home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / Samples / C-ASM_VI.ARJ / PROGASM.ZIP / PROG057P.ASM < prev    next >
Encoding:
Assembly Source File  |  1988-06-29  |  2.4 KB  |  66 lines

  1.  
  2. ;************************************************************************
  3. ; Display text at specified row and column                              *
  4. ; Entry:        Row             - Starting row of the text              *
  5. ;               Column-Starting column of the text                      *
  6. ;               String-Pointer to Turbo Pascal string (with byte count) *
  7. ;************************************************************************
  8.  
  9. Row             EQU     [BP+12]
  10. Column          EQU     [BP+10]
  11. string_seg      EQU     [BP+8]
  12. string_offset   EQU     [BP+6]
  13.  
  14.         PUBLIC  Write_String
  15.  
  16. Write_String    PROC FAR
  17.         PUSH    BP
  18.         MOV     BP,SP
  19.         PUSH    DS
  20.         PUSH    DI                      ;Preserve registers
  21.         PUSH    SI
  22.         PUSH    ES
  23.  
  24.         ;--- Fetch number of rows and columns on the screen and
  25.         ;    compute absolute address in display buffer
  26.  
  27.         XOR     AX,AX                   ;Point ES to segment zero
  28.         MOV     ES,AX
  29.         MOV     AX,Row                  ;Fetch row number
  30.         MOV     BX,ES:[BIOS_Columns]    ;Fetch columns per screen
  31.         MUL     BX                      ;Compute absolute address
  32.         ADD     AX,Column               ;in the display buffer as
  33.         SHL     AX,1                    ;((Row*Col_per_row)+Column)*2
  34.         MOV     DI,AX                   ;Move address into register DI
  35.  
  36.         ;--- Determine and load segement of the display buffer
  37.  
  38.         MOV     AX,0B000H               ;Assume monochrome buffer address
  39.         TEST    BYTE PTR ES:[BIOS_Equipment],2   ;Is mono attached?
  40.         JNZ     Str_Address_Ok          ;...Yes, go load segment
  41.         MOV     AX,0B800H               ;...No, change address to color
  42. Str_Address_Ok:
  43.         MOV     ES,AX                   ;Set segment of display buffer
  44.  
  45.         ;--- Fetch address of the text
  46.  
  47.         mov     DS,string_seg
  48.         MOV     SI,string_offset        ;Get pointer to the string
  49.         lodsb
  50.         sub     ah,ah
  51.         mov     cx,ax                   ;get byte count
  52. charloop:
  53.         lodsb                   ;get char
  54.         stosb                   ;save char
  55.         inc     di              ;skip over attribute byte
  56.         loop    charloop
  57.  
  58. String_Done:
  59.         POP     ES                      ;Restore registers
  60.         POP     DI
  61.         POP     SI
  62.         POP     DS
  63.         POP     BP
  64.         RET     8
  65. Write_String    ENDP
  66.