2
I am trying to create a game in Assembly x86 in emu8086 in which the pieces fall and it is necessary a timer of 1 second for each movement of the piece. I tried to implement two ways:
wait_time dw 0
PAUSE proc
semtec:
mov ah, 00h
int 1ah
cmp dx, wait_time
jb ino
add dx, 4
mov wait_time, dx
ret
endp
And I also learned using this one-million-microsecond stretch that is the equivalent of 1 sec:
mov cx, 0fh
mov dx, 4240h
mov ah, 86h
int 15h
However both do not work, the second spoils the game’s home screen (changes the screen position, changes the color,...) and the first makes no difference. Could someone help me? How to create a 1-second interval timer?
The call code 86h BIOS in question is correct and works smoothly in emu8086. Probably, the error is happening elsewhere in the code, before or after calling this timer function. How are you calling this function?
– Gomiero
Hi @Gomiero I tried to do this in two ways, I put this excerpt just above the piece’s descent logic and also tried to create a proc with push’s and pop’s , I was even afraid that maybe the int 15h ah=86h would change some value of the registers, flags and Talz. But it did not work very well, the first descent is normal (fast without interval) and the second the screen breaks and changes color. =(
– MAO
In some tests you could even notice the timer working, but the game screen changes ( it goes down, turns red and the characters are replaced) . If I use this form, does it alter any register type SI, DI,...? Memory positions? What can I do to run the timer and the screen too?
– MAO
I also performed a unit test in the registers with push and pop ( I believe I’m giving this problem because of the register bp) if I push bp and pop bp then the screen freezes. (no longer breaks and does not change color...). Do you have any suggestions? Idea?
– MAO
the call 86h does not change any register or memory in emu8086, and should not change any flag either. Without knowing the rest of the code, you can’t be sure where the bug is. There is a similar question in the English OS where one of the answers suggests setting the register al with value 00h before the call of int 15h: https://stackoverflow.com/questions/34089884/problems-with-bios-delay-function-int-15h-ah-86h
– Gomiero
@Gomiero where can I put the full code? Can you join sopt’s chat?(I posted there in chat) https://chat.stackexchange.com/rooms/11910/estouro-de-pilha
– MAO
I answered there...other people reported the same problem, however, occurring in Dosbox and not in emu8086, and the output was even set the
al
for 00h before the call. If you can put the code somewhere shared (ex: Github), I can try testing here.– Gomiero