Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Help understanding assembly calls and labels

Status
Not open for further replies.

journeyman200

Newbie level 3
Joined
Nov 12, 2011
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,305
Code:
WaitHalfSec:

     Mov R2, #30
L3: Mov r1, #250
L2: Mov R0, #250
L1: djnz Ro, L1;
     djnz R1, L2;
     djnz R2, L3;
     ret

When I first call WaitHalfSec do the lines in labels L3, L2, L1 also get read? When "djnz, R2" calls L3 do all lines below L3, including L2 and L1, get read again or does it only read L3 and return? Because if it does, it seems like it'd be an infinite loop? Any help is appreciated.
 

Code:
WaitHalfSec:

     Mov R2, #30
L3: Mov r1, #250
L2: Mov R0, #250
L1: djnz Ro, L1;
     djnz R1, L2;
     djnz R2, L3;
     ret

When I first call WaitHalfSec do the lines in labels L3, L2, L1 also get read? When "djnz, R2" calls L3 do all lines below L3, including L2 and L1, get read again or does it only read L3 and return? Because if it does, it seems like it'd be an infinite loop? Any help is appreciated.

No problem with infinite loop ..
The program is executed as follows:
R2 is loaded with #30
R1 is loaded with #250
and
R0 is loaded with #250
Next within loop L1 R0 is decreased 250 times ..
Then the program looks at loop L2 and executes it 250 times with loop L1 being executed as described above ..
Then it looks at loop L3 and executes it 30 times executing internal loops L2 (250 times) and within it loop L1 (250 times) ..
After L3 loop is completed the program exits/returns ..

:wink:
IanP
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top