Department of Computer Science and Information EngineeringNational Cheng Kung University, TAIWANCALL HANEL
INSTRUCTIONSUse PUSH/POP in Subroutine01 0000
ORG 0
02 0000 7455 BACK: MOVA,#55H ;load A with 55H03 0002 F590 MOVP1,A ;send 55H to p104 0004 7C99MOV R4,#99H05 0006 7D67MOV R5,#67H06 0008 120300LCALL DELAY ;time delay07 000B 74AAMOV A,#0AAH ;load A with AA08 000D F590 MOVP1,A ;send AAH to p109 000F 120300 LCALL DELAY10 0012 80ECSJMP BACK ;keeping doingthis11 0014 ;-------this is thedelay subroutine------12 0300ORG 300H13 0300 C004 DELAY: PUSH 4 ;push R414 0302 C005PUSH 5 ;push R515 0304 7CFFMOV R4,#0FFH;R4=FFH16 0306 7DFF NEXT:MOV R5,#0FFH;R5=FFH17 0308 DDFE AGAIN: DJNZ R5,AGAIN18 030A DCFA DJNZ R4,NEXT19 030C D005 POP5 ;POP into R520 030E D004 POP4 ;POP into R421 0310 22 RET;return to caller22 0311 END;end of asm fileNormally, the number ofPUSH
and POPinstructions must always match in any called subroutinePCL
0B
08
PCL
0B
08
PCL
0B
08PCH
00
09
PCH
00
09
PCH
00
09R4
99
0A
R4
99
0A0AR5
67
0B0B0BAfter PUSH 5After PUSH 4After first LCALL