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.

[SOLVED] 8051 assembly : acall in another acall. is it possible ?

Status
Not open for further replies.

MamadJun

Junior Member level 2
Joined
Jan 11, 2011
Messages
24
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Belgium
Activity points
1,612
Dear all
I am using 8051 assembly
can i use acall in another acall

like this ?


main:
ACALL text1
.
.
.
LJMP finish
text1:
.
.
.
ACALL text2
.
.
RET

text2:
.
.
.
RET

finish:
END
 

Yes... as long the reserved lastIn/firstOut stack didn't reach its limit. Each ACALL (or LCALL) save 2 bytes for the address that the subroutine should return to it.

I mean that in text2 you can call text3 and in text3 you can call text4. Every call will decrease the free space in the call stack by 2. Every return will increase the free space by 2 bytes.

Please note that this stack also allows saving the value of a register (8-bit) by a PUSH instruction. Every PUSH will decrease the free space by 1 byte. Obviously the POP command will increase it by 1 byte.

Added:
I usually let the stack length be 32 bytes below the RAM top. Without PUSH, 16 nested calls could be made.

IMPORTANT:
Even interrupts are calls. Sometimes while an interrupt is serviced, another higher priority interrupt can start and perhaps another one interrupts the two previous ones... in this case 6 bytes are reserved in the stack for the IRET of these three interrupt subroutines.
 
Last edited:
Have a look on the Stack Pointer. Also remind that. ACALL can be called only inside the 2K memory.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top