home *** CD-ROM | disk | FTP | other *** search
- ; Assembler source for Procedure WriteChar
-
- ; This procedure was written in Assembler with the intention to use the
- ; the assembled code to generate the INLINE code for the procedure
- ; WriteChar. It may need some more work if anyone wants to use this as
- ; a linkable procedure.
-
- Code Segment
- assume ds:code,cs:code,es:code,ss:code
- start: sti
- xor bx,bx
- push ds
- mov dx,40h
- mov ds,dx
- mov bl,[cs:Out_Page] ;Introduce 'Out_Page' instead of address
- ;in Inline statement
- and bl,7
- shl bx,1
- mov dx,[bx+50h]
- mov cx,0b800h
- mov es,cx
- push dx
- mov ax,800h
- mul bx
- pop dx
- mov cx,ax
- mov ax,[bp+0aaaah] ;0aaah is a dummy address..To be replaced in
- ;Inline statement with 'Inchar'
- mov ah,[cs:Attribute] ;Introduce 'Attribute' instead of address
- ; in Inline statement
- mov si,ax
- cmp al, 07
- jnz Nobell ;If Bell character,Use INT10,function 0Eh
- mov ah,0Eh
- int 10h
- inc dl
- jmp short BS
- Nobell: cmp al,0DH
- jz CR
- cmp al,0Ah
- jz LF
- cmp al,08
- jz BS
- mov di,cx
- mov ax,50h
- mul dh
- push dx
- xor dh,dh
- add ax,dx
- shl ax,1
- add di,ax
- mov dx,03dah
- Checknz: in al,dx ;Wait for horizontal retrace to end if occuring
- rcr al,1
- jc checknz
- cli
- Checkz: in al,dx ;Wait for start of next horizontal retrace
- rcr al,1
- jnc checkz
- mov ax,si
- stosw
- sti ;Output character to screen
- pop dx
- inc dx
- cmp dl,50h
- jb setcursor
- xor dl,dl
- LF: cmp dh,18h ;Line feed
- jnb scroll
- inc dh
- jmp short setcursor
- CR: xor dl,dl ;Carriage Return
- jmp short setcursor
- BS: or dl,dl ;Backspce
- jz exit
- dec dl
- jmp short setcursor
- scroll: push ds ;Scroll
- push dx
- mov dx,0b800h
- mov es,dx
- mov ds,dx
- mov di,cx
- mov ax,si
- mov si,cx
- add si,0A0h
- mov cx,07B0h
- mov al,20h
- mov dx,03dah
- Checkz1: in al,dx ;Wait for a vertical retrace
- test al,8
- jz checkz1
- mov dx,03d8h ;Blank screen while scrolling
- mov al,1h
- out dx,al
- cli
- cld
- Repz MovsW
- mov cx,50h
- mov al,20h
- repz stosw
- mov dx,03dah
- Checkz2: in al,dx ;Wait for next vertical retrace
- test al,8
- jz checkz2
- mov dx,03d8h
- mov al,9h ;Re-enable display
- out dx,al
- sti
- pop dx
- pop ds
- setcursor:mov [bx+50h],dx
- shr bx,1
- cmp bl,[0062h]
- jnz exit ;If Out_Page is currently displayed,send
- ;new cursor address to CRT controller
- mov al,0A0h
- mul dh
- xor dh,dh
- shl dx,1
- add ax,dx
- add ax,[004Eh]
- shr ax,1
- mov dx,03d4h
- mov cx,ax
- mov al,0eh
- out dx,al
- inc dx
- mov al,ch
- out dx,al
- mov al,0fh
- dec dx
- out dx,al
- inc dx
- mov al,cl
- out dx,al
- exit : pop ds
- ;*********************************************
- Out_page db 0 ;Dummy variables provided to prevent Assembler
- Attribute db 0 ;returning an error
- code ends
- end
- ;*********************************************************************
- ; Assembler source for Procedure Display_Page
- code1 segment
- Assume cs:code
- mov ah,05h
- mov al,[bp+0aaaah] ;Replace the 0aaah by variable "a" in
- ;the INLINE statement
- and al,03 ;Page # should be between 0 and 3
- int 10h
- Code1 ends
- end
- ;*********************************************************************