ACME_Lib: changed macro parameters to cheap locals (there should be no change in functionality)

git-svn-id: https://svn.code.sf.net/p/acme-crossass/code-0/trunk@102 4df02467-bbd4-4a76-a152-e7ce94205b78
This commit is contained in:
marcobaye 2018-08-05 15:33:15 +00:00
parent 6ff2e95da8
commit b31e6c4e70
6 changed files with 121 additions and 122 deletions

View File

@ -1,4 +1,4 @@
;ACME 0.95 ;ACME 0.96.4
!ifdef lib_6502_std_a !eof !ifdef lib_6502_std_a !eof
lib_6502_std_a = 1 lib_6502_std_a = 1
@ -22,57 +22,57 @@ lib_6502_std_a = 1
} }
; increase 16-bit counter ; increase 16-bit counter
!macro inc16 .t { !macro inc16 @t {
inc .t inc @t
bne + bne +
inc .t + 1 inc @t + 1
+ +
} }
; far branches ; far branches
!macro bcc .t { !macro bcc @t {
bcs + bcs +
jmp .t jmp @t
+ +
} }
!macro bcs .t { !macro bcs @t {
bcc + bcc +
jmp .t jmp @t
+ +
} }
!macro beq .t { !macro beq @t {
bne + bne +
jmp .t jmp @t
+ +
} }
!macro bne .t { !macro bne @t {
beq + beq +
jmp .t jmp @t
+ +
} }
!macro bmi .t { !macro bmi @t {
bpl + bpl +
jmp .t jmp @t
+ +
} }
!macro bpl .t { !macro bpl @t {
bmi + bmi +
jmp .t jmp @t
+ +
} }
!macro bvc .t { !macro bvc @t {
bvs + bvs +
jmp .t jmp @t
+ +
} }
!macro bvs .t { !macro bvs @t {
bvc + bvc +
jmp .t jmp @t
+ +
} }

View File

@ -1,4 +1,4 @@
;ACME 0.96.3 ;ACME 0.96.4
!ifdef lib_65816_std_a !eof !ifdef lib_65816_std_a !eof
lib_65816_std_a = 2 lib_65816_std_a = 2
@ -72,11 +72,11 @@ lib_65816_std_a = 2
+i8 +i8
} }
!macro inc24 .t {; increase 24-bit counter !macro inc24 @t {; increase 24-bit counter
inc .t inc @t
bne + bne +
inc .t + 1 inc @t + 1
bne + bne +
inc .t + 2 inc @t + 2
+ +
} }

View File

@ -19,32 +19,32 @@ lib_cbm_c64_float_a = 2
; convenience macros: ; convenience macros:
; some float functions need a memory address in YYAA ; some float functions need a memory address in YYAA
!macro movYYAA .adr { !macro movYYAA @addr {
lda #<.adr lda #<@addr
ldy #>.adr ldy #>@addr
} }
; ...or in YYXX ; ...or in YYXX
!macro movYYXX .adr { !macro movYYXX @addr {
ldx #<.adr ldx #<@addr
ldy #>.adr ldy #>@addr
} }
; other float functions expect or output a value in AAYY ; other float functions expect or output a value in AAYY
!macro movAAYY .val { !macro movAAYY @val {
ldy #<.val ldy #<@val
lda #>.val lda #>@val
} }
!macro ldAAYY .adr { !macro ldAAYY @addr {
ldy .adr ldy @addr
lda .adr + 1 lda @addr + 1
} }
!macro stAAYY .adr { !macro stAAYY @addr {
sty .adr sty @addr
sta .adr + 1 sta @addr + 1
} }
; ...or in AAXX ; ...or in AAXX
!macro ldAAXX .adr { !macro ldAAXX @addr {
ldx .adr ldx @addr
lda .adr + 1 lda @addr + 1
} }
!address { !address {
@ -118,12 +118,12 @@ lib_cbm_c64_float_a = 2
} }
; wrappers for names from older version of this file: ; wrappers for names from older version of this file:
!macro movAY .adr { +movYYAA .adr } !macro movAY @addr { +movYYAA @addr }
!macro movXY .adr { +movYYXX .adr } !macro movXY @addr { +movYYXX @addr }
!macro movYA .val { +movAAYY .val } !macro movYA @val { +movAAYY @val }
!macro ldYA .adr { +ldAAYY .adr } !macro ldYA @addr { +ldAAYY @addr }
!macro stYA .adr { +stAAYY .adr } !macro stYA @addr { +stAAYY @addr }
!macro ldXA .adr { +ldAAXX .adr } !macro ldXA @addr { +ldAAXX @addr }
fac1_to_signedYA = fac1_to_signedAAYY fac1_to_signedYA = fac1_to_signedAAYY
fac1_read_signedYA = fac1_read_signedAAYY fac1_read_signedYA = fac1_read_signedAAYY
fac1_to_unsignedYA = fac1_to_unsignedAAYY fac1_to_unsignedYA = fac1_to_unsignedAAYY

