6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Nov 23, 2024 3:14 am

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Fri Oct 06, 2017 3:04 pm 
Offline

Joined: Thu Jul 27, 2017 7:48 pm
Posts: 68
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.


Last edited by Ax2013 on Sun Oct 22, 2017 4:08 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
PostPosted: Tue Oct 10, 2017 1:40 pm 
Offline
User avatar

Joined: Tue Aug 14, 2012 12:47 pm
Posts: 18
Location: Austria - Vienna
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?

If you are referring to https://github.com/mist64/msbasic/blob/master/float.s
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).

If the starting value is e.g. X=$90 and FAC+1/FAC+2 $00/$42 we should get
Code:
 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+4


Top
 Profile  
Reply with quote  
PostPosted: Fri Oct 13, 2017 5:48 pm 
Offline

Joined: Thu Jul 27, 2017 7:48 pm
Posts: 68
Thanks for the explanation!

br,

Axel.


Top
 Profile  
Reply with quote  
PostPosted: Sun Oct 22, 2017 4:15 pm 
Offline

Joined: Thu Jul 27, 2017 7:48 pm
Posts: 68
#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.


Top
 Profile  
Reply with quote  
PostPosted: Tue Nov 21, 2017 9:30 pm 
Offline
User avatar

Joined: Tue Aug 14, 2012 12:47 pm
Posts: 18
Location: Austria - Vienna
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.

You want to put a LIST output to a file (with something like a SAVE)? Also the reverse task with some LOAD which takes a textual LIST output?

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)


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 23 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: