Variable error in Hex entry program

The place for codemasters or beginners to talk about programming any language for the Spectrum.
Post Reply
stevie232323
Drutt
Posts: 4
Joined: Sun May 05, 2019 6:06 pm

Variable error in Hex entry program

Post by stevie232323 »

Hi all. My name is Steve. I am a long term Sinclair lover and have a nice collection of hardware including around 4 rubber key 48s, one 48 with a HI/LO keyboard, several interfaces including a Multiface, a MIDI interface mongst other and an Opus Discovery One disc interface (fully working. I love it.)
I have gone from just playimg games to wanting to start learning machine code properly. I have started reading the book "Cracking the code on the ZX Spectrum" by John Wilson.
I have entered a hex entry program which asks for an address which you enter in hex and then start inputting the program. I have entered and checked the entry code but after it asks me for the address (which I do) it then throws me a 2 Variable not found error on line 170. I am hoping someone could help me in finding where the typo is in the program. I've included a copy of it. I've checked it over twice but cant see the fault. Please help ..
Thanks,
Steve.S




Image

Image
User avatar
PeterJ
Site Admin
Posts: 6878
Joined: Thu Nov 09, 2017 7:19 pm
Location: Surrey, UK

Re: Variable error in Hex entry program

Post by PeterJ »

Hi [mention]stevie232323[/mention]

That's a great book. What address are you entering, and what listing are you trying?

Are you typing this in on an emulator? If so upload the .tap file to Dropbox or similar and post it here.

Are you sure it's line 170? That looks like a Gosub?..

Finally, although it's a bit old in the tooth, ZXSpin which is an emulator has a built in assembler which makes things much easier. You also have the option of Pasmo, and other PC based assemblers. I used Pasmo when working through that book.
stevie232323
Drutt
Posts: 4
Joined: Sun May 05, 2019 6:06 pm

Re: Variable error in Hex entry program

Post by stevie232323 »

Hi [mention]PeterJ[/mention] :D

Oops. Its line 270!!
Yeah it is a great book. I got a load of Spectrum books and hardware gear in a house clearance a couple of years ago!!
I also got 2 copies of Super Charge your Spectrum.
I'm not a ZX newbie, in fact, my 1st computer was a 1K ZX81 in 1984. I have loads of love for the ZX81 and the Spectrum.
The program is the Spectrum Monitor program with the listing on pages 77 / 78.
Yeah I am using an emulator. Im using Speccy 5.1 which is OK but lacking in debugger utilities...
I dont understand the error.
I'll look in to ZXSpin. Thanks. :)
User avatar
1024MAK
Bugaboo
Posts: 3123
Joined: Wed Nov 15, 2017 2:52 pm
Location: Sunny Somerset in the U.K. in Europe

Re: Variable error in Hex entry program

Post by 1024MAK »

This line:

Code: Select all

270 LET l=FN x(2): IF l>15 THEN LET e=1
:?:

Mark
:!: Standby alert :!:
“There are four lights!”
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb :dance
Looking forward to summer later in the year.
stevie232323
Drutt
Posts: 4
Joined: Sun May 05, 2019 6:06 pm

Re: Variable error in Hex entry program

Post by stevie232323 »

Yep. Line 270.
I can't see where the error is. Because my BASIC has rusted over the years... :?
It appears lines 270 and 280 form part of the numbers for the address... but I dont know where the 2 error is thrown...
User avatar
1024MAK
Bugaboo
Posts: 3123
Joined: Wed Nov 15, 2017 2:52 pm
Location: Sunny Somerset in the U.K. in Europe

Re: Variable error in Hex entry program

Post by 1024MAK »

After the error, can you try this:

Code: Select all

PRINT a$
Mark
:!: Standby alert :!:
“There are four lights!”
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb :dance
Looking forward to summer later in the year.
User avatar
1024MAK
Bugaboo
Posts: 3123
Joined: Wed Nov 15, 2017 2:52 pm
Location: Sunny Somerset in the U.K. in Europe

Re: Variable error in Hex entry program

Post by 1024MAK »

The function x() in line 310 cannot be calculated because at the point that line 270 calls function x(), no value has been assigned to a$.

This appears to be an error in the listing.

Try changing line 170 to

Code: Select all

170 GO SUB 220
Then try again...

Mark
:!: Standby alert :!:
“There are four lights!”
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb :dance
Looking forward to summer later in the year.
User avatar
1024MAK
Bugaboo
Posts: 3123
Joined: Wed Nov 15, 2017 2:52 pm
Location: Sunny Somerset in the U.K. in Europe

Re: Variable error in Hex entry program

Post by 1024MAK »

Line 290, the last character should be a lower case L and not a 1.

Mark
:!: Standby alert :!:
“There are four lights!”
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb :dance
Looking forward to summer later in the year.
stevie232323
Drutt
Posts: 4
Joined: Sun May 05, 2019 6:06 pm

Re: Variable error in Hex entry program

Post by stevie232323 »

YES!! Thanks 1024MAK . :D . 2 Typos in the text. The first going to a wrong subroutine. The second getting a character wrong making the start address wrong. Your deductions are right! Thankyou.
Now I can enter the 5 pages of Opcodes and get the monitor working. :)
User avatar
1024MAK
Bugaboo
Posts: 3123
Joined: Wed Nov 15, 2017 2:52 pm
Location: Sunny Somerset in the U.K. in Europe

Re: Variable error in Hex entry program

Post by 1024MAK »

No problem (well, not now!) :D

It did have me scratching my head for a bit...

Mark
:!: Standby alert :!:
“There are four lights!”
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb :dance
Looking forward to summer later in the year.
User avatar
PeterJ
Site Admin
Posts: 6878
Joined: Thu Nov 09, 2017 7:19 pm
Location: Surrey, UK

Re: Variable error in Hex entry program

Post by PeterJ »

Nice one @1024MAK
Post Reply