Task

Show how to return more than one value from a function.




UnpackNibbles:
; Takes accumulator as input. 
; Separates a two-digit hex number into its component "nibbles." Left nibble in X, right nibble in Y.
 
pha          ;backup the input.
and #$0F     ;chop off the left nibble. What remains is our Y.
tay
pla          ;restore input
and #$F0     ;chop off the right nibble. What remains is our X, but it needs to be bit shifted into the right nibble.
lsr
lsr
lsr
lsr
tax          ;store in X
rts