I'm testing out writing text to a screen using emu8086. I'm trying to print out a 3x3 grid with the letters A to I. I imagine this isn't the conventional way to move the cursor down (perform a carriage return) but it should work.
org 100h
;
; Initialise
;
; Set video mode
mov AL, 13h
mov AH, 0
int 10h
; Set cursor position
mov DH, 1
mov DL, 1
mov BH, 0
mov AH, 2
int 10h
; Set cursor intensity/blinking
mov ax, 1003h
mov bx, 0
int 10h
; Set attribute to white foreground, black background
mov BL, 0Fh
call print_grid
jmp end
print_char PROC
mov AH, 09h ; Set interrupt to print
mov CX, 1 ; So that the character is only printed once
int 10h
inc DL ; Incrementing the cursor position horizontally
mov AH, 2h ; Set interrupt to set cursor position
int 10h
ret
print_char ENDP
carriage_return PROC
inc DH ; Incrementing the cursor position vertically
mov DL, 1 ; Resetting horizontal cursor position
mov AH, 2h ; Set interrupt to set cursor position
int 10h
ret
carriage_return ENDP
; Prints the grid to the screen
print_grid PROC
; Row 1
mov AL, pos[0]
call print_char
mov AL, '|'
call print_char
mov AL, pos[1]
call print_char
mov AL, '|'
call print_char
mov AL, pos[2]
call print_char
call carriage_return
; Row 2
mov AL, '-'
call print_char
mov AL, '+'
call print_char
mov AL, '-'
call print_char
mov AL, '+'
call print_char
mov AL, '-'
call print_char
call carriage_return
; Row 3
mov AL, pos[3]
call print_char
mov AL, '|'
call print_char
mov AL, pos[4]
call print_char
mov AL, '|'
call print_char
mov AL, pos[5]
call print_char
call carriage_return
; Row 4
mov AL, '-'
call print_char
mov AL, '+'
call print_char
mov AL, '-'
call print_char
mov AL, '+'
call print_char
mov AL, '-'
call print_char
call carriage_return
; Row 5
mov AL, pos[6]
call print_char
mov AL, '|'
call print_char
mov AL, pos[7]
call print_char
mov AL, '|'
call print_char
mov AL, pos[8]
call print_char
call carriage_return
ret
print_grid ENDP
end:
ret
pos DB 65, 66, 67, 68, 69, 70, 71, 72, 73
What appears on the virtual screen is this
I know that there are better methods to print characters using emu8086 such as the PRINT/PRINTN macros but I wanted to try doing it manually, so I would appreciate an answer as to why the program is outputting this. Though general tips on improving this code are welcome, if you'd like.