mirror of
https://github.com/irmen/prog8.git
synced 2024-12-22 03:29:41 +00:00
floats: added AYINT2 as a safe wrapper for AYINT. Internal float to word cast now also uses that.
This commit is contained in:
parent
b88f550c5b
commit
688dce6145
6
.gitignore
vendored
6
.gitignore
vendored
@ -1,9 +1,12 @@
|
||||
.idea/workspace.xml
|
||||
.idea/discord.xml
|
||||
.idea/developer-tools.xml
|
||||
.idea/usage.statistics.xml
|
||||
.idea/shelf/
|
||||
build/
|
||||
dist/
|
||||
output/
|
||||
out/
|
||||
.*cache/
|
||||
*.directory
|
||||
*.prg
|
||||
@ -12,7 +15,6 @@ output/
|
||||
*.vm.txt
|
||||
*.vice-mon-list
|
||||
docs/build
|
||||
out/
|
||||
parser/**/*.interp
|
||||
parser/**/*.tokens
|
||||
parser/**/*.java
|
||||
@ -23,6 +25,7 @@ compiler/src/prog8/buildversion/*
|
||||
.eggs/
|
||||
/MANIFEST
|
||||
.tox/
|
||||
.kotlin/
|
||||
__pycache__/
|
||||
parser.out
|
||||
parsetab.py
|
||||
@ -31,7 +34,6 @@ parsetab.py
|
||||
compiler/lib/
|
||||
|
||||
.gradle
|
||||
/prog8compiler.jar
|
||||
sd*.img
|
||||
*.d64
|
||||
|
||||
|
@ -120,12 +120,8 @@ cast_FAC1_as_uw_into_ya .proc ; also used for float 2 ub
|
||||
.pend
|
||||
|
||||
cast_FAC1_as_w_into_ay .proc ; also used for float 2 b
|
||||
; -- cast fac1 to word into A/Y
|
||||
; clobbers X
|
||||
jsr AYINT
|
||||
ldy floats.AYINT_facmo
|
||||
lda floats.AYINT_facmo+1
|
||||
rts
|
||||
; -- cast fac1 to word into A/Y. clobbers X
|
||||
jmp AYINT2
|
||||
.pend
|
||||
|
||||
|
||||
|
@ -29,7 +29,7 @@ extsub $bbd4 = MOVMF(uword mflpt @ XY) clobbers(A,Y) ; store fac1 to memo
|
||||
extsub $b7f7 = GETADR() clobbers(X) -> ubyte @ Y, ubyte @ A
|
||||
|
||||
extsub $bc9b = QINT() clobbers(A,X,Y) ; fac1 -> 4-byte signed integer in 98-101 ($62-$65), with the MSB FIRST.
|
||||
extsub $b1bf = AYINT() clobbers(A,X,Y) ; fac1-> signed word in 100-101 ($64-$65) MSB FIRST. (might throw ILLEGAL QUANTITY)
|
||||
extsub $b1bf = AYINT() clobbers(A,X,Y) ; fac1-> signed word in 100-101 ($64-$65) MSB FIRST. (might throw ILLEGAL QUANTITY) DON'T USE THIS, USE WRAPPER 'AYINT2' INSTEAD.
|
||||
|
||||
; GIVAYF: signed word in Y/A (note different lsb/msb order) -> float in fac1
|
||||
; (tip: use floats.GIVAYFAY to use A/Y input; lo/hi switched to normal order)
|
||||
@ -80,6 +80,20 @@ extsub $e2b4 = TAN() clobbers(A,X,Y) ; fac1 = TAN(fac1)
|
||||
extsub $e30e = ATN() clobbers(A,X,Y) ; fac1 = ATN(fac1)
|
||||
|
||||
|
||||
asmsub AYINT2() clobbers(X) -> word @AY {
|
||||
; fac1-> signed word in AY. Safe wrapper around the AYINT kernal routine (not reading internal memory locations)
|
||||
; (might throw ILLEGAL QUANTITY)
|
||||
%asm {{
|
||||
jsr AYINT
|
||||
ldx #<floats_temp_var
|
||||
ldy #>floats_temp_var
|
||||
jsr MOVMF
|
||||
lda floats_temp_var+4
|
||||
ldy floats_temp_var+3
|
||||
rts
|
||||
}}
|
||||
}
|
||||
|
||||
asmsub FREADS32() clobbers(A,X,Y) {
|
||||
; ---- fac1 = signed int32 from $62-$65 big endian (MSB FIRST)
|
||||
%asm {{
|
||||
@ -154,7 +168,7 @@ asmsub FREADU24AXY(ubyte lo @ A, ubyte mid @ X, ubyte hi @ Y) clobbers(A, X, Y)
|
||||
asmsub GIVUAYFAY (uword value @ AY) clobbers(A,X,Y) {
|
||||
; ---- unsigned 16 bit word in A/Y (lo/hi) to fac1
|
||||
%asm {{
|
||||
sty $62
|
||||
sty $62 ; facmo
|
||||
sta $63
|
||||
ldx #$90
|
||||
sec
|
||||
@ -183,7 +197,6 @@ asmsub GETADRAY () clobbers(X) -> uword @ AY {
|
||||
}}
|
||||
}
|
||||
|
||||
&uword AYINT_facmo = $64 ; $64/$65 contain result of AYINT
|
||||
|
||||
sub rnd() -> float {
|
||||
%asm {{
|
||||
|
@ -14,7 +14,7 @@ floats {
|
||||
; note: fac1/2 might get clobbered even if not mentioned in the function's name.
|
||||
; note: for subtraction and division, the left operand is in fac2, the right operand in fac1.
|
||||
|
||||
extsub $fe00 = AYINT() clobbers(A,X,Y) ; fac1-> signed word in 'facmo' and 'faclo', MSB FIRST. (might throw ILLEGAL QUANTITY) See "basic.sym" kernal symbol file for their memory locations.
|
||||
extsub $fe00 = AYINT() clobbers(A,X,Y) ; fac1-> signed word in 'facmo' and 'faclo', MSB FIRST. DON'T USE THIS, USE WRAPPER 'AYINT2' INSTEAD. (might throw ILLEGAL QUANTITY)
|
||||
|
||||
; GIVAYF: signed word in Y/A (note different lsb/msb order) -> float in fac1
|
||||
; there is also floats.GIVUAYFAY - unsigned word in A/Y (lo/hi) to fac1
|
||||
@ -77,6 +77,19 @@ extsub $fe8d = QINT() clobbers(A,X,Y) ; facho:facho+1:fach
|
||||
extsub $fe90 = FINLOG(byte value @A) clobbers (A, X, Y) ; fac1 += signed byte in A
|
||||
|
||||
|
||||
asmsub AYINT2() clobbers(X) -> word @AY {
|
||||
; fac1-> signed word in AY. Safe wrapper around the AYINT kernal routine (not reading internal memory locations)
|
||||
; (might throw ILLEGAL QUANTITY)
|
||||
%asm {{
|
||||
jsr AYINT
|
||||
ldx #<floats_temp_var
|
||||
ldy #>floats_temp_var
|
||||
jsr MOVMF
|
||||
lda floats_temp_var+4
|
||||
ldy floats_temp_var+3
|
||||
rts
|
||||
}}
|
||||
}
|
||||
|
||||
asmsub FREADSA (byte value @A) clobbers(A,X,Y) {
|
||||
; ---- 8 bit signed A -> float in fac1
|
||||
@ -124,6 +137,8 @@ asmsub FREADU24AXY(ubyte lo @ A, ubyte mid @ X, ubyte hi @ Y) clobbers(A, X, Y)
|
||||
|
||||
asmsub GIVUAYFAY (uword value @ AY) clobbers(A,X,Y) {
|
||||
; ---- unsigned 16 bit word in A/Y (lo/hi) to fac1
|
||||
; See "basic.sym" kernal symbol file for the facmo memory location.
|
||||
; TODO find a way to not depend on that internal fac memory location. MOVFM doesn't work.
|
||||
%asm {{
|
||||
sty $c4 ; facmo
|
||||
sta $c5 ; facmo+1
|
||||
@ -190,7 +205,6 @@ _msg .text 13,"?rom 47+ required for val1",13,0
|
||||
}}
|
||||
}
|
||||
|
||||
&uword AYINT_facmo = $c6 ; $c6/$c7 contain result of AYINT (See "basic.sym" kernal symbol file)
|
||||
|
||||
sub rnd() -> float {
|
||||
%asm {{
|
||||
|
@ -1,13 +1,17 @@
|
||||
TODO
|
||||
====
|
||||
|
||||
|
||||
for releasenotes: gfx2.width and gfx2.height got renamed as gfx_lores.WIDTH/HEIGHT or gfx_hires4.WIDTH/HEIGTH constants. Screen mode routines also renamed.
|
||||
|
||||
regenerate symbol dump files
|
||||
|
||||
improve ability to create library files in prog8; for instance there's still stuff injected into the start of the start() routine AND there is separate setup logic going on before calling it.
|
||||
Make up our mind! Maybe all setup does need to be put into start() ? because the program cannot function correctly when the variables aren't initialized properly bss is not cleared etc. etc.
|
||||
Add a -library $xxxx command line option to preselect every setting that is required to make a library at $xxxx rather than a normal loadable and runnable program
|
||||
Add a -library $xxxx command line option to preselect every setting that is required to make a library at $xxxx rather than a normal loadable and runnable program?
|
||||
Need to add some way to generate a stable jump table at a given address.
|
||||
Why are blocks without an addr moved BEHIND a block with an address? That's done in the StatementReorderer.
|
||||
|
||||
|
||||
Improve register load order in subroutine call args assignments:
|
||||
in certain situations, the "wrong" order of evaluation of function call arguments is done which results
|
||||
|
@ -1,13 +1,20 @@
|
||||
%import textio
|
||||
%zeropage dontuse
|
||||
%import floats
|
||||
%option no_sysinit
|
||||
%address $5000
|
||||
%launcher none
|
||||
%zeropage basicsafe
|
||||
|
||||
main {
|
||||
sub start() {
|
||||
txt.print("address of start: ")
|
||||
txt.print_uwhex(&start, true)
|
||||
float @shared fl1 = 4444.234
|
||||
float @shared fl2 = -9999.111
|
||||
float @shared fl3 = fl1+fl2
|
||||
floats.print(fl1)
|
||||
txt.spc()
|
||||
floats.print(fl2)
|
||||
txt.spc()
|
||||
floats.print(fl3)
|
||||
txt.nl()
|
||||
txt.print_w(fl3 as word)
|
||||
txt.nl()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user