CODE EXAMPLE: SIMPLE IO PROGRAM
;Code routine to add numbers
.MODEL small
;######################################
.STACK 500
;######################################
.DATA
data_1 dw 0
;######################################
.CODE
start proc near
mov dx,@data ;get data segment index
mov ds,dx ;set data segment
add_loop:
call get_number
jc number_error
mov data_1,ax
call get_number
jc number_error
add ax,data_1
call display_number
jmp add_loop
;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
number_error:
mov ah,4CH ;set for DOS terminate function
mov al,0 ;set terminating variable code
int 21H ;call DOS to terminate
start endp
;************************************
get_number proc near
;on exit if carry clear then number in AX is OK else ERROR
call display_new_line
mov ah,1 ;set for read keyboard function
int 21H ;call DOS to get keyboard data
cmp al,’0’ ;test for valid number
jb get_number_bad ;jump if bad number
cmp al,’9’
ja get_number_bad ;jump if bad number
an ax,0FH
clc ;set OK exit code
ret ;exit
get_number_bad:
stc ;set ERROR exit code
ret ;exit subroutine
get_number endp
;************************************
display_number proc near
;on exit binary number in AX is displayed (between 0 to 19)
call display_new_line
display_number_1:
cmp al,9
ja display_number_2
or al,30H
mov dl,al
mov ah,2 ;set for DOS display character
int 21H ;call DOS function
ret ;exit subroutine
display_number_2:
sub al,10 ;adjust number
push ax ;save adjusted number
mov dl,’1’
mov ah,2 ;set for DOS display character
int 21H ;call DOS function
pop ax ;restore adjusted number
jmp display_number_1
display_number endp
;************************************
display_new_line proc near
;on exit cursor is at start of next line down
push ax ;save AX register
push dx ;save DX register
mov dl,0DH ;start of line character
mov ah,2 ;set for DOS display character
int 21H ;call DOS function
mov dl,0AH ;new line character
mov ah,2 ;set for DOS display character
int 21H ;call DOS function
pop dx ;restore DX register
pop ax ;restore AX register
ret ;exit subroutine
display_new_line endp
;************************************
end start
CODE EXAMPLE: PRINT FILE PROGRAM
; This program prints a file defined on the command line
.MODEL small
;************* Stack Section *********************
.STACK 500
;************* Data Section **********************
.DATA
psp_seg dw 0
no_cl_mess db "This routine requires that a "
db "filename be on the command line for printing."
db 0dh,0ah,"Please try with a filename.",0dh,0ah,"$"
file_bad_open db "Bad file open",0dh,0ah,"$"
file_bad_read db "Bad file read",0dh,0ah,"$"
printer_bad_mess db "!! Printer Error !!!!",0dh,0ah,"$"
printing_mess db "A file is being printed,",0dh,0ah
db "To stop printing, Press ESC key",0dh,0ah,"$"
filename db 128 dup(0)
file_handle dw 0
file_count dw 0
file_pointer dw offset file_buffer
file_buffer db 1024 dup(0)
; ************* ----------- *********************
;************* Code Section *******************
.CODE
start proc near
;DS and ES are indexing PSP area
mov al,[DS:80H] ;load AL with size of data line
mov dx,@data ;get segment address of data area
mov ds,dx ;point DS to data area
mov psp_seg,ES ;save PSP address
cmp al,1 ;?? data in DOS command line ??
ja get_PSP_filename ;branch if data found
;if here, there is no data on command line
;display error message to user and terminate
lea dx,no_cl_mess
;-------------------------
terminate_display:
;display message indexed by DX then terminate
mov ah,09
int 21H ;DOS Call
;-------------------------
terminate_program:
;terminating the program
mov ah,4CH ;set AH for terminating function
mov al,00 ;set terminating code variable
int 21H ;call DOS to terminate
;------------------------------------------
; %%%%%%%%%%%%% ----------- %%%%%%%%%%%%%%%
get_PSP_filename:
;move PSP filename to filename buffer in our data area
mov ax,ds
mov es,ax ;point ES to data segment
mov ds,psp_seg
mov si,82H ;SI source is PSP data area
lea di,filename
cld ;make strings go forward
get_PSP_data_1:
lodsb ;load string data byte
;check for end of filename
cmp al,21H
;branch if end of string
jb got_PSP_filename
stosb ;store string data byte
jmp get_PSP_data_1
got_PSP_filename:
mov al,0
stosb ;make ASCIIZ string with zero end
push es
pop ds ;reset data segment pointer
;try to open file
mov ah,3dH
lea dx,filename
mov al,0 ;read access code
int 21H ;DOS Call
jnc file_open_ok
lea dx,file_bad_open
jmp terminate_display
;+++++++++++++++++++++++++++++++++++++++++++
;############### +++++++++++ ###############
file_open_ok:
;save file handle
mov file_handle,ax
lea dx,printing_mess ;display start message
mov ah,09
int 21H ;DOS Call
file_read:
;read in block of file data
mov ah,3fH
lea dx,file_buffer
mov cx,1024
mov bx,file_handle
int 21H ;DOS Call
jnc file_read_ok ;branch if good read
;else read file error occurred
;close file
mov ah,3eh
mov bx,file_handle
int 21H
;index exit error message
lea dx,file_bad_read
jmp terminate_display
file_read_ok:
;check to see if no more file data
cmp ax,0
je close_file ;branch if no data left
;else reset data block size and pointer
mov file_count,ax
lea bx,file_buffer
mov file_pointer,bx
;!!!!!!!!!!!!!!!!! ^^^^^^^^ !!!!!!!!!!!!!!!!!!!!
print_data_block:
;main loop to print block of file data
;scan keyboard to check for any keys
mov ah,1
int 16H
jz print_data_block_1 ;branch if no key
;get key code out of buffer
mov ah,0
int 16H ;call BIOS keyboard
cmp al,01BH ;check key code
je close_file ;branch if ESC
print_data_block_1:
mov si,file_pointer
mov al,[si]
mov ah,0
mov dx,0 ;select LPT1
int 17H ;BIOS Call
test ah,25H
jnz printer_error
inc si
mov file_pointer,si
dec file_count
jnz print_data_block ;loop if more data
;else go read in next block of file data
jmp file_read
;!!!!!!!!!!!!!!!! ^^^^^^^^ !!!!!!!!!!!!!!!!!!!!
close_file:
mov ah,3eh
mov bx,file_handle
int 21H ;DOS Call
jmp terminate_program
;-------------- ?????????? -------------------
printer_error:
;index exit error message
lea dx,printer_bad_mess
jmp terminate_display
;_______________________________________________
start endp ;end of start procedure
end start ;define start as beginning of program
CODE EXAMPLE: GET TIME OF
DAY
; Wait for Time
;This program can be executed inside of a .BAT file to
; stall execution of the .BAT file until a set time of day
;?????????????????????????????????????????????????????????? ???
;conditional assembly flag, 0 to use DOS, 1 to use BIOS example
.MODEL tiny
use_bios_flag EQU 1
;----------- stack area ---------------
.STACK 500
;--------------------------------------
.CODE
;************* @@@@@@@@@@@@@@ ***************
start proc near
mov bx,80H ;index command line data
mov al,[bx] ;get size of string variable
mov ax,cs
mov ds,ax ;reset data segment
mov psp_seg,es ;save PSP address
mov es,ax ;reset extra segment
cmp al,4 ;is there data in string
jb exit_bad ;branch if no data
inc bx
inc bx ;point to start of data
;get number out of buffer area
call get_number
jc exit_bad ;branch if number bad
mov wait_hour,al ;save number in hour
cmp al,23 ;?? number too large ??
ja exit_bad ;branch is too large
;check the number terminating character
cmp ah,":"
jne exit_bad ;branch if not :
;point to start of next number
inc bx
;get next number out of buffer area
call get_number
jc exit_bad ;branch if number bad
cmp al,59 ;?? number too large ??
ja exit_bad ;branch if too large
mov wait_minute,al ;save number to minute
;display executing wait message
mov ah,9 ;set DOS function number
lea dx,wait_message
int 21H ;DOS call to display message
;________________________________
;********** !!!!!!!! **********
wait_loop:
;scan keyboard for keys
mov ah,1
int 16H
jz wait_no_key ;branch if no key
mov ah,0 ;if here then keyboard data
int 16H ;get key code from buffer
cmp ax,3B00H ;check key code
je exit ;branch if exit key
cmp al,1BH ;check for ESC key
je exit ;branch if ESC key
wait_no_key:
;find out what time it is
;conditional assembly ????????????????????
;use this code if linking to code in this section
IF use_bios_flag
call get_time_of_day
;else use this code if calling DOS for time
ELSE
mov ah,2CH
int 21H ;get current time of day
ENDIF
cmp ch,wait_hour
jne wait_loop ;loop if not time
cmp cl,wait_minute
jne wait_loop ;loop if not time
;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
exit:
mov ah,4CH
int 21h ;terminate program
;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
exit_bad:
mov ah,9
lea dx,exit_bad_message
int 21H ;DOS call to display message
jmp exit
; ***** ^^^^^^^^ ***** ^^^^^^^^ ****
get_number:
;on entry BX indexes ASCII number data in PSP segment area
;on exit if carry clear,
; register AL has binary number, from 0 to 99
; BX indexes past the number,
; AH has exiting character code indexed by BX
push ds
mov ds,psp_seg
mov al,[bx]
inc bx
call number_check
jc get_number_bad
mov ah,al
mov al,[bx]
call number_check
jc get_number_1
get_number_2a:
cmp ah,0
je get_number_2
add al,10
dec ah
jmp get_number_2a
get_number_2:
inc bx
mov ah,al
mov al,[bx]
get_number_1:
cmp al,":"
je get_number_1a
cmp al,0DH
jne get_number_bad
get_number_1a:
xchg al,ah
pop ds
clc ;set good number flag
ret
get_number_bad:
pop ds
stc ;set bad number flag
ret
;#################################################
number_check:
;this code checks for ASCII number in AL
; if it finds a number, then it makes it binary
; and returns with carry clear, else carry set
cmp al,"0"
jb number_bad
cmp al,"9"
ja number_bad
and al,0FH
clc
ret stc
ret
;*************************
start endp
;+++ this routine combines data and code into one segment +++
; define data area
psp_seg dw 0
wait_hour db 0
wait_minute db 0
wait_message db 0DH,0AH,0DH,0AH
db "Wait in progress, Press [ESC] to exit",0DH,0AH
db "$"
exit_bad_message db 0DH,0AH
db "To use TimeWait program enter timeout data "
db "from command line as example:",0DH,0AH,0DH,0AH
db "TimeWait 11:30",0DH,0AH,0DH,0AH
db "Note, timeout hours vary from 0 to 23, "
db "and minutes from 0 to 59.",0DH,0AH
db "$"
;______________________________________
end start
CODE EXAMPLE: MAKE SOUNDS
;Set of keyboard routines with sound outputs
.MODEL small
.STACK 500
.DATA
;define table for sound output
;sample_sounds dw 8,45000 ;long low sound
; dw 2,2000 ;short high sound
; dw 0 ;end of sample sound table
sound_table dw 0
sound_time_m dw 0
sound_time_l dw 0
sound_flag db 0
sound_on_flag db 0,0
key_time_out_m dw 0
key_time_out_l dw 0
.CODE
;************ ^^^^^^^^^^ *************
;### code entry point #####
get_keyinput proc near
;this routine checks for keyboard data in BIOS buffer
; and returns with data if there
;else it updates sound output data and loops to check for
; keyboard data again until keyboard data found
;on exit AX has keyboard data
public get_keyinput
push bx
push cx
push dx
get_keyinput_loop:
mov ah,1 ;set AH for scan
int 16H ;BIOS Call
;branch if no keyboard data
jz sound_update
mov ah,0 ;set AH for get key
int 16H ;BIOS Call
pop dx
pop cx
pop bx
ret
;******* -------- *******
sound_update:
cmp sound_flag,0 ;check for sound on????
jz get_keyinput_loop ;branch out if sound off
mov cx,sound_time_m ;else check for sound update
mov ax,sound_time_l
call test_current_time ;is it time for update ??
jc get_keyinput_loop ;branch if not time
mov bx,sound_table
mov ax,[bx] ;get next sound update value
or ax,ax ;?? end of sound ??
jz turn_sound_off ;branch if end sound
call get_time_plus_ax ;reset sound duration
mov sound_time_m,cx
mov sound_time_l,ax
inc bx
inc bx
mov ax,[bx]
inc bx
inc bx
mov sound_table,bx
call sound_out_ax ;go set sound frequency
jmp get_keyinput_loop ;branch to keyboard loop
turn_sound_off:
call sound_off
mov sound_flag,0
jmp get_keyinput_loop ;branch to keyboard loop
get_keyinput endp
;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
;************ ########## *************
;### code entry point #####
get_keyinput_to proc near
;get keyboard data with timeout if no data available
;on entry AX has time duration in 18 ticks per second
;on exit if carry clear then AX has keyboard data
public get_keyinput_to
push bx
push cx
push dx
call get_time_plus_ax ;add duration to current time
mov key_time_out_m,cx ;set timeout value
mov key_time_out_l,ax
get_keyinput_to_loop:
mov ah,1 ;ready to scan keyboard data
int 16H ;BIOS Call
jz sound_update_to ;branch if no keyboard data
mov ah,0 ;ready to get key data
int 16H ;BIOS Call
pop dx
pop cx
pop bx
clc ;set keyboard data flag
ret
get_keyinput_to_1:
mov cx,key_time_out_m ;check for timeout
mov ax,key_time_out_l
call test_current_time
jc get_keyinput_to_loop ;branch if no timeout
xor ax,ax ;else timeout return condition
pop dx
pop cx
pop bx
stc ;set no keyboard data flag
ret
; ******** %%%%%%% ********
sound_update_to:
cmp sound_flag,0 ;check for sound on????
jz get_keyinput_to_1 ;branch if sound off
mov cx,sound_time_m ;else check for sound update
mov ax,sound_time_l
call test_current_time
jc get_keyinput_to_1 ;branch if not ready for update
mov bx,sound_table
mov ax,[bx]
or ax,ax ;test for end of table
jz turn_sound_off_to ;branch if end of table data
call get_time_plus_ax
mov sound_time_m,cx
mov sound_time_l,ax
inc bx
inc bx
mov ax,[bx]
inc bx
inc bx
mov sound_table,bx
call sound_out_ax
jmp get_keyinput_to_1
turn_sound_off_to:
call sound_off
mov sound_flag,0
jmp get_keyinput_to_1
get_keyinput_to endp
;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
;************ @@@@@@@@@@ ************
;### code entry point #####
start_table_sound proc near
;subroutine to start background sound output
;on entry BX indexes sound data table
public start_table_sound
push ax
push bx
mov ax,[bx]
call get_time_plus_ax
mov sound_time_m,cx
mov sound_time_l,ax
inc bx
inc bx
mov ax,[bx]
inc bx
inc bx
mov sound_table,bx
call sound_out_ax
mov sound_flag,0FFH
pop bx
pop ax
ret
start_table_sound endp
;************ ========== *************
;### code entry point #####
flush_keyboard proc near
;utility to flush contents of keyboard buffer
public flush_keyboard
mov ah,1
int 16H ;BIOS Call ;scan for keyboard data
jz flush_keyboard_x ;branch if no keyboard data
mov ah,0 ;else get keyboard data
int 16H ;BIOS Call
jmp flush_keyboard
flush_keyboard_x:
ret
flush_keyboard endp
;************* ----------- **************
sound_out_ax proc near
;set sound out frequency to data value in AX
push ax
push ax
cmp sound_on_flag,0
jne sound_out_1
in al,61H ;input port 61h
or al,3
out 61H,al ;output port 61h
sound_out_1:
mov al,0B6H
out 43H,al ;output port 43h
pop ax
out 42H,al ;output port 42h
xchg al,ah
out 42H,al ;output port 42h
mov sound_on_flag,0FFH
pop ax
ret
sound_out_ax endp
;*********** $$$$$$$$$$ ************
;###### code entry point #######
sound_off proc near
;turn sound port off
public sound_off
push ax
cmp sound_on_flag,0
je sound_off_exit
in al,61H ;input port 61h
and al,0FCH
out 61H,al ;output port 61h
mov sound_on_flag,0
sound_off_exit:
pop ax
ret
sound_off endp
;************** %%%%%%%%%% ***************
;with all CX:AX time values, CX is most significant
; and AX is least significant
get_current_time proc near
;on exit CX:AX has 32 bit day clock value
; in 18.2 ticks per second
push dx
xor ax,ax ;set AH to zero
int 1AH ;BIOS Call get time
mov ax,dx
pop dx
ret
get_current_time endp
;****************************
get_time_plus_ax proc near
;on entry AX has 16 bit value to add to current clock time
;on exit CX:AX has new 32 bit clock value
push dx
push ax
xor ax,ax
int 1AH ;BIOS Call
pop ax
add ax,dx
adc cx,0
pop dx
ret
get_time_plus_ax endp
;************ ######## ************
test_current_time proc near
;on entry CX:AX has time value
; to be subtracted from the current time
;on exit if carry set then current time
; is less than CX:AX time
push dx
push cx
push ax
xor ax,ax
int 1AH ;BIOS Call
cmp dx,18
jb test_current_time_2
test_current_time_1:
pop ax
sub dx,ax
pop dx
sbb cx,dx
mov cx,dx
pop dx
ret
test_current_time_2:
or cx,cx
jnz test_current_time_1
pop ax ;this is fix code for midnight factor
pop dx
pop dx
clc ;clear carry condition
ret
test_current_time endp
;*****************************************
end
CODE EXAMPLE: VIDEO CHARACTER INTERFACE
;set of video display routines
.MODEL small
public reset_video
public clear_screen
public get_cursor_position, set_cursor_position
;write character in AL, use TTY method
public write_to_screen
;write string indexed by SI using TTY
public write_asciiz_string
;write character in AL and display control codes
public display_character
public save_screen, restore_screen
;set by program to activate escape code functions
public esc_flag
public normal_attribute
public scroll_screen_up, scroll_screen_down
public screen_buffer, cursor_port
.DATA
;video data variables
even
cursor dw 0
save_cursor dw 0
cursor_port dw 3B4H
screen_buffer dw 2001 dup(0)
esc_flag db 0
esc_on_flag db 0
esc_y_flag db 0
esc_y_line db 0
video_hw_mode db 0
normal_attribute db 07H
;jump table used for ESC codes
esc_jmp_table db "A"
dw write_esc_a
db "B"
dw write_esc_b
db "C"
dw write_esc_c
db "D"
dw write_esc_d
db "H"
dw write_esc_h
db "I"
dw write_esc_i
db "J"
dw write_esc_j
db "K"
dw write_esc_k
db "Y"
dw write_esc_y
db 0,0,0
.CODE
;****************** $$$$$$$$$$$$$ ******************
reset_video proc near
;this routine needs to be called before any other video
; function routines to start up the video system
;on exit if carry set then video mode less than 80 columns
push ax
push bx
mov ah,15
int 10H ;check current video mode
cmp ah,80
jae reset_video_80_b ;branch if 80+ columns
;video is less than 80 columns
stc ;set for error condition on exit
jmp short reset_video_exit_b
reset_video_80_b:
mov video_hw_mode,0FFH
mov normal_attribute,07H
clc
reset_video_exit_b:
pop bx
pop ax
ret
reset_video endp
;################################################
; ************** ############ ****************
clear_screen proc near
;clear screen using BIOS calls
push ax
push cx
push dx
push bx
mov ax,600H
mov cx,0000H
mov dh,24
mov dl,79
mov bh,normal_attribute
int 10H
xor dx,dx
call set_cursor_position
pop bx
pop dx
pop cx
pop ax
ret
clear_screen endp
;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
;************** ^^^^^^^^^^^^ ***************
set_cursor_position proc near
;set cursor with BIOS call
;on entry have DX set for new cursor position
push ax
push bx
push dx
mov ah,2
mov cursor,dx
xor bx,bx
int 10H
pop dx
pop bx
pop ax
ret
set_cursor_position endp
;-----------------------------------------
;************ %%%%%%%%%%%%% ************
get_cursor_position proc near
;on exit DX has current cursor position
mov dx,cursor
ret
get_cursor_position endp
;__________________________________
;*********** -------- *************
write_esc_y_on:
cmp esc_y_flag,0FFH
jne write_esc_y_on1
sub al,20H
mov esc_y_line,al
mov esc_y_flag,0FH
jmp write_to_screen_x
write_esc_y_on1:
sub al,20H
mov dl,al
mov dh,esc_y_line
cmp dh,24
ja write_esc_y_er
cmp dl,79
ja write_esc_y_er
call set_cursor_position
write_esc_y_er:
mov esc_y_flag,0
mov esc_on_flag,0
jmp write_to_screen_x
;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
write_esc_data:
cmp esc_y_flag,0
jne write_esc_y_on
lea bx,esc_jmp_table
write_esc_data_l:
cmp al,[bx]
je write_esc_data_jmp
add bx,3
cmp byte ptr[bx],0
jne write_esc_data_l
mov esc_on_flag,0
jmp write_to_screen_x
write_esc_data_jmp:
mov bx,[bx+1] ;perform Table Lookup Jump
jmp bx
;---------------------------------
;*********** %%%%%% ************
write_to_screen proc near
;on entry AL has ASCII character for TTY output
; this code uses the system BIOS calls for display functions
push ax
push bx
push cx
push dx
cmp esc_on_flag,0
jne write_esc_data
mov bl,normal_attribute
cmp al,20H
jb write_to_screen_c
write_to_screen_0:
mov cx,01
mov bh,0
mov ah,9
int 10H
mov dx,cursor
cmp dl,79
je write_to_screen_1
inc dl
call set_cursor_position
jmp short write_to_screen_x
write_to_screen_1:
mov dl,0
cmp dh,24
je write_to_screen_2
inc dh
call set_cursor_position
jmp short write_to_screen_x
write_to_screen_2:
call set_cursor_position
call scroll_screen_up
write_to_screen_x proc near
pop dx
pop cx
pop bx
pop ax
ret
write_to_screen_x endp
write_to_screen_c:
; check for special keyboard control codes
mov dx,cursor
cmp al,0DH
je write_to_screen_cr
cmp al,0AH
je write_to_screen_lf
cmp al,09H
je write_to_screen_tab
cmp al,0CH
je write_to_screen_ff
cmp al,08H
je write_to_screen_bs
cmp al,1BH
je write_to_screen_esc
jmp write_to_screen_0 ;branch if unknown code
write_to_screen_cr:
mov dl,0
call set_cursor_position
jmp write_to_screen_x
write_to_screen_lf:
cmp dh,24
je write_to_screen_lf1
inc dh
call set_cursor_position
jmp write_to_screen_x
write_to_screen_lf1:
call scroll_screen_up
jmp write_to_screen_x
write_to_screen_tab:
and dl,0F8H
add dl,8
cmp dl,80
je write_to_screen_tab1
call set_cursor_position
jmp write_to_screen_x
write_to_screen_tab1:
mov dl,0
cmp dh,24
je write_to_screen_tab2
inc dh
call set_cursor_position
jmp write_to_screen_x
write_to_screen_tab2:
call set_cursor_position
call scroll_screen_up
jmp write_to_screen_x
write_to_screen_ff:
call clear_screen
jmp write_to_screen_x
write_to_screen_bs:
or dl,dl
jz write_to_screen_bsx
dec dl
call set_cursor_position
write_to_screen_bsx:
jmp write_to_screen_x
write_to_screen_esc:
cmp esc_flag,0
jne write_to_screen_esc_1
mov esc_on_flag,0FFH
jmp write_to_screen_x
write_to_screen_esc_1:
jmp write_to_screen_0
write_to_screen endp
;++++++++++++++++++++++++++++++++++++++++++++
;************* <<<<<< >>>>>> **************
;the following are for processing escape string functions
write_esc_a proc near
;move cursor up one line
mov dx,cursor
cmp dh,0
je write_esc_a_0
dec dh
call set_cursor_position
write_esc_a_0:
mov esc_on_flag,0
jmp write_to_screen_x
write_esc_a endp
write_esc_b proc near
;move cursor down one line
mov dx,cursor
cmp dh,24
je write_esc_b_0
inc dh
call set_cursor_position
write_esc_b_0:
mov esc_on_flag,0
jmp write_to_screen_x
write_esc_b endp
write_esc_c proc near
;move cursor right one character
mov dx,cursor
cmp dl,79
je write_esc_c_0
inc dl
call set_cursor_position
write_esc_c_0:
mov esc_on_flag,0
jmp write_to_screen_x
write_esc_c endp
write_esc_d proc near
;move cursor left one character
mov dx,cursor
cmp dl,0
je write_esc_d_0
dec dl
call set_cursor_position
write_esc_d_0:
mov esc_on_flag,0
jmp write_to_screen_x
write_esc_d endp
write_esc_h proc near
;move cursor to top left position
xor dx,dx
call set_cursor_position
mov esc_on_flag,0
jmp write_to_screen_x
write_esc_h endp
write_esc_i proc near
;move cursor up with scroll if on top line
mov dx,cursor
cmp dh,0
je write_esc_i_0
dec dh
call set_cursor_position
mov esc_on_flag,0
jmp write_to_screen_x
write_esc_i_0:
call scroll_screen_down
mov esc_on_flag,0
jmp write_to_screen_x
write_esc_i endp
write_esc_j proc near
;erase from cursor to end of screen
push cx
push bx
mov ax,cursor
mov cx,79
sub cl,al
write_esc_j2:
cmp ah,24
je write_esc_j1
add cx,80
inc ah
jmp write_esc_j2
write_esc_j1:
jcxz write_esc_j3
mov bl,normal_attribute
mov al,20H
add cx,1
mov bh,0
mov ah,9
int 10H
write_esc_j3:
pop bx
pop cx
mov esc_on_flag,0
jmp write_to_screen_x
write_esc_j endp
write_esc_k proc near
;erase from cursor to end of line
push cx
push bx
mov ax,cursor
mov cx,79
sub cl,al
jcxz write_esc_k1
mov bl,normal_attribute
mov al,20H
add cx,1
mov bh,0
mov ah,9
int 10H
write_esc_k1:
pop bx
pop cx
mov esc_on_flag,0
jmp write_to_screen_x
write_esc_k endp
write_esc_y proc near
;set cursor position
mov esc_y_flag,0FFH
jmp write_to_screen_x
write_esc_y endp
;_______________________________________________
;************ <<<<<<<<< >>>>>>>>>> ************
display_character proc near
;on entry AL has character for output using BIOS calls
push ax