Let's calculate! - renewed arithmetic routines

Anything Sinclair ZX Basic related; history, development, tips - differences between BASIC on the ZX80 and ZX81
User avatar
siggi
Posts: 1029
Joined: Thu May 08, 2008 9:30 am
Location: Wetterau, Germany
Contact:

Re: Let's calculate! - renewed arithmetic routines

Post by siggi »

Great progress :mrgreen:
Just testet LOAD "Memocalc" and it worked :mrgreen:

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 ....
My ZX81 web-server: online since 2007, running since dec. 2020 using ZeddyNet hardware
http://zx81.ddns.net/ZxTeaM
User avatar
siggi
Posts: 1029
Joined: Thu May 08, 2008 9:30 am
Location: Wetterau, Germany
Contact:

Re: Let's calculate! - renewed arithmetic routines

Post 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)" :mrgreen:
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 :mrgreen:

@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: :mrgreen:

Siggi
My ZX81 web-server: online since 2007, running since dec. 2020 using ZeddyNet hardware
http://zx81.ddns.net/ZxTeaM
olofsen
Posts: 189
Joined: Wed Jan 08, 2014 12:29 pm

Re: Let's calculate! - renewed arithmetic routines

Post 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 ;)
User avatar
zsolt
Posts: 214
Joined: Wed Apr 20, 2011 11:43 am
Location: Fót, Hungary

Re: Let's calculate! - renewed arithmetic routines

Post 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 :D
Thanks,
Zsolt
ZX81 (8K), ENTERPRISE 128, [ZX SPECTRUM (48K,+,+128K,+2,+2A), TS1000, TS1500, TS2068, Cambridge Z88, PRIMO A64 (red)]
User avatar
zsolt
Posts: 214
Joined: Wed Apr 20, 2011 11:43 am
Location: Fót, Hungary

Re: Let's calculate! - renewed arithmetic routines

Post 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 :D 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! ;)
Last edited by zsolt on Thu Jun 28, 2018 7:54 pm, edited 1 time in total.
ZX81 (8K), ENTERPRISE 128, [ZX SPECTRUM (48K,+,+128K,+2,+2A), TS1000, TS1500, TS2068, Cambridge Z88, PRIMO A64 (red)]
User avatar
siggi
Posts: 1029
Joined: Thu May 08, 2008 9:30 am
Location: Wetterau, Germany
Contact:

Re: Let's calculate! - renewed arithmetic routines

Post 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.:

Code: Select all

not_1
	NEG
They accept only such labels:

Code: Select all

not_1:
	NEG

or

Code: Select all

not_1 NEG
:(

Which assembler to you use? Is it availabe somewhere (I am using WIN as OS):
Siggi
My ZX81 web-server: online since 2007, running since dec. 2020 using ZeddyNet hardware
http://zx81.ddns.net/ZxTeaM
User avatar
zsolt
Posts: 214
Joined: Wed Apr 20, 2011 11:43 am
Location: Fót, Hungary

Re: Let's calculate! - renewed arithmetic routines

Post 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
ZX81 (8K), ENTERPRISE 128, [ZX SPECTRUM (48K,+,+128K,+2,+2A), TS1000, TS1500, TS2068, Cambridge Z88, PRIMO A64 (red)]
User avatar
siggi
Posts: 1029
Joined: Thu May 08, 2008 9:30 am
Location: Wetterau, Germany
Contact:

Re: Let's calculate! - renewed arithmetic routines

Post 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
My ZX81 web-server: online since 2007, running since dec. 2020 using ZeddyNet hardware
http://zx81.ddns.net/ZxTeaM
User avatar
zsolt
Posts: 214
Joined: Wed Apr 20, 2011 11:43 am
Location: Fót, Hungary

Re: Let's calculate! - renewed arithmetic routines

Post 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" :D is still under construction.
Zsolt
ZX81 (8K), ENTERPRISE 128, [ZX SPECTRUM (48K,+,+128K,+2,+2A), TS1000, TS1500, TS2068, Cambridge Z88, PRIMO A64 (red)]
User avatar
siggi
Posts: 1029
Joined: Thu May 08, 2008 9:30 am
Location: Wetterau, Germany
Contact:

Re: Let's calculate! - renewed arithmetic routines

Post 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" :D is still under construction.
Zsolt
Using that "Big Bang" version the Zeddy then can execute an endless loop within less than 3 seconds. Correct?

:mrgreen:
Siggi
My ZX81 web-server: online since 2007, running since dec. 2020 using ZeddyNet hardware
http://zx81.ddns.net/ZxTeaM
Post Reply