add byte reverse
This commit is contained in:
parent
dce5a43804
commit
5767133ae3
53
utility.h65
53
utility.h65
@ -7,6 +7,34 @@ INCLUDE_UTILITY = 1
|
|||||||
.feature string_escapes
|
.feature string_escapes
|
||||||
.feature underline_in_numbers
|
.feature underline_in_numbers
|
||||||
|
|
||||||
|
.macro DEBUG_LED_OFF nr
|
||||||
|
pha
|
||||||
|
lda IO1 + IO::RA
|
||||||
|
.if nr = 0
|
||||||
|
and #%11111110
|
||||||
|
.elseif nr = 1
|
||||||
|
and #%11111101
|
||||||
|
.else
|
||||||
|
and #%11111011
|
||||||
|
.endif
|
||||||
|
sta IO1 + IO::RA
|
||||||
|
pla
|
||||||
|
.endmacro
|
||||||
|
|
||||||
|
.macro DEBUG_LED_ON nr
|
||||||
|
pha
|
||||||
|
lda IO1 + IO::RA
|
||||||
|
.if nr = 0
|
||||||
|
ora #%00000001
|
||||||
|
.elseif nr = 1
|
||||||
|
ora #%00000010
|
||||||
|
.else
|
||||||
|
ora #%00000100
|
||||||
|
.endif
|
||||||
|
sta IO1 + IO::RA
|
||||||
|
pla
|
||||||
|
.endmacro
|
||||||
|
|
||||||
|
|
||||||
;;********************************************************************************
|
;;********************************************************************************
|
||||||
;; @macro Update a byte in memory using a mask
|
;; @macro Update a byte in memory using a mask
|
||||||
@ -17,6 +45,7 @@ INCLUDE_UTILITY = 1
|
|||||||
;; xor #value with addr -> only bits that need to flip are 1
|
;; xor #value with addr -> only bits that need to flip are 1
|
||||||
;; and result with #mask -> only selected bits that need to flip stay 1
|
;; and result with #mask -> only selected bits that need to flip stay 1
|
||||||
;; xor result with addr -> flips selected bits
|
;; xor result with addr -> flips selected bits
|
||||||
|
;; @TODO optimize when immediate is used
|
||||||
;;********************************************************************************
|
;;********************************************************************************
|
||||||
.macro MaskedWrite addr,value,mask
|
.macro MaskedWrite addr,value,mask
|
||||||
lda value
|
lda value
|
||||||
@ -123,4 +152,26 @@ _n_genlabel .set 0
|
|||||||
.ident(.sprintf("%s", .string(l1))) = .ident(.sprintf("%s_%s", .string(prefix), .string(l1)))
|
.ident(.sprintf("%s", .string(l1))) = .ident(.sprintf("%s_%s", .string(prefix), .string(l1)))
|
||||||
ImportZp prefix,l2,l3,l4,l5,l6,l7,l8
|
ImportZp prefix,l2,l3,l4,l5,l6,l7,l8
|
||||||
.endmacro
|
.endmacro
|
||||||
.endif
|
|
||||||
|
|
||||||
|
.import REVERSE_TABLE
|
||||||
|
;;********************************************************************************
|
||||||
|
;; @macro Reverse a byte
|
||||||
|
;; @param reg: The byte to reverse. May be in X, Y or A
|
||||||
|
;; @returns A: The reversed byte
|
||||||
|
;; @modifies A, X (only when reg = A)
|
||||||
|
;;********************************************************************************
|
||||||
|
.macro Reverse reg
|
||||||
|
.if .match(reg, A)
|
||||||
|
tax
|
||||||
|
lda REVERSE_TABLE,x
|
||||||
|
.elseif .match(reg, x)
|
||||||
|
lda REVERSE_TABLE,x
|
||||||
|
.elseif .match(reg, y)
|
||||||
|
lda REVERSE_TABLE,y
|
||||||
|
.else
|
||||||
|
.fatal ("Reverse macro got invalid argument. This syntax error is intentional to show the line number")
|
||||||
|
.endif
|
||||||
|
.endmacro
|
||||||
|
|
||||||
|
.endif ; guard
|
||||||
|
Loading…
Reference in New Issue
Block a user