Reputation: 127
Fairly new to assembly and emu8086 and I'm trying to get an ASCII character (an asterisk*) to move across the screen in different directions starting from a certain point.
I can get the asterisk to go right (see code snippet), but how would I make it go left? Up, down?
mov ah,downCol ; set cursor position
mov bh,downRow
mov dl, downCol ; change column
mov dh, downRow ; change row
mov cx, 20
loop1:
mov ah, 2
mov dl, 2ah ;*
int 21h
;mov dl, 20h ;space
;int 21h
;mov dl, 08h
;int 21h
loop loop1
Also, I've been looking at trying to remove the * shortly after it's outputted so it looks like it's moving, but as you can see from the commented section, it's not working. What should I be doing?
Upvotes: 1
Views: 1563
Reputation: 9899
Also, I've been looking at trying to remove the * shortly after it's outputted so it looks like it's moving, but as you can see from the commented section, it's not working.
;mov dl, 20h ;space ;int 21h ;mov dl, 08h ;int 21h
This was close to success if you had first output the backspace (8) then followed by the space (32).
mov dl, 08h
int 21h
mov dl, 20h ;space
int 21h
I'm trying to get an ASCII character (an asterisk*) to move across the screen in different directions starting from a certain point.
A program that does those things follows these steps:
This example moves back an forth from the left to the right:
Top:
mov dh, Row
mov dl, Column
mov bh, 0
mov ah, 02h ;SetCursor
int 10h
mov cx, 1
mov bh, 0
mov al, "*"
mov ah, 0Ah ;DrawCharacter
int 10h
mov dx, 0 ;Approximately 1/8 second
mov cx, 2
mov ah, 86h ;Delay
int 15h
mov cx, 1
mov bh, 0
mov al, " "
mov ah, 0Ah ;DrawCharacter
int 10h
mov al, Sense ;Is +1 to go right, is -1 to go left
test al, al
js GoLeft
GoRight:
inc Column
cmp Column, 80
jb Top
mov Column, 78
neg Sense
jmp Top
GoLeft:
dec Column
jns Top
mov Column, 1
neg Sense
jmp Top
Column db 20
Row db 12
Sense db -1
This should give you an idea on how to solve the problem.
Upvotes: 1