mirror of
https://github.com/irmen/prog8.git
synced 2025-02-04 02:30:19 +00:00
reg_x removal: math.asm and some others
This commit is contained in:
parent
9938959026
commit
ea8b7ab193
@ -3,6 +3,8 @@
|
||||
FL_ONE_const .byte 129 ; 1.0
|
||||
FL_ZERO_const .byte 0,0,0,0,0 ; 0.0
|
||||
|
||||
floats_store_reg .byte 0 ; temp storage
|
||||
|
||||
|
||||
ub2float .proc
|
||||
; -- convert ubyte in SCRATCH_ZPB1 to float at address A/Y
|
||||
|
@ -194,7 +194,7 @@ asmsub GETADRAY () clobbers(X) -> uword @ AY {
|
||||
sub print_f (float value) {
|
||||
; ---- prints the floating point value (without a newline).
|
||||
%asm {{
|
||||
stx P8ZP_SCRATCH_REG_X
|
||||
stx floats_store_reg
|
||||
lda #<value
|
||||
ldy #>value
|
||||
jsr MOVFM ; load float into fac1
|
||||
@ -207,7 +207,7 @@ sub print_f (float value) {
|
||||
jsr c64.CHROUT
|
||||
iny
|
||||
bne -
|
||||
ldx P8ZP_SCRATCH_REG_X
|
||||
ldx floats_store_reg
|
||||
+ rts
|
||||
}}
|
||||
}
|
||||
|
@ -299,8 +299,8 @@ _irq_handler_init
|
||||
sta IRQ_SCRATCH_ZPB1
|
||||
lda P8ZP_SCRATCH_REG
|
||||
sta IRQ_SCRATCH_ZPREG
|
||||
lda P8ZP_SCRATCH_REG_X
|
||||
sta IRQ_SCRATCH_ZPREGX
|
||||
lda P8ZP_SCRATCH_REG_X ; TODO remove REG_X
|
||||
sta IRQ_SCRATCH_ZPREGX ; TODO remove this storage byte
|
||||
lda P8ZP_SCRATCH_W1
|
||||
sta IRQ_SCRATCH_ZPWORD1
|
||||
lda P8ZP_SCRATCH_W1+1
|
||||
@ -325,8 +325,8 @@ _irq_handler_end
|
||||
sta P8ZP_SCRATCH_B1
|
||||
lda IRQ_SCRATCH_ZPREG
|
||||
sta P8ZP_SCRATCH_REG
|
||||
lda IRQ_SCRATCH_ZPREGX
|
||||
sta P8ZP_SCRATCH_REG_X
|
||||
lda IRQ_SCRATCH_ZPREGX ; TODO remove this storage location
|
||||
sta P8ZP_SCRATCH_REG_X ; TODO remove _REG_X
|
||||
lda IRQ_SCRATCH_ZPWORD1
|
||||
sta P8ZP_SCRATCH_W1
|
||||
lda IRQ_SCRATCH_ZPWORD1+1
|
||||
|
@ -213,7 +213,7 @@ asmsub byte2decimal (byte value @ A) -> ubyte @ Y, ubyte @ A, ubyte @ X {
|
||||
asmsub ubyte2hex (ubyte value @ A) -> ubyte @ A, ubyte @ Y {
|
||||
; ---- A to hex petscii string in AY (first hex char in A, second hex char in Y)
|
||||
%asm {{
|
||||
stx P8ZP_SCRATCH_REG_X
|
||||
stx P8ZP_SCRATCH_REG
|
||||
pha
|
||||
and #$0f
|
||||
tax
|
||||
@ -225,7 +225,7 @@ asmsub ubyte2hex (ubyte value @ A) -> ubyte @ A, ubyte @ Y {
|
||||
lsr a
|
||||
tax
|
||||
lda _hex_digits,x
|
||||
ldx P8ZP_SCRATCH_REG_X
|
||||
ldx P8ZP_SCRATCH_REG
|
||||
rts
|
||||
|
||||
_hex_digits .text "0123456789abcdef" ; can probably be reused for other stuff as well
|
||||
|
@ -130,7 +130,7 @@ asmsub GETADRAY () clobbers(X) -> uword @ AY {
|
||||
sub print_f (float value) {
|
||||
; ---- prints the floating point value (without a newline).
|
||||
%asm {{
|
||||
stx P8ZP_SCRATCH_REG_X
|
||||
phx
|
||||
lda #<value
|
||||
ldy #>value
|
||||
jsr MOVFM ; load float into fac1
|
||||
@ -143,7 +143,7 @@ sub print_f (float value) {
|
||||
jsr c64.CHROUT
|
||||
iny
|
||||
bne -
|
||||
ldx P8ZP_SCRATCH_REG_X
|
||||
plx
|
||||
+ rts
|
||||
}}
|
||||
}
|
||||
|
@ -11,6 +11,10 @@
|
||||
; http://codebase64.org/doku.php?id=base:6502_6510_maths
|
||||
;
|
||||
|
||||
|
||||
math_store_reg .byte 0 ; temporary storage
|
||||
|
||||
|
||||
multiply_bytes .proc
|
||||
; -- multiply 2 bytes A and Y, result as byte in A (signed or unsigned)
|
||||
sta P8ZP_SCRATCH_B1 ; num1
|
||||
@ -31,7 +35,7 @@ multiply_bytes_16 .proc
|
||||
; -- multiply 2 bytes A and Y, result as word in A/Y (unsigned)
|
||||
sta P8ZP_SCRATCH_B1
|
||||
sty P8ZP_SCRATCH_REG
|
||||
stx P8ZP_SCRATCH_REG_X
|
||||
stx math_store_reg
|
||||
lda #0
|
||||
ldx #8
|
||||
lsr P8ZP_SCRATCH_B1
|
||||
@ -44,7 +48,7 @@ multiply_bytes_16 .proc
|
||||
bne -
|
||||
tay
|
||||
lda P8ZP_SCRATCH_B1
|
||||
ldx P8ZP_SCRATCH_REG_X
|
||||
ldx math_store_reg
|
||||
rts
|
||||
.pend
|
||||
|
||||
@ -57,7 +61,7 @@ multiply_words .proc
|
||||
|
||||
sta P8ZP_SCRATCH_W2
|
||||
sty P8ZP_SCRATCH_W2+1
|
||||
stx P8ZP_SCRATCH_REG_X
|
||||
stx P8ZP_SCRATCH_REG
|
||||
|
||||
mult16 lda #0
|
||||
sta result+2 ; clear upper bits of product
|
||||
@ -79,7 +83,7 @@ mult16 lda #0
|
||||
ror result
|
||||
dex
|
||||
bne -
|
||||
ldx P8ZP_SCRATCH_REG_X
|
||||
ldx P8ZP_SCRATCH_REG
|
||||
rts
|
||||
|
||||
result .byte 0,0,0,0
|
||||
@ -124,7 +128,7 @@ divmod_ub_asm .proc
|
||||
; division by zero will result in quotient = 255 and remainder = original number
|
||||
sty P8ZP_SCRATCH_REG
|
||||
sta P8ZP_SCRATCH_B1
|
||||
stx P8ZP_SCRATCH_REG_X
|
||||
stx math_store_reg
|
||||
|
||||
lda #0
|
||||
ldx #8
|
||||
@ -137,7 +141,7 @@ divmod_ub_asm .proc
|
||||
dex
|
||||
bne -
|
||||
ldy P8ZP_SCRATCH_B1
|
||||
ldx P8ZP_SCRATCH_REG_X
|
||||
ldx math_store_reg
|
||||
rts
|
||||
.pend
|
||||
|
||||
@ -197,7 +201,7 @@ result = dividend ;save memory by reusing divident to store the result
|
||||
|
||||
sta _divisor
|
||||
sty _divisor+1
|
||||
stx P8ZP_SCRATCH_REG_X
|
||||
stx P8ZP_SCRATCH_REG
|
||||
lda #0 ;preset remainder to 0
|
||||
sta remainder
|
||||
sta remainder+1
|
||||
@ -224,7 +228,7 @@ result = dividend ;save memory by reusing divident to store the result
|
||||
|
||||
lda result
|
||||
ldy result+1
|
||||
ldx P8ZP_SCRATCH_REG_X
|
||||
ldx P8ZP_SCRATCH_REG
|
||||
rts
|
||||
_divisor .word 0
|
||||
.pend
|
||||
|
@ -3,6 +3,9 @@
|
||||
%import cx16flt
|
||||
%zeropage basicsafe
|
||||
|
||||
; TODO fix this, only black squares output...
|
||||
|
||||
|
||||
main {
|
||||
const uword width = 60
|
||||
const uword height = 50
|
||||
|
Loading…
x
Reference in New Issue
Block a user