Why are the DAC and ARG not 8 bytes?

Page 1/3
| 2 | 3

Par WORP3

Paladin (864)

Portrait de WORP3

25-01-2022, 12:24

Maybe a stupid question but looking at the MSX math pack I wonder why the DAC and ARG are both 16 bytes is size?
Looking at the BCD description the maximum double precision size can only be 8 bytes per number, anyone Question
Also is the system MSX uses compatible with IEEE 754-1985?

!login ou Inscrivez-vous pour poster

Par WORP3

Paladin (864)

Portrait de WORP3

25-01-2022, 14:34

I know that there are 16 bytes reserved for each of the two math variable, but why 16 when each variable is only 8 bytes?

Par gdx

Enlighted (6429)

Portrait de gdx

25-01-2022, 16:06

Good question. I did not notice. They may be planning to do more in the future.

Par NYYRIKKI

Enlighted (6091)

Portrait de NYYRIKKI

25-01-2022, 17:32

Indeed a nice catch that has missed my eyes as well... It seems at least RND-function uses the spare part of DAC as some sort of temporary space, but in reality this is either "for future expansion" or then they just accidentally mixed up BCD numbers and bytes at some point.

WORP3 wrote:

Also is the system MSX uses compatible with IEEE 754-1985?

No... IEEE 754 is base 2 while the MSX-BASIC system is base 10. Some other Microsoft BASIC variants (even earlier) use base 2 numbers though... Makes me wonder why we got these slower base 10 numbers instead.

Par zeilemaker54

Champion (355)

Portrait de zeilemaker54

25-01-2022, 20:15

In general MSX-BASIC is a port of MBASIC (Microsoft BASIC for CP/M). GWBASIC for PC is largely a port of the MBASIC i8080 code to i8086 code.
Both MBASIC and GWBASIC use the Microsoft Binary Format, which use 8 bytes for double floating point (and 4 bytes for single floating point). The code for the floating point routines is in the so called F4 module.
But it seems that for MSX-BASIC (and its predecessor SVI-BASIC) a different floating point format (BCD based) was chosen for reasons unknown to me. If you compare the F4 module of MSX-BASIC with the F4 module of MBASIC there are relatively much differences, compared to the other modules. So it seems that the F4 module was largely rewritten.
In size, there is not difference. So double floating point is still 8 bytes, and single floating point 4 bytes.
For example double floating point 1.0 in MBASIC it is stored as 00H,00H,00H,00H,000H,00H,00H,81H
And in MSX-BASIC it is stored as 41H,10H,00H,00H,00H,00H,00H,00H
[guessing mode:] It may be that during development 16 bytes was considered but later ditched (for performance reasons?) without reflecting this in the size of the data structure of both DAC and ARG. Or for expansion purposes may be room was reserved for IEEE quadruple-precision floating point, which is a 16 byte format.

Par WORP3

Paladin (864)

Portrait de WORP3

26-01-2022, 11:45

NYYRIKKI wrote:

Indeed a nice catch that has missed my eyes as well... It seems at least RND-function uses the spare part of DAC as some sort of temporary space, but in reality this is either "for future expansion" or then they just accidentally mixed up BCD numbers and bytes at some point.

WORP3 wrote:

Also is the system MSX uses compatible with IEEE 754-1985?

No... IEEE 754 is base 2 while the MSX-BASIC system is base 10. Some other Microsoft BASIC variants (even earlier) use base 2 numbers though... Makes me wonder why we got these slower base 10 numbers instead.

At least they don't incorporate the incorrect roundoff duo to the base 2 Wink

Par WORP3

Paladin (864)

Portrait de WORP3

26-01-2022, 11:50

zeilemaker54 wrote:

In general MSX-BASIC is a port of MBASIC (Microsoft BASIC for CP/M). GWBASIC for PC is largely a port of the MBASIC i8080 code to i8086 code.
Both MBASIC and GWBASIC use the Microsoft Binary Format, which use 8 bytes for double floating point (and 4 bytes for single floating point). The code for the floating point routines is in the so called F4 module.
But it seems that for MSX-BASIC (and its predecessor SVI-BASIC) a different floating point format (BCD based) was chosen for reasons unknown to me. If you compare the F4 module of MSX-BASIC with the F4 module of MBASIC there are relatively much differences, compared to the other modules. So it seems that the F4 module was largely rewritten.
In size, there is not difference. So double floating point is still 8 bytes, and single floating point 4 bytes.
For example double floating point 1.0 in MBASIC it is stored as 00H,00H,00H,00H,000H,00H,00H,81H
And in MSX-BASIC it is stored as 41H,10H,00H,00H,00H,00H,00H,00H
[guessing mode:] It may be that during development 16 bytes was considered but later ditched (for performance reasons?) without reflecting this in the size of the data structure of both DAC and ARG. Or for expansion purposes may be room was reserved for IEEE quadruple-precision floating point, which is a 16 byte format.

Just wondering, would it be possible that different MSX manufacturers could have implemented different math packs?

Par Briqunullus

Paladin (764)

Portrait de Briqunullus

26-01-2022, 15:54

WORP3 wrote:

Just wondering, would it be possible that different MSX manufacturers could have implemented different math packs?

What's the competitive advantage for that? When there are so many other things a manufacturer can do?

Par PingPong

Enlighted (4155)

Portrait de PingPong

26-01-2022, 18:43

I'm Guessing : Maybe the MSX-BASIC format was more z80 friendly than the IEEE format in terms of performances vs precision?

Par zeilemaker54

Champion (355)

Portrait de zeilemaker54

26-01-2022, 20:10

A very limited test with SQR(10) learns that MSX-BASIC is 3.5 times slower...
Note also that MBASIC is pure i8080 code, but even the bigest part of MSX-BASIC is still using the original i8080 code, not Z80 optimized.

Page 1/3
| 2 | 3