home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / TURBOPAS / PAGWRITE.ZIP / PAGEDISP.ASM next >
Encoding:
Assembly Source File  |  1985-10-07  |  4.9 KB  |  154 lines

  1. ; Assembler source for Procedure WriteChar
  2.  
  3. ; This procedure was written in Assembler with the intention to use the
  4. ; the assembled code to generate the INLINE code for the procedure
  5. ; WriteChar. It may need some more work if anyone wants to use this as
  6. ; a linkable procedure.
  7.  
  8. Code      Segment
  9.           assume  ds:code,cs:code,es:code,ss:code
  10. start:    sti
  11.           xor     bx,bx
  12.           push    ds
  13.           mov     dx,40h
  14.           mov     ds,dx
  15.           mov     bl,[cs:Out_Page] ;Introduce 'Out_Page' instead of address
  16.                                    ;in Inline statement
  17.           and     bl,7
  18.           shl     bx,1
  19.           mov     dx,[bx+50h]
  20.           mov     cx,0b800h
  21.           mov     es,cx
  22.           push    dx
  23.           mov     ax,800h
  24.           mul     bx
  25.           pop     dx
  26.           mov     cx,ax
  27.           mov     ax,[bp+0aaaah] ;0aaah is a dummy address..To be replaced in
  28.                                  ;Inline statement with 'Inchar'
  29.           mov     ah,[cs:Attribute] ;Introduce 'Attribute' instead of address
  30.                                     ; in Inline statement
  31.           mov     si,ax
  32.           cmp     al, 07
  33.           jnz     Nobell ;If Bell character,Use INT10,function 0Eh
  34.           mov     ah,0Eh
  35.           int     10h
  36.           inc     dl
  37.           jmp     short BS
  38. Nobell:   cmp     al,0DH
  39.           jz      CR
  40.           cmp     al,0Ah
  41.           jz      LF
  42.           cmp     al,08
  43.           jz      BS
  44.           mov     di,cx
  45.           mov     ax,50h
  46.           mul     dh
  47.           push    dx
  48.           xor     dh,dh
  49.           add     ax,dx
  50.           shl     ax,1
  51.           add     di,ax
  52.           mov     dx,03dah
  53. Checknz:  in      al,dx       ;Wait for horizontal retrace to end if occuring
  54.           rcr     al,1
  55.           jc      checknz
  56.           cli
  57. Checkz:   in      al,dx       ;Wait for start of next horizontal retrace
  58.           rcr     al,1
  59.           jnc     checkz
  60.           mov     ax,si
  61.           stosw
  62.           sti                 ;Output character to screen
  63.           pop     dx
  64.           inc     dx
  65.           cmp     dl,50h
  66.           jb      setcursor
  67.           xor     dl,dl
  68. LF:       cmp     dh,18h           ;Line feed
  69.           jnb     scroll
  70.           inc     dh
  71.           jmp     short setcursor
  72. CR:       xor     dl,dl             ;Carriage Return
  73.           jmp     short setcursor
  74. BS:       or      dl,dl              ;Backspce
  75.           jz      exit
  76.           dec     dl
  77.           jmp     short setcursor
  78. scroll:   push    ds               ;Scroll
  79.           push    dx
  80.           mov     dx,0b800h
  81.           mov     es,dx
  82.           mov     ds,dx
  83.           mov     di,cx
  84.           mov     ax,si
  85.           mov     si,cx
  86.           add     si,0A0h
  87.           mov     cx,07B0h
  88.           mov     al,20h
  89.           mov     dx,03dah
  90. Checkz1:  in      al,dx               ;Wait for a vertical retrace
  91.           test    al,8
  92.           jz      checkz1
  93.           mov     dx,03d8h            ;Blank screen while scrolling
  94.           mov     al,1h
  95.           out     dx,al
  96.           cli
  97.           cld
  98.           Repz    MovsW
  99.           mov     cx,50h
  100.           mov     al,20h
  101.           repz    stosw
  102.           mov     dx,03dah
  103. Checkz2:  in      al,dx                ;Wait for next vertical retrace
  104.           test    al,8
  105.           jz      checkz2
  106.           mov     dx,03d8h
  107.           mov     al,9h               ;Re-enable display
  108.           out     dx,al
  109.           sti
  110.           pop     dx
  111.           pop     ds
  112. setcursor:mov     [bx+50h],dx
  113.           shr     bx,1
  114.           cmp     bl,[0062h]
  115.           jnz     exit         ;If Out_Page is currently displayed,send
  116.                                ;new cursor address to CRT controller
  117.           mov     al,0A0h
  118.           mul     dh
  119.           xor     dh,dh
  120.           shl     dx,1
  121.           add     ax,dx
  122.           add     ax,[004Eh]
  123.           shr     ax,1
  124.           mov     dx,03d4h
  125.           mov     cx,ax
  126.           mov     al,0eh
  127.           out     dx,al
  128.           inc     dx
  129.           mov     al,ch
  130.           out     dx,al
  131.           mov     al,0fh
  132.           dec     dx
  133.           out     dx,al
  134.           inc     dx
  135.           mov     al,cl
  136.           out     dx,al
  137. exit :    pop     ds
  138. ;*********************************************
  139. Out_page  db      0  ;Dummy variables provided to prevent Assembler
  140. Attribute db      0  ;returning an error
  141. code      ends
  142. end
  143. ;*********************************************************************
  144. ; Assembler source for Procedure Display_Page
  145. code1     segment
  146. Assume    cs:code
  147.           mov     ah,05h
  148.           mov     al,[bp+0aaaah]  ;Replace the 0aaah by variable "a" in
  149.                                   ;the INLINE statement
  150.           and     al,03           ;Page # should be between 0 and 3
  151.           int     10h
  152. Code1     ends
  153. end
  154. ;*********************************************************************