Where are the addresses for the float routines in the VIC20?
Moderator: Moderators
Where are the addresses for the float routines in the VIC20?
Hi good afternoon.
Where are the addresses for the float routines in the VIC20?
I wanted to use it in ASM.
this is the c64 :
https://www.c64-wiki.de/wiki/Flie%C3%9Fkommaarithmetik
Thank you.
Greeting
Where are the addresses for the float routines in the VIC20?
I wanted to use it in ASM.
this is the c64 :
https://www.c64-wiki.de/wiki/Flie%C3%9Fkommaarithmetik
Thank you.
Greeting
-
- Vic 20 Afficionado
- Posts: 352
- Joined: Tue Apr 14, 2009 8:15 am
- Website: http://wimbasic.webs.com
- Location: Netherlands
- Occupation: farmer
Re: Where are the addresses for the float routines in the VIC20?
Hello funkheld
The Basic Interpreter in VIC20 is assembled in $C000 - $DFFF.
I always use: https://www.mdawson.net/vic20chrome/vic ... sembly.txt for reference.
Regards,
Wim.
The Basic Interpreter in VIC20 is assembled in $C000 - $DFFF.
I always use: https://www.mdawson.net/vic20chrome/vic ... sembly.txt for reference.
Regards,
Wim.
VICE; selfwritten 65asmgen; tasm; maintainer of WimBasic
- Mike
- Herr VC
- Posts: 4901
- Joined: Wed Dec 01, 2004 1:57 pm
- Location: Munich, Germany
- Occupation: electrical engineer
Re: Where are the addresses for the float routines in the VIC20?
@wimoos: PM sent
Re: Where are the addresses for the float routines in the VIC20?
Hello, thanks for the help.
I'm going to pick out the float commands.
Thank you.
greeting
I'm going to pick out the float commands.
Thank you.
greeting
Re: Where are the addresses for the float routines in the VIC20?
Hi good afternoon.
what does that mean please, i don't understand it as german:
convert FAC1 floating to fixed
Thank you.
greeting
what does that mean please, i don't understand it as german:
convert FAC1 floating to fixed
Thank you.
greeting
- chysn
- Vic 20 Scientist
- Posts: 1205
- Joined: Tue Oct 22, 2019 12:36 pm
- Website: http://www.beigemaze.com
- Location: Michigan, USA
- Occupation: Software Dev Manager
Re: Where are the addresses for the float routines in the VIC20?
Hey, funkheld,
I'm interested in this question, too. So far, I've been working with the integer-to-float and float-to-integer conversions. These are useful for getting input from BASIC (via USR()) and returning output as a USR() return value. The relevant routines are
$D1AA: Converts a floating point value in FAC1 (the first of two floating point accumulators) to a 16-bit integer, with Y as the low byte and A as the high byte
$D391: Writes a 16-bit integer (same format as above) to FAC1
Here's a simple example that basically turns USR() into PEEK
Then set the USR instruction with
POKE 0, 76:POKE 1, 0:POKE 2,24
?USR(2);
24
The next thing I'm going to do is play around with floating point operations between the two FACs. Most operations are performed on FAC1, but there are routines that copy FAC2 to FAC1 ($DBFC) and vice-versa ($DC0F). So if you don't mind, I'll write more about these experiments on this thread.
I'm interested in this question, too. So far, I've been working with the integer-to-float and float-to-integer conversions. These are useful for getting input from BASIC (via USR()) and returning output as a USR() return value. The relevant routines are
$D1AA: Converts a floating point value in FAC1 (the first of two floating point accumulators) to a 16-bit integer, with Y as the low byte and A as the high byte
$D391: Writes a 16-bit integer (same format as above) to FAC1
Here's a simple example that basically turns USR() into PEEK
Code: Select all
1800 JSR $D1AA ; Convert the parameter passed to USR into 16-bit integer (Y low, A high)
1803 STY $F9 ; Save the low and high bytes as a pointer to the location we want to PEEK at
1805 STA $FA
1807 LDY #$00 ; Clearing Y so it can be used as a 0 index in the next instruction
1809 LDA ($F9),Y
180B TAY ; Y is used as the low byte for the fixed-to-float conversion
180C LDA #$00 ; A is the high byte, so we want it to be 0
180E JSR $D391 ; Convert Y/A over to FAC1, so that USR() returns it
1811 RTS
POKE 0, 76:POKE 1, 0:POKE 2,24
?USR(2);
24
The next thing I'm going to do is play around with floating point operations between the two FACs. Most operations are performed on FAC1, but there are routines that copy FAC2 to FAC1 ($DBFC) and vice-versa ($DC0F). So if you don't mind, I'll write more about these experiments on this thread.
VIC-20 Projects: wAx Assembler, TRBo: Turtle RescueBot, Helix Colony, Sub Med, Trolley Problem, Dungeon of Dance, ZEPTOPOLIS, MIDI KERNAL, The Archivist, Ed for Prophet-5
WIP: MIDIcast BASIC extension
he/him/his
WIP: MIDIcast BASIC extension
he/him/his
- Mike
- Herr VC
- Posts: 4901
- Joined: Wed Dec 01, 2004 1:57 pm
- Location: Munich, Germany
- Occupation: electrical engineer
Re: Where are the addresses for the float routines in the VIC20?
If you go on exploration mode regarding the floating point routines of the VIC-20 BASIC interpreter, that for sure warrants your own thread - with the prospect that quite some people here in Denial will follow the new thread as it unfolds.chysn wrote:So if you don't mind, I'll write more about these experiments on this thread.
At least that promises to be a much more interesting topic than the trivial question put up in this thread here, where the OP just wants a list of addresses spoon-fed, all of which can be found in standard literature (like "Compute's Mapping the VIC" in English or "VC-20 intern" in German) or - for that matter - in a sticky thread here in the Programming section ("ROM calls and other tricks").
- chysn
- Vic 20 Scientist
- Posts: 1205
- Joined: Tue Oct 22, 2019 12:36 pm
- Website: http://www.beigemaze.com
- Location: Michigan, USA
- Occupation: Software Dev Manager
Re: Where are the addresses for the float routines in the VIC20?
Perhaps I will. I’ll peruse the forum a bit to see if a treatment of floating point arithmetic in ML already exists. Writing about something often helps me understand it better.
I’m finding that Mapping the VIC’s info is really good. It doesn’t really go into the format of the mantissa; but the more I delve, the more I realize that I can treat FAC1 and FAC2 as black boxes. There’s enough software in ROM to deal with them in a civilized way, i.e., as converted strings or data copied from memory.
VIC-20 Projects: wAx Assembler, TRBo: Turtle RescueBot, Helix Colony, Sub Med, Trolley Problem, Dungeon of Dance, ZEPTOPOLIS, MIDI KERNAL, The Archivist, Ed for Prophet-5
WIP: MIDIcast BASIC extension
he/him/his
WIP: MIDIcast BASIC extension
he/him/his
- Mike
- Herr VC
- Posts: 4901
- Joined: Wed Dec 01, 2004 1:57 pm
- Location: Munich, Germany
- Occupation: electrical engineer
Re: Where are the addresses for the float routines in the VIC20?
Such a treatment has not been done yet here in Denial, AFAIK.chysn wrote:I’ll peruse the forum a bit to see if a treatment of floating point arithmetic in ML already exists.
You'll find quite some examples of float routines strewn across the forum: SQR() reimplemented with Heron's algorithm, the inner loop of the Mandelbrot fractal, USR() used as popcount or joystick read function, and somewhere there's also an unfinished attempt to provide DIV() and MOD() as functions of two variables.
And there's also a round-up of the multiplication bug in the BASIC interpreter.
Re: Where are the addresses for the float routines in the VIC20?
You might find this booklet useful
http://69.60.118.202/books/vic20/VIC-20 ... Abacus.zip
It has a long section on floating point routines.
http://69.60.118.202/books/vic20/VIC-20 ... Abacus.zip
It has a long section on floating point routines.
- chysn
- Vic 20 Scientist
- Posts: 1205
- Joined: Tue Oct 22, 2019 12:36 pm
- Website: http://www.beigemaze.com
- Location: Michigan, USA
- Occupation: Software Dev Manager
Re: Where are the addresses for the float routines in the VIC20?
Thank you. Yes, this was an important resource when I was learning about it. Beware the typo on page 40! The string address should be stored in $22 and $23, not $71 and $72 as shown in the code. The other thing is that you don't really need to know how long the string is. The ASCFLT at $DFC3 stops working when it encounters a non-numeric value*. So LDA #$FF works fine if you don't want to be bothered by figuring out the length.srowe wrote: ↑Thu Feb 20, 2020 1:20 pm You might find this booklet useful
http://69.60.118.202/books/vic20/VIC-20 ... Abacus.zip
It has a long section on floating point routines.
In this book, the string-to-FAC conversion taps into BASIC's VAL() function. I've been using ASCFLT directly, like this:
Code: Select all
STY $7A
STA $7B
JSR $0079
JSR $DCF3
RTS
* Except for spaces. I learned by going through the ROM disassembly that everything that parses a floating point number does it through CHRGET, which basically ignores spaces. So spaces in numbers are just glossed over (for example, "5 . 6" is the same as "5.6")
VIC-20 Projects: wAx Assembler, TRBo: Turtle RescueBot, Helix Colony, Sub Med, Trolley Problem, Dungeon of Dance, ZEPTOPOLIS, MIDI KERNAL, The Archivist, Ed for Prophet-5
WIP: MIDIcast BASIC extension
he/him/his
WIP: MIDIcast BASIC extension
he/him/his