Hi,
Maybe someone whom knows 6502 MS BASIC very well could assist me. I try to debug what FLOAT2 and FOUT functions do.
FLOAT2 input:
FAC+1 LO byte of mantissa
FAC+2 HI byte of mantissa
X = exponent, but in which format? For integer $90?
FLOAT2 output:
FAC ?
FAC+1 ?
FAC+2 ?
FAC+3 ?
My main question: what is the content of FAC bytes after FLOAT2 being executed?
Axel.
6502 MS Basic in details (FLOAT2-FOUT functions)
6502 MS Basic in details (FLOAT2-FOUT functions)
Last edited by Ax2013 on Sun Oct 22, 2017 4:08 pm, edited 1 time in total.
Re: 6502 MS Basic and FLOAT2-FOUT functions
Ax2013 wrote:
Hi,
Maybe someone whom knows 6502 MS BASIC very well could assist me. I try to debug what FLOAT2 and FOUT functions do.
FLOAT2 input:
FAC+1 LO byte of mantissa
FAC+2 HI byte of mantissa
X = exponent, but in which format? For integer $90?
FLOAT2 output:
FAC ?
FAC+1 ?
FAC+2 ?
FAC+3 ?
My main question: what is the content of FAC bytes after FLOAT2 being executed?
Maybe someone whom knows 6502 MS BASIC very well could assist me. I try to debug what FLOAT2 and FOUT functions do.
FLOAT2 input:
FAC+1 LO byte of mantissa
FAC+2 HI byte of mantissa
X = exponent, but in which format? For integer $90?
FLOAT2 output:
FAC ?
FAC+1 ?
FAC+2 ?
FAC+3 ?
My main question: what is the content of FAC bytes after FLOAT2 being executed?
In case you consider the non-small format you have also FAC+4.
Because FAC1 will get normalized
- FAC will contain the exponent in excess notation (e.g. https://www.c64-wiki.com/wiki/Floating_point_arithmetic), in case of an 16 bit integer you will have to use $90 ($80 excess + two's exponent $10).
- FAC+1 ... FAC+3(4) contains the mantissa which will get the leading 1 bit shifted to the left (with the exponent adjusted accordingly) with the imaginary "0." in front of it. In the expanded float representation in the FAC the leading 1 bit is kept in place (for the compact format this bit contains the sign). A negative two's complement value is turned into a positive one and the sign is stored in an extra byte (FACSIGN).
Code: Select all
FAC = $87
FAC+1 = $84
FAC+2 = 0
FAC+3 = 0
FAC+4 = 0
FACSIGN = 0
= 0.10000100 00000000 00000000 00000000 * 2^7
FAC+1 FAC+2 FAC+3 FAC+4Re: 6502 MS Basic and FLOAT2-FOUT functions
Thanks for the explanation!
br,
Axel.
br,
Axel.
Re: 6502 MS Basic in details (FLOAT2-FOUT functions)
#JeeK, do you happen to know what are the proper parameters when calling LIST function? It does actually work just by "jsr LIST" but there are at least Z and C flags and Reg-A involved. I'm writing SAVE and LOAD functions. I was going to use LIST cmd without screen output for SAVE and GETC (also without screen output) for LOAD. Any other ideas are welcome.
Axel.
Axel.
Re: 6502 MS Basic in details (FLOAT2-FOUT functions)
Ax2013 wrote:
#JeeK, do you happen to know what are the proper parameters when calling LIST function? It does actually work just by "jsr LIST" but there are at least Z and C flags and Reg-A involved. I'm writing SAVE and LOAD functions. I was going to use LIST cmd without screen output for SAVE and GETC (also without screen output) for LOAD. Any other ideas are welcome.
Axel.
Axel.
LIST is problematic to call because it ends always in a warm start, never comes back to the caller.
On a C64 you might catch up the warm start vector $300 to get the control back after a list call.
Calling LIST similar to a call without a parameter you might use
JSR $A613 ; find first line
JSR $A6C3 ; do list from beginning
If you save the contents of $0300/$0301, let it point to your resume code before calling the above code, LIST branches
to your resume code which in turn should restore $0300/$0301 and may finally returns to the caller using a RTS.
(didn't try it, just the JSR sequence above)