Something like this where a bit can set or cleared by BSW (Bit Write in W)
using the Zero or Carry Flags (Default Zero)
None of the instructions used below has an any affect on Z or C.
BSW [base], lock
[base] is the indirect word that will change
lock is the bit position.
_
If Z = 0 it is the equivilent of bset [base], lock
_
If Z = 1 it is the the equivilent of bclr [base], lock
; ----------------------------------------------------
; reserved = w0
x = w1
key = w2
base = w3
lock = w4
pin_unlock:
bset SR, #Z
bra $+4
; - - - - - - - - - - - - - - - - - - -
pin_lock:
bclr SR, #Z
; - - - - - - - - - - - - - - - - - - -
; useful
mov #RPCON, base
mov #IOLOCK, lock
mov #NVMKEY, key
; - - - - - - - - - - - - - - - - - - -
; key
mov #0x55, x
mov.b x, [key]
mov #0xAA, x
mov.b x, [key]
; - - - - - - - - - - - - - - - - - - -
; lock / un-lock
bsw [base], lock
return
; ----------------------------------------------------