Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write an Assembly program that moves the cursor to a random location within a vi

ID: 3681569 • Letter: W

Question

Write an Assembly program that moves the cursor to a random location within a virtually bounded box with 80 columns and 25 rows in the output console. Upon reaching a random location in the virtual box, a symbol should be drawn at that place and a two second delay should be triggered. After the delay, the old character should be removed, a new random location drawn and the process should repeat. This should continue indefinitely until the user hits the ESCAPE key, which will cause you program to exit.

Explanation / Answer

the program below illustrates for setting the position of the cursor

.model small

.586

.stack 100th

.data

row db 12 ;; initially at row 12

col db 40 ;; initially at col 40

.code

extern Clrscr:proc

main proc

mov ax,@data

mov ds,ax

call Clrscr;clear screen

cal sector : set cursor at row/col1

lp1 : mov ah,7

int 21th ; get character with no echo

cmp al,'w'

jne skip1

dec row ;moveup

just domove

skip1: cmp al,'s'

jne row : move down

jmp domove

skip2 : cmp a1,'s'

jne skip2

inc row ; move down

jmp domove

skip 2 : cmp al.'a;'

jne skip3

dec col; move left

jmp domove

skip 3: cmp al , 'd'

jne skip4

inc col ; move right

skip 4 : cmp al,20th;space=exit

je doexit

domove : call setcur ; set cursor at new position

jmp lp1

doexit : Mov ax, 4cooh

int 21th

main endp

setcur proc

mov ah,2 : use Bios 10th to set cursor

mov dh,row ;row position

mov d1,col ; column position

mov bh,0

int 10th

ret

setcur endp

end main

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote