beautypg.com

3 conditional jumps, 4 calling subroutines, 3conditionaljumps – Maxim Integrated MAX31782 User Manual

Page 177: 4callingsubroutines

background image

MaximIntegrated 19-12

MAX31782 User’s Guide

Revision 0; 8/11

19.7.3ConditionalJumps

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 may only use immediate destinations .

19.7.4CallingSubroutines

The CALL instruction works the same as the unconditional JUMP, except that the next execution address is pushed
on the stack before transferring program execution to the branch address . 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