I'm using keil uvision 4 and learning programming for AT89s52 , I'm using 12MHZ frequency.
I had written a subroutine for a delay of 10 micro sec which is in another file called DELAY.ASM and made a call from DELAYCALL.ASM to it, but the call results in an infinite loop.
I just dont have a clue why this behaviour, please help?clarify this phenomenon
I tried simulation,found that statement
END
is never reached
ACALL DELAY10MICROSEC
calls itself again and again ,that happens ,and i can find that.but the code was not intended to do that
DELAYCALL.ASM $INCLUDE(DELAY.ASM) CSEG AT 0 ACALL DELAY10MICROSEC END DELAY.ASM DELAYS_A SEGMENT CODE RSEG DELAYS_A DELAY10MICROSEC: NOP NOP NOP NOP NOP NOP NOP NOP RET
$INCLUDE(DELAY.ASM)
Include any source file is not a good habit.
As I can see, your program doesn't contain the main loop which normally included in MAIN. So your first segment is
CSEG AT 0 ACALL DELAY10MICROSEC
There's no infinite loop to process. After ACALL your program is exhausted, and the uC doesn't know what to do next. He is only fetching and executing 0x00 or 0xFF like a scared lamb... By the end of accessing boundary the PC finally returned to 0 (or a reset caused by fetching error)and the uC finally find her way again --- once again.
Thanks for the clarification Ejack zhang
"After ACALL your program is exhausted, and the uC doesn't know what to do next. He is only fetching and executing 0x00 or 0xFF like a scared lamb... By the end of accessing boundary the PC finally returned to 0 (or a reset caused by fetching error)and the uC finally find her way again --- once again"
@raghav: You should have been able to see this happening in the simulator!
you said you'd run this in the simulator: http://www.keil.com/forum/22210/
One thing with simulators - who ever continues to run their simulator after having seen what they expected to see? Continuing further would just feel boring...