INCLUDE emu8086.inc
MACROS - code is expaned in every call
======
# PUTC char - macro with 1 parameter, prints out an ASCII char at
current cursor position.
Ex: Print a "1"
1. PUTC "1"
2. PUTC 31h
3. PUTC 49
4. PUTC 00110001b
5. mov al, "1"
PUTC al
6. mov c, 31h
PUTC c
# GOTOXY col, row - macro with 2 parameters, sets cursor position.
Ex: Put cursor at row 3, column 9
1. GOTOXY 3, 9
2. mov dl, 3
mov dh, 9
GOTOXY dl, dh
3. mov row, 3
mov col, 9
GOTOXY row, col
# PRINT string - macro with 1 parameter, prints out a string.
PRINT "Hello World"
PRINT ""
# PRINTN string - macro with 1 parameter, prints out a string. The same
as PRINT but automatically adds "carriage return" at end of the string.
PRINTN "Hello World"
PRINTN ""
# CURSOROFF - turns off the text cursor.
# CURSORON - turns on the text cursor.
PROCEDURES - used with CALL - expanded ONCE
==========
# PRINT_STRING - procedure to print a null terminated string at current
cursor position, receives address of string in DS:SI register. To use
it declare: DEFINE_PRINT_STRING before END directive.
Ex:
lea SI, str ; load address of string into SI register
call PRINT_STRING ; call to print it
RET
str DB "This is a null-terminated string",0
DEFINE_PRINT_STRING
END
# PTHIS - procedure to print a null terminated string at current cursor
position (just as PRINT_STRING), but receives address of string from
Stack. The ZERO TERMINATED string should be defined just after the
CALL instruction. For example:
CALL PTHIS
db 'Hello World!', 0
To use it declare: DEFINE_PTHIS before END directive.
# GET_STRING - procedure to get a null terminated string from a user,
the received string is written to buffer at DS:DI, buffer size should
be in DX. Procedure stops the input when 'Enter' is pressed. To use
it declare: DEFINE_GET_STRING before END directive.
Ex:
lea DI, in ; set address of buffer
mov DX, 80 ; set buffer size
call GET_STRING
RET
in DB 80 DUP [0] ; "DUP" means dupl;icate 80 bytes of zero
DEFINE_GET_STRING
END
# CLEAR_SCREEN - procedure to clear the screen, (done by scrolling entire
screen window), and set cursor position to top of it. To use it
declare: DEFINE_CLEAR_SCREEN before END directive.
# SCAN_NUM - procedure that gets the multi-digit SIGNED number from the
keyboard, and stores the result in CX register. To use it
declare: DEFINE_SCAN_NUM before END directive.
# PRINT_NUM - procedure that prints a signed number in AX register. To use
it declare: DEFINE_PRINT_NUM and DEFINE_PRINT_NUM_UNS before END directive.
mov AX, 0FFFFh
call PRINT_NUM_UNS ; prints 65535
# PRINT_NUM_UNS - procedure that prints out an unsigned number in AX register.
To use it declare: DEFINE_PRINT_NUM_UNS before END directive.
mov AX, 0FFFFh
call PRINT_NUM ; prints -1