message "division by zero error"

Basic and Machine Language

Moderator: Moderators

armypavarmy
Vic 20 Hobbyist
Posts: 107
Joined: Wed Oct 02, 2013 1:54 am
Location: Italy

message "division by zero error"

Post by armypavarmy »

good morning. I am Armando

please help.
Data entered for calculation
parameters for graphics
give this error.
The parameters are right.
in fact, by restarting the run at the second insertion they work
This happens every time you enter the required data, you have to run and re-enter them.
There is a solution to this problem.
Thanks for help ....
wimoos
Vic 20 Afficionado
Posts: 348
Joined: Tue Apr 14, 2009 8:15 am
Website: http://wimbasic.webs.com
Location: Netherlands
Occupation: farmer

Re: message "division by zero error"

Post by wimoos »

Hello Armando,

Can you make that program available to us ?

Regards,

Wim.
VICE; selfwritten 65asmgen; tasm; maintainer of WimBasic
armypavarmy
Vic 20 Hobbyist
Posts: 107
Joined: Wed Oct 02, 2013 1:54 am
Location: Italy

Re: message "division by zero error"

Post by armypavarmy »

sure ..... I prepare the material and then insert ......
Thanks-------Armando
armypavarmy
Vic 20 Hobbyist
Posts: 107
Joined: Wed Oct 02, 2013 1:54 am
Location: Italy

Re: message "division by zero error"

Post by armypavarmy »

Hello
here is the zip file it contains
the graphic program for "Super Expander"
and the link from which I downloaded.
It has pre-entered parameters if you hit return
without any number.
Even with these you have to repeat the run.
Tested with emulator and with real Vic20
Same problem.
Thanks .......... Armando
Spiralizer+ doc.zip
(13.75 KiB) Downloaded 41 times
User avatar
chysn
Vic 20 Scientist
Posts: 1205
Joined: Tue Oct 22, 2019 12:36 pm
Website: http://www.beigemaze.com
Location: Michigan, USA
Occupation: Software Dev Manager

Re: message "division by zero error"

Post by chysn »

If I run this and just hit RETURN at every prompt, I get a five-pointed cloverleaf-like pattern. (Real VIC-20 with Super Expander)
wimoos
Vic 20 Afficionado
Posts: 348
Joined: Tue Apr 14, 2009 8:15 am
Website: http://wimbasic.webs.com
Location: Netherlands
Occupation: farmer

Re: message "division by zero error"

Post by wimoos »

Armando.

What memory configuration are you using ? Line 260 is assuming you have 3.5k or maybe 6.5k, but not +8k or +16k.

What I think happens is that the POKEs in line 260 overwrite the memory space for simple variables, and subsequently Z cannot be found anymore, resulting in Z=0. In line 270 a A(P)=1/Z is performed, resulting in ?DIVISION BY ZERO.

Regards,

Wim.
VICE; selfwritten 65asmgen; tasm; maintainer of WimBasic
armypavarmy
Vic 20 Hobbyist
Posts: 107
Joined: Wed Oct 02, 2013 1:54 am
Location: Italy

Re: message "division by zero error"

Post by armypavarmy »

Hello
Loading the "super expander" program with the FE3 automatically configures all the ram.
I can't make any other choice.
If possible, how to change the program?
Thanks regards Armando
wimoos
Vic 20 Afficionado
Posts: 348
Joined: Tue Apr 14, 2009 8:15 am
Website: http://wimbasic.webs.com
Location: Netherlands
Occupation: farmer

Re: message "division by zero error"

Post by wimoos »

change line 260 to

Code: Select all


260 FOR I=4536 TO 4579 : POKE I,32 : NEXT I

VICE; selfwritten 65asmgen; tasm; maintainer of WimBasic
armypavarmy
Vic 20 Hobbyist
Posts: 107
Joined: Wed Oct 02, 2013 1:54 am
Location: Italy

Re: message "division by zero error"

Post by armypavarmy »

