14 HANEL
CALL
INSTRUCTIONS
Use PUSH/POP
in Subroutine
01 0000 ORG 0
02 0000 7455 BACK: MOV A,#55H ;load A with 55H
03 0002 F590 MOV P1,A ;send 55H to p1
04 0004 7C99 MOV R4,#99H
05 0006 7D67 MOV R5,#67H
06 0008 120300 LCALL DELAY ;time delay
07 000B 74AA MOV A,#0AAH ;load A with AA
08 000D F590 MOV P1,A ;send AAH to p1
09 000F 120300 LCALL DELAY
10 0012 80EC SJMP BACK ;keeping doing
this
11 0014 ;-------this is the delay subroutine------
12 0300 ORG 300H
13 0300 C004 DELAY: PUSH 4 ;push R4
14 0302 C005 PUSH 5 ;push R5
15 0304 7CFF MOV R4,#0FFH;R4=FFH
16 0306 7DFF NEXT: MOV R5,#0FFH;R5=FFH
17 0308 DDFE AGAIN: DJNZ R5,AGAIN
18 030A DCFA DJNZ R4,NEXT
19 030C D005 POP 5 ;POP into R5
20 030E D004 POP 4 ;POP into R4
21 0310 22 RET ;return to caller
22 0311 END ;end of asm file
Normally, the
number of PUSH
and POP
instructions must
always match in any
called subroutine
08 0B PCL 08 0B PCL 08 0B PCL
09 00 PCH 09 00 PCH 09 00 PCH
0A 0A 99 R4 0A 99 R4
0B 0B 0B 67 R5
After

Post a Comment

0 Comments

Close Menu