home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / asmutil / priac1.zip / PRIAC.ASM next >
Assembly Source File  |  1988-09-05  |  3KB  |  101 lines

  1. comment    |
  2.  
  3.     This program reads and reports the current contents of the Inter-
  4.     Application Communications Area (IAC).
  5.  
  6.     The IAC is 16 bytes beginning at addr 0040:00F0h. Any program can
  7.     write information to the IAC for another program to read. Please
  8.     note: unless the first program directly    invokes the second program,
  9.     it cannot protect the IAC from being altered by an intervening program.
  10.     The IAC can be used, for instance, to pass an address from one program
  11.     to the next.
  12.  
  13.     Written for MASM 5.0 by Hardin Brothers for PCResource. The original
  14.     appeared in the April 1988 issue of their magazine. Entire contents of
  15.     the April 1988 issue (C) Copyright 1988 by
  16.                 IDG Communications/Peterborough, Inc.
  17.  
  18.     Hardin Brothers is a freelance programmer and technical writer. Write
  19.     to him at 280 N. Campus Ave., Upland, CA  91786. Enclose a self-
  20.     addressed, stamped envelope for a reply.
  21.  
  22.     |
  23.  
  24. LF    equ    0Ah    ; linefeed char
  25. CR    equ    0Dh    ; carriage return char
  26. STDOUT    equ    1    ; standard output device
  27.  
  28. EXIT    macro    val
  29.     mov    AH, 4Ch        ; INT 21h service 4Ch: exit from program
  30.                 ; also returns a value. replaces old INT 20h.
  31.     mov    AL, val        ; return value byte
  32.     int    21h
  33.     endm
  34.  
  35.     .MODEL    SMALL
  36.     .STACK
  37.  
  38.     .DATA
  39. hexasc        db    '0123456789ABCDEF'
  40.  
  41. title$        db    CR, LF
  42.         db    'Contents of Inter-Application Communication Area'
  43.         db    ' (IAC):', CR, LF, CR, LF
  44. ltitle        equ    $-title$
  45.  
  46. byte$        db    ' '
  47. cnvt$        db    '  h'
  48. lbyte        equ    $-byte$
  49.  
  50.     .CODE
  51.  
  52. start:    mov    AX, @data
  53.     mov    DS, AX        ; initialize data seg register
  54.     lea    DX, title$    ; addr DS:DX points to output string
  55.     mov    CX, ltitle    ; output string byte count
  56.     mov    BX, STDOUT    ; write to standard output device
  57.     mov    AH, 40h        ; INT 21h service 40h: write to file/device
  58.     int    21h
  59.     mov    AX, 0040h    ; BIOS information segment
  60.     mov    ES, AX        ; initialize ES
  61.     mov    SI, 0F0h    ; start of IAC
  62.     mov    CX, 10h        ; length of IAC in bytes
  63.  
  64. lp:    mov    AL, ES:[SI]    ; get a byte from IAC
  65.     push    CX
  66.     push    BX        ; save loop count and device handle
  67.     call    convert        ; convert bytes to ASCII
  68.     pop    BX        ; restore handle
  69.     lea    DX, byte$    ; addr DS:DX points to output string
  70.     mov    CX, lbyte    ; string byte count
  71.     mov    AH, 40h
  72.     int    21h
  73.     pop    CX        ; restore loop count
  74.     inc    SI        ; point to next byte in IAC
  75.     loop    lp        ; continue loop
  76.     mov    AH, 02h        ; INT 21h service 02h: write a char to stdout
  77.     mov    DL, CR
  78.     int    21h
  79.     mov    AH, 02h
  80.     mov    DL, LF
  81.     int    21h
  82.     EXIT    0        ; normal termination value
  83.  
  84. convert:
  85.     lea    DI, cnvt$    ; DS:DI points to storage area
  86.     lea    BX, hexasc    ; DS:BX points to ASCII translation string
  87.     mov    AH, AL        ; keep copy of byte
  88.     mov    CL, 4        ; set nibble count
  89.     shr    AL, CL        ; move top nibble down
  90.     xlat    BX        ; translate nibble to ASCII char
  91.     mov    [DI], AL    ; store ASCII char
  92.     inc    DI        ; point to next char space
  93.     mov    AL, AH        ; restore byte
  94.     and    AL, 0Fh        ; mask top nibble
  95.     xlat    BX        ; translate
  96.     mov    [DI], AL    ; store char
  97.     ret
  98.  
  99.     end    start
  100.  
  101.