home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c017 / 36.ddi / DBTOC.ZIP / PRINTSTR.ASM < prev    next >
Encoding:
Assembly Source File  |  1987-10-09  |  2.1 KB  |  79 lines

  1. ;------------------------------------------------------------------
  2. ;  Function:   printstr(y,x,str_ptr)
  3. ;
  4. ;  This function prints a string to the screen
  5. ;
  6. ;
  7. ;------------------------------------------------------------------
  8.  
  9. include DATASEG.H
  10.  
  11.     x_off     dw    00
  12.     y_off     dw    00
  13.     bperln    db   0160           ; bytes per line
  14.  
  15. include ENDDSEG.H
  16.  
  17. include  PROGSEG.H
  18.  
  19.     public   printstr
  20.     printstr proc NEAR
  21.  
  22.     push bp                  ; save c's base pointer
  23.     push es                  ; save es, must be same as ds in S model
  24.     push ds
  25.  
  26.     mov  bp,sp
  27.  
  28.     mov  ax,8[bp]            ; get y offset
  29.     mov  y_off,ax
  30.  
  31.     mov  ax,10[bp]            ; get x offset
  32.     mov  x_off,ax
  33.  
  34.     mov  si,12[bp]           ; get string ptr
  35.  
  36. ;;;;;;;;;;;;;;;;;;;;;;;;
  37. ;; Check Adapter Type ;;
  38. ;;;;;;;;;;;;;;;;;;;;;;;;
  39.     mov  ah,0fH              ; function number for ROM BIOS video int
  40.     int  010H                ; perform interrupt
  41.     cmp  al,07               ; check if mode 7, monochrom mode
  42.     jz monochrom
  43.     mov  ax,0b800H           ; CGA/EGA vid ram segment
  44.     jmp  endchk
  45. monochrom:
  46.     mov  ax,0b000H           ; Monochrome vid ram segment
  47. endchk:
  48.     mov  es,ax
  49.  
  50.     mov  ax,y_off            ; calculate offset
  51.     mul  bperln              ; mult. by bytes per line to get vert offset
  52.     shl  x_off,1             ; mult by two, 2 bytes per char
  53.     add  ax,x_off
  54.     mov  di,ax               ; mov to di and use as pointer to vid ram
  55.  
  56.     mov  ah,BYTE PTR ds:[si] ; get character 
  57.     cmp  ah,00
  58.     jz   restregs            ; string is null
  59.  
  60. print_it:
  61.  
  62.     mov  BYTE PTR es:[di],ah ; put it on the screen, only one byte
  63.     inc  si                  ; goto next char
  64.     add  di,02               ; goto next character byte on screen
  65.     mov  ah,BYTE PTR ds:[si] ; get character
  66.     cmp  ah,00               ; check if Null
  67.     jnz  print_it
  68.  
  69. restregs:
  70.     pop  ds
  71.     pop  es
  72.     pop  bp                  ; restore the base pointer
  73.     ret  
  74.  
  75. printstr endp
  76. include  ENDPSEG.H
  77. end      printstr
  78.  
  79.