Hello
Made modification indicated.
Same problem.
Saved modified program, I reset everything and reloaded.
Like before. same mistake

......Armando
armypavarmy
Vic 20 Hobbyist
Posts: 107
Joined: Wed Oct 02, 2013 1:54 am
Location: Italy

Re: message "division by zero error"

Post by armypavarmy »

I'll wait for an answer
because the proposed solution does not work. thanks ..... Armando
User avatar
vicist
Vic 20 Afficionado
Posts: 352
Joined: Tue Oct 09, 2012 5:26 am
Location: Sheffield, UK

Re: message "division by zero error"

Post by vicist »

If you select 1 at the 'how many spirals' prompt, you may enter your own parameters into the following prompts.
If you select 2-4 at the first prompt, you have to keep pressing return at every other prompt until the second prompt (spriral figure #) equals the number you chose at the first prompt, then you can enter your own parameters into the following prompts.

I think this is just how the program works.
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: message "division by zero error"

Post by Mike »

viewtopic.php?t=5396&start=59, and to quote from there:
Mike wrote:just for general info: when a graphics screen is activated the first time, SE normally 'lowers the roof' available for the BASIC program and variables down to $0FFF (minus some extra for function key definitions). With +8K RAM or more, the BASIC start is set to $2001 instead, and the program is copied to the higher address, clearing all variables underway.
Emphasis added. That's what happens here (Armando, I take it here you soft-load SE with a full RAM expansion in VICE), which ultimately leads to the ?DIVISION BY ZERO error: the program switches between deactivated/removed graphics area in lines 100..410, and when in line 420 the command GRAPHIC 2 creates the graphics area *and* a bigger RAM expansion is present, all variables are cleared. A better way would be to create the graphics area once, right at the begin, and just change between text and graphics mode with GRAPHIC 0 and GRAPHIC 2, respectively.

I should add, that this issue does not occur with MINIGRAFIK at all: there, the graphics area is already created with the initialisation of MG and stays put as long as MG is active.

It is surely instructive to port the "Spiralizer" program to MINIGRAFIK. :wink:
armypavarmy
Vic 20 Hobbyist
Posts: 107
Joined: Wed Oct 02, 2013 1:54 am
Location: Italy

Re: message "division by zero error"

Post by armypavarmy »

Hello Mike
thanks so much for your unexpected help.
Now the program works.
It's very beautiful.
I would like to bring it to Minigrafik
The problem is that Minigrafik
does not have the command: Draw TO X, Y.
Whenever possible I always adapt graphic programs
with Minigrafik.
greetings ----- Armando
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: message "division by zero error"

Post by Mike »

Hi, Armando,
armypavarmy wrote:The problem is that Minigrafik does not have the command: Draw TO X, Y.
In Super Expander (or BASIC V3.5/V7), the DRAW TO command is just a shortcut where the draw command remembers the previous position of the "graphics cursor" and uses it as start point.

This is done in MINIGRAFIK with two temporary variables XC,YC that are assigned to with the second coordinate pair of any preceding @ draw command, like thus: @<colour>,...,... TO X2,Y2:XC=X2:YC=Y2. Any DRAW TO command then is written as @<colour>,XC,YC TO ...,... - and XC,YC are afterwards updated (again) with the new second coordinate pair.

Note the variable names above are only suggestions. If they clash with existing variables in the program, use other names.

Greetings,

Michael
armypavarmy
Vic 20 Hobbyist
Posts: 107
Joined: Wed Oct 02, 2013 1:54 am
Location: Italy

Re: message "division by zero error"

Post by armypavarmy »

thanks mike
in this listing
example:
first origin with point 1,100,100
after only the draw to x, y command
as I do with Minigrafik
I have to write @ 1,100,100 to x, y
and then ?
I should write @ 1,100,100
and then @ 1 to x, y
but it is not possible.
Minigrafik that I have does not accept
also multiple TO
I don't know how to do it any other way
Thanks Armando
Post Reply