Jump to content


Photo

80x86 Assembly Programming Gurus


  • Please log in to reply
3 replies to this topic

#1 mazir

mazir

    X-S Enthusiast

  • Members
  • 24 posts

Posted 21 May 2003 - 10:16 PM

I've been cracking my head for 6 hours unable to figure this out. Does anyone know why the following procedure would go into an endless loop? Assume startDisplay is defined outside the procedure and all compiles.


PROC WAIT_1 FAR
pusha
push es
mov dx, [word 40H:006EH]
mov [startDisplay], dx

continue:
mov dx, [word 40H:006EH]
sub dx, [startDisplay]
cmp dx, 12H
je return
jmp continue

return:
pop es
popa
ret 4
ENDP WAIT_1


Any help would be much appreciated. I feel like I'm going crazy here.

Thanks in advance.


#2 rjm2k

rjm2k

    X-S Freak

  • Members
  • PipPipPipPipPip
  • 1,120 posts

Posted 21 May 2003 - 10:44 PM

It's been a long time since I had to do any assembler, so I might be on the wrong track here, but as far as I can remember:-

PROC WAIT_1 FAR
pusha
push es
mov dx, [word 40H:006EH] 'Move the word at this address into DX
mov [startDisplay], dx 'Move the contents of DX into the address startDisplay

continue:
mov dx, [word 40H:006EH] 'Move the word at this address into DX (nb, DX now = startDisplay
sub dx, [startDisplay] 'submit startDisplay from DX, which should give 0
cmp dx, 12H 'compare dx with 12h
je return 'if dx = 12 (which it can't because it's 0) goto return
jmp continue 'go back to continue, which performs EXACTLY the same steps again with the same outcome

return:
pop es
popa
ret 4
ENDP WAIT_1

Edited by rjm2k, 21 May 2003 - 10:44 PM.


#3 mazir

mazir

    X-S Enthusiast

  • Members
  • 24 posts

Posted 21 May 2003 - 11:05 PM

Maybe I should add that the address 40H:006EH gets one added to it ever 1/18.2 seconds. It's the real time clock interrupt.

Sorry I didn't mention this earlier. Thanks for the reply.

#4 rjm2k

rjm2k

    X-S Freak

  • Members
  • PipPipPipPipPip
  • 1,120 posts

Posted 22 May 2003 - 07:17 AM

QUOTE (mazir @ May 22 2003, 12:05 AM)
Maybe I should add that the address 40H:006EH gets one added to it ever 1/18.2 seconds. It's the real time clock interrupt.

Sorry I didn't mention this earlier. Thanks for the reply.

Maybe it's a timing issue, it could be skipping 12. Try using jump greater if there is one.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users