View File

@ -1,4 +1,4 @@
;ACME 0.95.7 ;ACME 0.96.4
!ifdef lib_cbm_c64_memcopy_a !eof !ifdef lib_cbm_c64_memcopy_a !eof
lib_cbm_c64_memcopy_a = 1 lib_cbm_c64_memcopy_a = 1
@ -11,24 +11,23 @@ lib_cbm_c64_memcopy_a = 1
; higher addresses are copied first, so: ; higher addresses are copied first, so:
; - moving data to higher addresses works even if areas overlap ; - moving data to higher addresses works even if areas overlap
; - moving data to lower addresses only works if areas do not overlap ; - moving data to lower addresses only works if areas do not overlap
!macro basic_memcopy .src_start, .src_end, .target_start { !macro basic_memcopy @src_start, @src_end, @target_start {
!address { !addr @z_target_end = $58
.z_target_end = $58 !addr @z_src_end = $5a
.z_src_end = $5a !addr @z_src_start = $5f
.z_src_start = $5f !addr @fn = $a3bf
.fn = $a3bf
} lda #<@src_start
lda #<.src_start ldx #>@src_start
ldx #>.src_start sta @z_src_start
sta .z_src_start stx @z_src_start + 1
stx .z_src_start + 1 lda #<@src_end
lda #<.src_end ldx #>@src_end
ldx #>.src_end sta @z_src_end
sta .z_src_end stx @z_src_end + 1
stx .z_src_end + 1 lda #<(@target_start + @src_end - @src_start)
lda #<(.target_start + .src_end - .src_start) ldx #>(@target_start + @src_end - @src_start)
ldx #>(.target_start + .src_end - .src_start) sta @z_target_end
sta .z_target_end stx @z_target_end + 1
stx .z_target_end + 1 jsr @fn
jsr .fn
} }

View File

@ -1,4 +1,4 @@
;ACME 0.94.5 ;ACME 0.96.4
!ifdef lib_cbm_flpt_a !eof !ifdef lib_cbm_flpt_a !eof
lib_cbm_flpt_a = 1 lib_cbm_flpt_a = 1
@ -46,48 +46,48 @@ lib_cbm_flpt_a = 1
; this is ugly, but it gets the job done ; this is ugly, but it gets the job done
; (if it's stupid, but it works, then it's not stupid) ; (if it's stupid, but it works, then it's not stupid)
!macro flpt .value { !macro flpt @value {
!set .float = float(.value) ; make sure to do passes until value is defined !set @float = float(@value) ; make sure to do passes until value is defined
!ifndef .float { !ifndef @float {
!by $ff, $ff, $ff, $ff, $ff, $ff ; six place holder bytes !by $ff, $ff, $ff, $ff, $ff, $ff ; six place holder bytes
} else { } else {
; value is defined, so split up into sign and non-negative value ; value is defined, so split up into sign and non-negative value
!if .float < 0 { !if @float < 0 {
!set .sign = $80 !set @sign = $80
!set .float = -.float !set @float = -@float
} else { } else {
!set .sign = $00 !set @sign = $00
} }
!if .float = 0 { !if @float = 0 {
!by 0, 0, 0, 0, 0, 0 ; six zeroes (zero is represented by all bits zero) !by 0, 0, 0, 0, 0, 0 ; six zeroes (zero is represented by all bits zero)
} else { } else {
; split up into exponent and mantissa ; split up into exponent and mantissa
!set .exponent = 128 + 32 ; 128 is cbm's bias, 32 is this algo's bias !set @exponent = 128 + 32 ; 128 is cbm's bias, 32 is this algo's bias
; if mantissa is too large, shift right and adjust exponent ; if mantissa is too large, shift right and adjust exponent
!do while .float >= (2.0 ^ 32.0) { !do while @float >= (2.0 ^ 32.0) {
!set .float = .float >> 1 !set @float = @float >> 1
!set .exponent = .exponent + 1 !set @exponent = @exponent + 1
} }
; if mantissa is too small, shift left and adjust exponent ; if mantissa is too small, shift left and adjust exponent
!do while .float < (2.0 ^ 31.0) { !do while @float < (2.0 ^ 31.0) {
!set .float = .float << 1 !set @float = @float << 1
!set .exponent = .exponent - 1 !set @exponent = @exponent - 1
} }
!if .exponent < 1 { !if @exponent < 1 {
!warn "FLPT underflow, using zero instead" !warn "FLPT underflow, using zero instead"
!set .float = 0 !set @float = 0
!set .exponent = 0 !set @exponent = 0
!set .sign = 0 !set @sign = 0
} }
!if .exponent > 255 { !if @exponent > 255 {
!error "FLPT overflow" !error "FLPT overflow"
} }
!by .exponent !by @exponent
!by 255 & int(.float >> 24) !by 255 & int(@float >> 24)
!by 255 & int(.float >> 16) !by 255 & int(@float >> 16)
!by 255 & int(.float >> 8) !by 255 & int(@float >> 8)
!by 255 & int(.float) !by 255 & int(@float)
!by .sign !by @sign
} }
} }
} }

