Upload
neeraj
View
216
Download
0
Embed Size (px)
DESCRIPTION
microcontroller
Citation preview
8-bit microcontrollers8-bit microcontrollers
04/21/23 8 bit microcontrollers 2
Jump & Call instructions…
A jump instruction can replace the contents of the program counter with a new program address that causes program execution to begin at code located at new address.
The difference in bytes of this new address from the address in the program where jump or call is located is called Range of jump or call.
They may have one of the three ranges…
Relative range +127d,-128d bytes from the instructions following the jump/call
04/21/23 8 bit microcontrollers 3
CALL Instructions
ACALL: Absolute CallIt calls subroutines with a target address
within 2K bytes from the current program counter (PC). 2 byte instruction.
LCALL: Long CallTo reach the target address in the 64K bytes
maximum ROM space of 8051, we must use LCALL. 3 byte instruction
04/21/23 8 bit microcontrollers 4
Format of CALL instructions
ACALL abs address ACALL label
LCALL 16 bit address LCALL 2050h
04/21/23 8 bit microcontrollers 5
JUMP Instructions
AJMP: Absolute JumpIt transfers program execution to the target
address unconditionally, within 2k bytes of program memory. 2 byte instruction
LJMP: Long jumpIt is used to jump unconditionally to any
address location within 64K bytes of program memory. 3 byte instruction.
04/21/23 8 bit microcontrollers 6
SJMP: Short Jump
Used to jump unconditionally within -128 to +127 bytes of the current program counter (PC) value. 2 byte instruction.
04/21/23 8 bit microcontrollers 7
An absolute range 2K byte page
A long range Any address
A short range relative to PC (-128 to +127)
(0000- FFFF) anywhere in the program memory
Jumps….
Bit jumps:
All bit jumps either operate according to the status of carry flag of PSW or status of any bit addressable location..
All bit jumps are relative to the PC(-128 to +127)
04/21/23 8 bit microcontrollers 8
JC radd 2 Byte Instr.
JNC radd 2 Byte Instr.JZ radd 2 Byte InstrJNZ radd 2 Byte Instr
JB b, radd 3 Byte Instr.
JNB b, radd 3 Byte Instr.
JBC b, radd 3 Byte Instr.
jump relative if add bit is set and clear the bit to 0.
radd: Relative Address within Program Code
04/21/23 8 bit microcontrollers 9
Byte jumps…CJNE dest. byte, source byte, addrs. 3 Byte Instr
Compare the contents of A with direct address if not equal then jump to relative address
CJNE A, #n, radd 3 Byte Instr
CJNE Rn, #n, radd 3 Byte Instr
CJNE @Rp, #n, radd 3 Byte Instr
DJNZ Rn, radd 3 Byte Instr
The CJNE instruction affects the CY flag only.
Dest. < Source; CY=1
Dest. > Source; CY=0
04/21/23 8 bit microcontrollers 10
Unconditional jumps…
JMP @A+DPTR 1 Byte Instr
AJMP sadd 2 Byte Instr
LJMP ladd 3 Byte Instr
SJMP radd 2 Byte Instr
04/21/23 8 bit microcontrollers 11
Calculation of short jump addressOrg 0000hJz nextInc r0
Again: inc a inc a
Next: mov a,#34hjnc overclr amov r0,amov r1,amov r2,amov r3,a
Over: mov r4,#45hjnc againend