Page **3** of **4**

### Re: Let's calculate! - renewed arithmetic routines

Posted: **Thu Jun 14, 2018 12:26 am**

by **siggi**

Great progress

Just testet LOAD "Memocalc" and it worked

Now it seems to be possible to LOAD programs also by a running program (not only by the user, pressing DS-L).

Currently I cannot LOAD/SAVE Memocalc data files (which are loaded/saved by Memocalc by the command "LOAD A$(L TO C)"(*), which is embedded in M/C and called from M/C!) on ZxMore, because patching Memocalc to call (on LOAD and SAVE) an external program, which asked and waited for the user's DS-L or DS-S to be done, resulted in finishing Memocalc and return to BASIC (despite this technology workes well when using MEFISDOS/MMC as mass storage device).

More tests will follow ....

Siggi

Edit: (*): the ROM subroutine "03A8 NAME" can be used scan/evaluate such a complex string ....

### Re: Let's calculate! - renewed arithmetic routines

Posted: **Thu Jun 14, 2018 9:37 pm**

by **siggi**

I just testet Memocalc without my SAVE/LOAD patches. Now it can save/load data files using its internal "LOAD A$(L TO C)"

But the filename is a little bit strange: I saved "mtest", and Windows sees a file with invalid filename it cannot handle: "mtest<-<-<-.<-<-<-" (where "<-" is one chacter: an arrow to the left). Thus 3 chars before the '.' and 3 chars past the '.' are "<-" (maybe not initialized by Memocalc).

But ZxMore can handle that file, so I now can save/load Memocalc data files

@ZSOLT: I have made tests with Memocalc and let it do:

sum=0

FOR degree=365 down to 0

sum=sum+sin(degree/180*PI)^2+cos(degree/180*PI)^2

next degree

and got the expected result. Since Memocalc does call a lot of BASIC functions to handle the "grid", to edit and calculate the field contents (e.g. by using the BASIC input line editor to input eqations containing BASIC keywords/functions) and there was no problem:

Siggi

### Re: Let's calculate! - renewed arithmetic routines

Posted: **Thu Jun 14, 2018 9:39 pm**

by **olofsen**

siggi wrote: ↑Thu Jun 14, 2018 12:26 am

Edit: (*): the ROM subroutine "03A8 NAME" can be used scan/evaluate such a complex string ....

Yes, I left it in place at the beginning of LOAD and SAVE. However, the resulting string can only have A-Z. That is because the ZX81 character to ASCII conversion just adds $1B, otherwise it takes too much space

### Re: Let's calculate! - renewed arithmetic routines

Posted: **Thu Jun 14, 2018 11:29 pm**

by **zsolt**

siggi wrote: ↑Thu Jun 14, 2018 9:37 pm

and got the expected result. Since Memocalc does call a lot of BASIC functions to handle the "grid", to edit and calculate the field contents (e.g. by using the BASIC input line editor to input eqations containing BASIC keywords/functions) and there was no problem

Great News

Thanks,

Zsolt

### Re: Let's calculate! - renewed arithmetic routines

Posted: **Mon Jun 18, 2018 4:36 pm**

by **zsolt**

Many thanks to olofsen:

olofsen wrote:I reread your posts and saw your note on "testing the limits", and got the idea of finding FLT_EPSILON.

It is the smallest number that when added to 1, the result is different from 1.

In the attached program, I'm on my way to compute it. Line 2000 makes V, at first 1, greater than 1.

If you run this program with the original ZX81 ROM, V-1 is printed as 4.6566129E-10. However, with your ROM, it prints 0...

I found the BUG

This is a "small mistake", but it is very important that we found it.

At the beginning of the normalization, the counter had a bad starting value:

Code: Select all

```
ld bc,$2000 ; set counters (it was $1F00)
ld a,c ; clear A
rra ; A7 indicates the sign change
sub_norm
bit 7,h ; normalize
jp nz,sub_end ; done if msb=1
ex de,hl ;
add hl,hl ; double the lower word of the result's mantissa
ex de,hl ;
adc hl,hl ; double the upper word of the result's mantissa
inc c ; set counter
djnz sub_norm ; max. 31 shifts are accepted
```

You can find Erik's test program and the bug fixed ROM image in the attachment.

The "SG81_Gm" is for ZXmore (wo. 3T-patch), which is ~3% slower than the other.

Regards,

Zsolt

Edit:

here is the next bug fixed version!

### Re: Let's calculate! - renewed arithmetic routines

Posted: **Wed Jun 20, 2018 5:14 pm**

by **siggi**

Hi ZSOLT

I tried to assemble your source using Pokemon's IDE (using FASMW-ZX.EXE) and the assembler used in Z88DK. But none of them can handle the labels you are using, e. g.:

They accept only such labels:

or

Which assembler to you use? Is it availabe somewhere (I am using WIN as OS):

Siggi

### Re: Let's calculate! - renewed arithmetic routines

Posted: **Wed Jun 20, 2018 8:36 pm**

by **zsolt**

Hi Siggi,

I use the good old '

**Assembly Studio 86 v3.1**'

*(downloadable from here - ticalc.org/pub/win/asm/)*.

It has a good editor, a code counter

*(counts also the Tstates!)* and it is TASM compatible.

But why not rename the labels to the desired format?

Regards,

Zsolt

### Re: Let's calculate! - renewed arithmetic routines

Posted: **Wed Jun 20, 2018 9:59 pm**

by **siggi**

zsolt wrote: ↑Wed Jun 20, 2018 8:36 pm

But why not rename the labels to the desired format?

Hi ZSOLT

If your current rom is the final version, that would be OK. But if not, it must be done with each new version

I want to do some more patches I have in my own roms to support my own hardware better (LOAD/SAVE using MMC/Mefisdos, bank switching@8k, printer driver in RAM instead of ROM, Euro character instead of pound sign, ....)

Siggi

### Re: Let's calculate! - renewed arithmetic routines

Posted: **Fri Jun 22, 2018 9:55 am**

by **zsolt**

Hi Siggi,

siggi wrote: ↑Wed Jun 20, 2018 9:59 pm

If your current rom is the final version,

No, the final version with a "Big Bang"

is still under construction.

Zsolt

### Re: Let's calculate! - renewed arithmetic routines

Posted: **Sat Jun 23, 2018 9:33 am**

by **siggi**

zsolt wrote: ↑Fri Jun 22, 2018 9:55 am

Hi Siggi,

siggi wrote: ↑Wed Jun 20, 2018 9:59 pm

If your current rom is the final version,

No, the final version with a "Big Bang"

is still under construction.

Zsolt

Using that "Big Bang" version the Zeddy then can execute an endless loop within less than 3 seconds. Correct?

Siggi