Image Map Image Map
Page 1 of 5 12345 LastLast
Results 1 to 10 of 42

Thread: Floating point info code for 8088 wanted

  1. #1

    Default Floating point info code for 8088 wanted

    I'm writing my own BASIC from scratch in 8088 assembly. The editor, the way the lines are stored and can be listed again seems to work fine. The next step is to write the code for the various commands and functions. I want to support at least the commands and functions as supported by the C64. This means I need to support floating point.

    I have found documentation about FP plus some info about adding, subtracting, multiplication an division using FP numbers. But I haven't found anything related to LOG, SIN, square root and other more difficult stuff yet. Any pointers, please?

    Best would be if somebody has 8088 code that goes by it. 80836+ code would do as well, I should be able to convert it to 8088, but no 80x87 code: it should run on a standard IBM-PC in the first place.

    One thing I'm thinking about is looking how the c64 does it. I "only" have to translate the 6502 code into 8088. And here is a challenge as well: single precision is 32 bits, double precision is 64 bits but the C64 supports 40 bits.
    Using 40 bits as well means less work but using 64 bits could mean that the BASIC as whole will be slowed down. I have no idea what precision the original IBM BASIC (= Microsoft) uses.

    Any help and info is welcome!
    With kind regards / met vriendelijke groet, Ruud Baltissen

    www.baltissen.org

  2. #2
    Join Date
    Jan 2005
    Location
    Principality of Xeon (NJ)
    Posts
    1,436

    Default

    Are you intentionally avoiding snooping out M$ code? You haven't disclosed what you rewriting, a compiler, an interpreter? If it's an interpreter, I guess it kind of makes sense, but the notion is coming from an odball. The larger question is why, especially if it's a new compiler you're crafting. Personally if I were interested at all in writing my own implementation of a language, it would be something like PROLOG.

  3. #3

    Default

    First: this is purely a fun project. This BASIC should be an interpreter. I'm also busy with my own Pascal compiler, written in Free Pascal. The end results should be able to run under my own OS. This OS is meant to be able to run on an IBM-PC (compatible).

    Are you intentionally avoiding snooping out M$ code?
    No. But so far I haven't found any MS code yet so there is nothing to snoope at all. The only 8088 source of a BASIC interpreter I found so far is the one of PATB and that one doesn't support floating point at all. So if you, or anyone else, have the 8088 sources of a BASIC interpreter, or any language, I really would like to have a look at them. Just to find out how FP is handled.

    Regarding PROLOG, the reason I chose Pascal and BASIC is that I'm familiar with both. The moment my BASIC interpreter works fine, I'm thinking about using it as base for a Pascal interpreter and then turn that one into a compiler.

    Oh, almost forgot to mention: this BASIC interpreter should be able to work stand-alone, just like the BASIC of the PC or the C64. At this moment the BASIC part is loaded from from disk by the boot sector because writing to a disk is a bit easier than writing to an EEPROM everytime.
    With kind regards / met vriendelijke groet, Ruud Baltissen

    www.baltissen.org

  4. #4
    Join Date
    Jan 2005
    Location
    Principality of Xeon (NJ)
    Posts
    1,436

    Default

    While not a basic interpreter, Herb Schildt wrote a C tutorial/reference that as a project had a C interpreter. Can't speak to how or if it handled fp math. I can find the exact title later if it interests you. I sent a PM by the way.

  5. #5
    Join Date
    Jan 2007
    Location
    Pacific Northwest, USA
    Posts
    32,736
    Blog Entries
    18

    Default

    For many years, the book sitting (dusty now) on my bookshelf was pretty much a practical standard for implementors.

    "Software Manual for the Elementary Functions"; William Cody Jr., William Waite; Prentice-Hall, 1980

    ISBN 0-13-822064-6

    Written by a couple of number-spinners at Argonne National Labs. There may be follow-ons; sample code in FORTRAN. It's very good, but you should know your Chebyshev polynomials from your Taylor series.

    ACM CALGO should also be a gold mine. I've also got an old 1960s IBM S/360 publication describing the algorithms used for their FORTRAN run-time.

    I'm assuming that you want to write code that produces quantifiably accurate results, not clone someone else's errors. The transcendental functions can be very tricky when it comes to extreme values.

  6. #6
    Join Date
    May 2009
    Location
    Connecticut
    Posts
    4,465
    Blog Entries
    1

    Default

    Bywater Basic is a portable open source BASIC interpreter written in C. Version 1 was public domain and MS-DOS. Earlier versions were smaller and thus better for 8088 usage. The version 2 math code seems to be a fairly clear implementation of a floating point for BASIC. Worse places to spend a little time looking at.

  7. #7
    Join Date
    Jan 2007
    Location
    Pacific Northwest, USA
    Posts
    32,736
    Blog Entries
    18

    Default

    Why copy someone, when there's an opportunity to learn something?

    Also, what kind of floating point? When I wrote for financial BASIC and spreadsheet, I was required to implement decimal floating point. For non-finance stuff, I wrote binary floating point routines (both for x80 an x86). Both have their uses.

  8. #8
    Join Date
    May 2009
    Location
    Connecticut
    Posts
    4,465
    Blog Entries
    1

    Default

    I have written my own floating point routines. Validating those was tedious. I don't know how long the OP plans to take before having code that can be shown to others. If stuck, having a working implementation to seek inspiration from can be helpful.

  9. #9
    Join Date
    Jan 2007
    Location
    Pacific Northwest, USA
    Posts
    32,736
    Blog Entries
    18

    Default

    Maybe it's me, but I remember that working out FP routines was a real adventure. Not everything was IEEE 754 back then and the ways various vendors implemented FP was a source of fascination for me. For example, HP had an interesting take on decimal FP--the mantissa was expressed as a group of 16-bit binary numbers having a range of 0-9999 each. CDC used FP with the binary point after the least-significant bit, so that an integer multiply could be effected by using an unnormalized double-precision FP multiply. IBM S/360 had a floating point representation that was generally considered to be the worst ever implemented.

    And so on. You also learned how to twiddle bits to get the fastest result--and then there was all the numerical analysis stuff.

  10. #10
    Join Date
    Dec 2010
    Location
    Seattle, WA
    Posts
    1,859

    Default

    Floating point is hard.

    Not directly on topic with the original post, but if you have a couple of hours to spare some may find some interesting content in this video:

    Floating Point - Past, present and Future
    Recorded on May 23, 1995
    www.youtube.com/watch?v=LuKBvsvkzEs

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •