For the
Alien Planet Probe, I have to display two strings on the screen so it is better writing a
procedure that I can reuse. I designed a procedure called show_string. I
have coded it immediately using INT 10h since it has the same logic used in
Alien-Planet Landing-Module.
show_string:
######################################################################################
#
# This procedure shows a string on the video starting at address DS:[SI].
# It uses the int 10h assembly to show one character at each time and terminates
# as soon as the procedure finds the byte 0x00.
#
# INPUT: DS:SI
# OUTPUT: ---
# REGISTER USAGE: AX, BX
# THIS ONE CALLS:
#
#######################################################################################
##################################################################
# standard setup for displaying characters on the screen
##################################################################
mov ah, 0e # int10/AH = 0e : video teletype out
# AL = character to write
mov bx, 0007 # BH = page number
# BL = foreground color (graphics mode only)
##################################################################
# displays characters on the screen until "00" byte is found
##################################################################
do_until:
lodsb # AL = DS:[SI]; SI = SI + 1
cmp al, 00 # affect flags by: AL - 00
je do_end: # jump if ZeroFlag is set (ZF = 1)
int 10 # int 10h in 8086 puts a character on the screen
# and returns nothing
jmp do_until:
do_end:
####################
# end of procedure
####################
ret
I look at the show_string procedure as my baby version of the print function
in assembly. I just have to point DS:[SI] at the beginning of the string in
memory and then call show_string. It is very easy to use and I will use it
also in the future. After all, print a messages on screen is quite a common task.
By the way, we never "print" on any screen, we just display it, but the printer
was the first standard output for a computer in the history before the display
was used, so we keep saying that we print messages regardless where the
messages go: either to a printer or a screen.
Comments
Post a Comment