Download presentation
Presentation is loading. Please wait.
1
Subroutine Call; Stack
2
stack Structure of stack Address Data 0005H 0006H SP 0007H 0008H
000BH 000CH 000DH 000EH 000FH stack
3
start: MOV R0,#00H MOV R1,#11H MOV R2,#22H MOV R3,#33H MOV R4,#44H MOV R5,#55H MOV R6,#66H MOV R7,#77H NOP PUSH AR0 PUSH AR1 PUSH AR2 PUSH AR3 PUSH AR4 PUSH AR5 PUSH AR6 PUSH AR7 Before PUSH AR Before PUSH AR Before PUSH AR2 Address Data 0005H 0006H 0007H SP 0008H 00H 0009H ?? 000AH 000BH 000CH 000DH 000EH 000FH Address Data 0005H 0006H SP 0007H 0008H ?? 0009H 000AH 000BH 000CH 000DH 000EH 000FH Address Data 0005H 0006H 0007H 0008H 00H SP 0009H 11H 000AH ?? 000BH 000CH 000DH 000EH 000FH
4
NOP POP 57H POP 56H POP 55H POP 54H POP 53H POP 52H POP 51H POP 50H JMP start Before POP 57H Before POP 56H Before POP 55H Address Data 0005H 0006H 0007H 0008H 00 0009H 11 000AH 22 000BH 33 000CH 44 000DH 55 000EH 66 SP 000FH 77 Address Data 0005H 0006H 0007H 0008H 00 0009H 11 000AH 22 000BH 33 000CH 44 000DH 55 SP 000EH 66 000FH 77 Address Data 0005H 0006H 0007H 0008H 00 0009H 11 000AH 22 000BH 33 000CH 44 SP 000DH 55 000EH 66 000FH 77
5
ACALL LCALL Length of machine code 2 bytes 3 byte
6
Machine code format Target (Subroutine) address = A10A9A8・・・A1A0
Range: 2 K Target address = A15A14A13・・・A1A0 Range: 64 K
7
Note the convention of EdSim51:
CALL is replaced by ACALL . JMP is replaced by either SJMP or AJMP. LCALL and LJMP must be programmed explicitly.
8
Before the LCALL sub instruction has been executed
After the LCALL sub instruction has been executed
9
After the RET instruction has been executed
10
RET
11
ICPs ICP = push & pop - simple.asm ICP = average of 5 numbers.asm
ICP = average of up to 255 numbers.asm ICP = average of up to 255 numbers - with PSW & registers intact.asm
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.