Atmel C51 Handbuch Seite 15

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 116
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 14
The 8051 Instruction Set
1-13 Atmel 8051 Microcontrollers Hardware Manual
4316E–8051–01/07
The RLA instruction converts the index number (0 through 4) to an even number on the
range 0 through 8, because each entry in the jump table is 2 bytes long:
JUMP_TABLE:
AJMP CASE_0
AJMP CASE_1
AJMP CASE_2
AJMP CASE_3
AJMP CASE_4
Table 1-11 shows a single “CALL addr” instruction, but there are two of them -LCALL
and ACALL -which differ in the format in which the subroutine address is given to the
CPU. CALL is a generic mnemonic which can be used if the programmer does not care
which way the address is encoded.
The LCALL instruction uses the 16-bit address format, and the subroutine can be any-
where in the 64K Program Memory space. The ACALL instruction uses the 11-bit format,
and the subroutine must be in the same 2K block as the instruction following the ACALL.
In any case the programmer specifies the subroutine address to the assembler in the
same way: as a label or as a 16-bit constant. The assembler will put the address into the
correct format for the given instructions.
Subroutines should end a RET instruction, which returns execution following the CALL.
RETI is used to return from an interrupt service routine. The only difference between RET
and RETI is that RETI tells the interrupt control system that the interrupt in progress is
done. If there is no interrupt in progress at the time RETI is executed, then the RETI is
functionally identical to RET.
Table 1-12 shows the list of conditional jumps available to the Atmel 8051 user. All of
these jumps specify the destination address by the relative offset method, and so are
limited to a jump distance of -128 to + 127 bytes from the instruction following the condi-
tional jump instruction. Important to note, however, the user specifies to the assembler
the actual destination address the same way as the other jumps: as a label or a 16-bit
constant.
There is no Zero bit in the PSW. The JZ and JNZ instructions test the Accumulator data
for that condition.
The DJNZ instruction (Decrement and Jump if Not Zero) is for loop control. To execute a
loop N times, load a counter byte with N and terminate the loop with DJNZ to the beginning
of the loop, as shown below for N = 10:
MOV COUNTER, # 10
LOOP:(begin loop)
*
*
Table 1-12. Conditional Jumps in Atmel 8051 Devices
Mnemonic Operation Addressing Modes
Execution Time
@ 12MHz (µs)
DIR IND REG IMM
JZ rel Jump if A = 0 Accumulator only 2
JNZ rel Jump if A 0 Accumulator only 2
DJNZ <byte>,rel
Decrement and jump if
not zero
X X 2
CJNZ A,<byte>,rel Jump if A = <byte> X X 2
CJNE <byte>,#data,rel Jump if <byte> = #data X X 2
Seitenansicht 14
1 2 ... 10 11 12 13 14 15 16 17 18 19 20 ... 115 116

Kommentare zu diesen Handbüchern

Keine Kommentare