View File

@ -41,47 +41,47 @@ lib_cbm_mflpt_a = 1
; this is ugly, but it gets the job done ; this is ugly, but it gets the job done
; (if it's stupid, but it works, then it's not stupid) ; (if it's stupid, but it works, then it's not stupid)
!macro mflpt .value { !macro mflpt @value {
!set .float = float(.value) ; make sure to do passes until value is defined !set @float = float(@value) ; make sure to do passes until value is defined
!ifndef .float { !ifndef @float {
!by $ff, $ff, $ff, $ff, $ff ; five place holder bytes !by $ff, $ff, $ff, $ff, $ff ; five place holder bytes
} else { } else {
; value is defined, so split up into sign and non-negative value ; value is defined, so split up into sign and non-negative value
!if .float < 0 { !if @float < 0 {
!set .sign = $80 !set @sign = $80
!set .float = -.float !set @float = -@float
} else { } else {
!set .sign = $00 !set @sign = $00
} }
!if .float = 0 { !if @float = 0 {
!by 0, 0, 0, 0, 0 ; five zeroes (zero is represented by all bits zero) !by 0, 0, 0, 0, 0 ; five zeroes (zero is represented by all bits zero)
} else { } else {
; split up into exponent and mantissa ; split up into exponent and mantissa
!set .exponent = 128 + 32 ; 128 is cbm's bias, 32 is this algo's bias !set @exponent = 128 + 32 ; 128 is cbm's bias, 32 is this algo's bias
; if mantissa is too large, shift right and adjust exponent ; if mantissa is too large, shift right and adjust exponent
!do while .float >= (2.0 ^ 32.0) { !do while @float >= (2.0 ^ 32.0) {
!set .float = .float >> 1 !set @float = @float >> 1
!set .exponent = .exponent + 1 !set @exponent = @exponent + 1
} }
; if mantissa is too small, shift left and adjust exponent ; if mantissa is too small, shift left and adjust exponent
!do while .float < (2.0 ^ 31.0) { !do while @float < (2.0 ^ 31.0) {
!set .float = .float << 1 !set @float = @float << 1
!set .exponent = .exponent - 1 !set @exponent = @exponent - 1
} }
!if .exponent < 1 { !if @exponent < 1 {
!warn "MFLPT underflow, using zero instead" !warn "MFLPT underflow, using zero instead"
!set .float = 0 !set @float = 0
!set .exponent = 0 !set @exponent = 0
!set .sign = 0 !set @sign = 0
} }
!if .exponent > 255 { !if @exponent > 255 {
!error "MFLPT overflow" !error "MFLPT overflow"
} }
!by .exponent !by @exponent
!by (127 & int(.float >> 24)) | .sign !by (127 & int(@float >> 24)) | @sign
!by 255 & int(.float >> 16) !by 255 & int(@float >> 16)
!by 255 & int(.float >> 8) !by 255 & int(@float >> 8)
!by 255 & int(.float) !by 255 & int(@float)
} }
} }
} }