Maxim-integrated MAXQ622 Bedienungsanleitung Seite 49

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 255
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 48
MAXQ612/MAXQ622 Users Guide
Maxim Integrated 3-13
3.7.3 Conditional Jumps
Conditional jumps transfer program execution based on the value of one of the status flags (C, E, Z, S). Except where
noted for JUMP E and JUMP NE, the absolute and relative operands allowed are the same as for the unconditional
JUMP command.
jump c, Label1 ; jump to Label1 if Carry is set
jump nc, LongJump ; jump to LongJump if Carry is not set
jump z, LC[0] ; jump to 16-bit register destination if
; Zero is set
jump nz, Label1 ; jump to Label1 if Zero is not set (Acc<>0)
jump s, A[2] ; jump to A[2] if Sign flag is set
jump e, Label1 ; jump to Label1 if Equal is set
jump ne, Label1 ; jump to Label1 if Equal is cleared
JUMP E and JUMP NE can only use immediate destinations.
3.7.4 Calling Subroutines
The CALL instruction works the same as the unconditional JUMP, except that the next execution address is pushed on
the stack before the jump is made. The RET instruction is used to return from a normal call, and RETI is used to return
from an interrupt handler routine.
call Label1 ; if Label1 is relative,
; assembles to: call #immediate
call LongCall ; assembles to: move PFX[0], #high(LongCall)
; call #low(LongCall)
call LC[0] ; call to address in LC[0]
LongCall:
ret ; return from subroutine
3.7.5 Loop Operations
Looping over a section of code can, of course, be performed by using the conditional jump instructions. However,
there is built-in functionality in the form of the “DJNZ LC[n], src” instruction to support faster, more compact looping
code with separate loop counters. The 16-bit registers LC[0] and LC[1] are used to store these loop counts. The “DJNZ
LC[n], src” instruction automatically decrements the associated loop counter register and jumps to the loop address
specified by src if the loop counter has not reached 0.
To initialize a loop, set the LC[n] register to the desired count before entering the loop’s main body.
The desired loop address should be supplied in the src operand of the “DJNZ LC[n], src” instruction. When the sup-
plied loop address is relative (+127/-128 words) to the DJNZ LC[n] instruction, as is typically the case, the assembler
automatically calculates the relative offset and inserts this immediate value in the object code.
move LC[1], #10h ; loop 16 times
LoopTop: ; loop addr relative to djnz LC[n],src
call LoopSub
djnz LC[1], LoopTop ; decrement LC[1] and jump if nonzero
Seitenansicht 48
1 2 ... 44 45 46 47 48 49 50 51 52 53 54 ... 254 255

Kommentare zu diesen Handbüchern

Keine Kommentare