Trying to enter a line from a book fails for some reason

Post Reply
Balrockus
Posts: 1
Joined: Wed Apr 12, 2017 2:26 pm

Trying to enter a line from a book fails for some reason

Post by Balrockus »

I am reading through the book "Spectrum Machine Language for the Absolute Beginner edited William Tang". I have got to the section where I need to enter a program from the book into my emulator (Spectacular). The program is EZ-Code Machine Language Editor The image (book.png) below is a screenshot from the book of the listing. When I try to enter line 130 into my emulator it just errors with a flashing red square "E" (see screenshot emulator.png below).

I have entered line 130 as one whole line into the emulator and it wraps around. Is the problem the last

Code: Select all

(s$ > "`") 
? I am not sure if I have entered the correct character in quotes.

If this is not a question for this forum, could anyone please recommend where I could get some help with Spectrum Basic and Assembly programming please.

Cheers, Paul

Book.png
Book.png (75.55 KiB) Viewed 12822 times

emulator.png
emulator.png (1.8 KiB) Viewed 12822 times
RWAP
Posts: 1337
Joined: Thu May 08, 2008 8:42 am
Location: Stoke-on-Trent, UK
Contact:

Re: Trying to enter a line from a book fails for some reason

Post by RWAP »

(I moved this topic to Spectrum software as I assume you mean using the emulator, Spectaculator).

I suppose this might be a bug in Spectaculator - you need to enter DEF FN using the CAPS SHIFT + SYMBOL SHIFT then SYMBOL SHIFT 1 key combination.

Is that how you did it?

The character in the last set of quotes should be Symbol Shift 7
RWAP
Posts: 1337
Joined: Thu May 08, 2008 8:42 am
Location: Stoke-on-Trent, UK
Contact:

Re: Trying to enter a line from a book fails for some reason

Post by RWAP »

I just tested the line in Eighty One and it enters correctly without reporting any errors (using Symbol Shift 7 as the character in quotes)

I do not have Spectaculator
User avatar
XavSnap
Posts: 1258
Joined: Sat May 10, 2008 4:23 pm
Location: 'Zx81 France' Fb group.

Re: Trying to enter a line from a book fails for some reason

Post by XavSnap »

Yes, RWAP point the right error.

Have a look to the "error" cursor ! It point the syntax error after the command or function.

You typed "D" + "E" + "F" + " " + "F" + "N" and not the "DEF FN" function !

The error cursor is located after the "D"... and not after the "DEF FN" function...
Xavier
harlandski
Posts: 5
Joined: Sun Feb 11, 2018 8:24 am

Re: Trying to enter a line from a book fails for some reason

Post by harlandski »

By the way, I also had a problem with this line of the listing, but for a different reason. The expression:

Code: Select all

(s$  > "'")
was clearly a misprint in the book and should read:

Code: Select all

(s$ > "9")
The function is to parse hexadecimal numbers to decimal, but does not work unless you make this change to the published text.
User avatar
XavSnap
Posts: 1258
Joined: Sat May 10, 2008 4:23 pm
Location: 'Zx81 France' Fb group.

Re: Trying to enter a line from a book fails for some reason

Post by XavSnap »

harlandski wrote: Sat Mar 10, 2018 1:05 am The expression:
(s$ > "'")
was clearly a misprint in the book and should read:
No, this command is correct.
The Basic take the ASCII character's value! (A$ character and ' character)
This command take the first character in the A$ chain.
Capture_spec.JPG
But, the A$ had to be set.
Try to print the A$ value after the reported error... and check if it's a null char. string!

Just try the a$>"/" expression... if target all decimals char. codes.
a$>"@" all hexa (upper case) and a$>"£" (lower case)
Xavier
harlandski
Posts: 5
Joined: Sun Feb 11, 2018 8:24 am

Re: Trying to enter a line from a book fails for some reason

Post by harlandski »

Your reasoning looks amazing, but it just fails to properly parse hex unless you make the alteration I suggest. Before making the change the code was unworkable, and since making it, it works.

Just try a simplified version:

Code: Select all

10 DEF FN d(s$) = (s$ > "9") * (CODE s$-55)+(s$ <= "9") * (CODE s$ - 48) - (s$ > "'") * 32
20 PRINT FN d("9")
30 PRINT FN d("f")
This produces:

-23
15

15 is f in hex, but 9 in hex is not -23!

With my amendment:

Code: Select all

10 DEF FN d(s$) = (s$ > "9") * (CODE s$-55)+(s$ <= "9") * (CODE s$ - 48) - (s$ > "9") * 32
20 PRINT FN d("9")
30 PRINT FN d("f")
This produces the correct:

9
15
Martijn
Posts: 1
Joined: Mon Jan 11, 2021 9:25 pm

Re: Trying to enter a line from a book fails for some reason

Post by Martijn »

Hi,
I typed in this program from the Dutch translation of mr Tang's book.
It did not work very well, fully buggy not debugged since 1984 I think.

When I changed the '-typo to 9 the correct Hex values were given.
10 DEF FN d(s$) = (s$ > "9") * (CODE s$-55)+(s$ <= "9") * (CODE s$ - 48) - (s$ > "9") * 32
So thanks for that!

It was still very buggy and since I have the english translation as well I found more typo's, of myself l and 1 mixups mainly.

Now most of the program seems to work except:

I cannot enter program codes in lines other than the consecutively way:

example: line nr: 14 C9
line nr: 26 E3
It does not change line nr 14 or 26 it only changes (after a Dump) line 1.

When I do it the consecutively way like :
line nr: 01 04
line nr: 02 A4
..
..
line nr: 14 C9

Then it works, so basicly I cannot edit a previously made program, I have to redo it all. Starting with line 1 all the way to the end.
I looked over the code and over and over but cannot find more typo's yet.

Is this a bug? Or just the way this old monitor program works?

Also Loading a previously saved machine code file does not work:
after loading when I press a key, the program ends with a D-break message.
Perhaps a typo or perhaps a known bug by any of you?

Thx.
matalog
Posts: 5
Joined: Thu Feb 18, 2021 5:13 pm

Re: Trying to enter a line from a book fails for some reason

Post by matalog »

It's always tricky when you don't know about the tokenised keys. Try using 128k BASIC, and you can just type the words in, all you have to do is spell them correctly and they will be recognised.
Post Reply