Chapter 5
Procedures
Assembly Language Programming Exercise
Problem # 7:
Write a program that displays a single character at 100 random screen locations, using a timing delay of 100 milliseconds. Hint: Use the GetMaxXY procedure to determine the current size of the console window.
Solution:
INCLUDE Irvine32.inc
.data
rows WORD ?
cols WORD ?
.code
main PROC
call Clrscr
mov ecx, 100
L1:
call GetMaxXY
mov rows, ax
mov cols, dx
movzx eax, rows
call RandomRange
mov dh, al
movzx eax, cols
call RandomRange
mov dl, al
call Gotoxy ; locate cursor
mov al,'H'
call WriteChar
mov eax,100
call Delay
Loop L1
call WaitMsg
exit
main ENDP
END main
.data
rows WORD ?
cols WORD ?
.code
main PROC
call Clrscr
mov ecx, 100
L1:
call GetMaxXY
mov rows, ax
mov cols, dx
movzx eax, rows
call RandomRange
mov dh, al
movzx eax, cols
call RandomRange
mov dl, al
call Gotoxy ; locate cursor
mov al,'H'
call WriteChar
mov eax,100
call Delay
Loop L1
call WaitMsg
exit
main ENDP
END main
Let me know in the comment section if you have any question.
Previous Post:
Program to Random Strings in Assembly Language using Visual Studio