Page 1 of 2

Started learning Machine code: Am i doing this correctly?

Posted: Tue Nov 05, 2019 2:00 am
by Crayon21
For zx81/TS1000 with 2k expansion
This is the code:
5 clear
10 let a=usr 3000
15 rem A9 C2 B1 00 4E c9
run (just a precaution)
rand usr 3000

and this is the error
C/10

any ideas? I'm using the Eightyone Emulator

Re: Started learning Machine code: Am i doing this correctly?

Posted: Tue Nov 05, 2019 4:21 am
by XavSnap
Hi Crayon21,

It strange ! The USR must throw the BC register in A value.
May be something wrong on a … forgotten "C9".

1) "CLEAR" erase the Vars values (all varaibles), not the memory.
On Spectrum, the "Clear" is used to set the Basic memory segment/memory… but, not on the ZX81.
2) Let A=USR 3000... Why the 3000 memory offset?
3) The rem location is unknown in the memory, you had to place it in the first Basic line. (located at 16514)
4) REM HELLO … Steel "HELLO". You had to POKE ALL values in memory.
5) … The ZX81 can't speek the hexadecimal ! REM C9 is a text oppcode.
6) RUN ? No crash?
7) RAND USR run the garbage located in 3000 (decimal)… the REPORT-B subroutine, in the ROM Basic monitor.
8) The C/10 will be displayed using RUN !

1 REM xxxxxxxxxxxxxxxxx
2 POKE 16514,169
3 POKE 16515,194
4 POKE 16516,177
5 POKE 16517,0
6 POKE 16518,78
7 POKE 16516,201
20 LET A=USR 16514

Code: Select all

16514   A9               XOR A,C              
16515   C2;B1;00         JP NZ,$00B1         ; []*BIOS ROM*
16518   4E               LD C,(HL)            
16519   C9               RET                  
:roll:
It's the very beginning of course.

Re: Started learning Machine code: Am i doing this correctly?

Posted: Tue Nov 05, 2019 4:35 am
by Crayon21
i honestly can't tell if that's sarcasm or genuine annoyance?

Never been good with MC, so kindly explain the process

Re: Started learning Machine code: Am i doing this correctly?

Posted: Tue Nov 05, 2019 6:32 am
by mrtinb
I don’t see any sarcasm.

I would recommend the book Machine Code for beginners, that learns both Z80 and 6502 machine code for any 8-bit micro. Or Mastering Machine Code on Your ZX81 that specifically targets the ZX81.

Re: Started learning Machine code: Am i doing this correctly?

Posted: Tue Nov 05, 2019 6:35 am
by Crayon21
mrtinb wrote: Tue Nov 05, 2019 6:32 am I don’t see any sarcasm.

I would recommend the book Machine Code for beginners, that learns both Z80 and 6502 machine code for any 8-bit micro. Or Mastering Machine Code on Your ZX81 that specifically targets the ZX81.
I will take a look at Machine code for beginners, seeing as Mastering Machine code is of questionable quality. Besides, could not get draughts to work

Re: Started learning Machine code: Am i doing this correctly?

Posted: Tue Nov 05, 2019 8:55 am
by Lardo Boffin
Mastering Machine Code is a great book. Admittedly I never typed in any of the listings so there could be syntax errors in there (or its possible you mistyped something) but what it teaches is good and covers the idiosyncrasies of the ZX81 nicely.

Re: Started learning Machine code: Am i doing this correctly?

Posted: Tue Nov 05, 2019 8:58 am
by mrtinb
The online version I linked to, should have all the typos corrected.

Re: Started learning Machine code: Am i doing this correctly?

Posted: Tue Nov 05, 2019 2:15 pm
by Moggy
It should be noted crayon21 that not all members are native English speakers/writers so sometimes the posting style can seem strange but rest assured XavSnap is amongst the most helpful and knowledgeable on the forum as is Martin who supplied the two very good links.


Mastering machine code on your ZX80/81 is riddled with errors and as stands the draughts program doesn't work also the ROM maths routines are incorrect in places.

The link Martin has provided is for a corrected version of the book which I had the privilege of providing the correct ROM addresses for the maths routines, I suggest you look there for simple examples of coding but would really recommend the other link Machine code for beginners again kindly supplied by Martin.

Re: Started learning Machine code: Am i doing this correctly?

Posted: Tue Nov 05, 2019 3:51 pm
by mrtinb
It should be noted that many of the beginner computer books from Usborne Publishing from the 80'ies can be downloaded freely from their page: https://usborne.com/browse-books/featur ... ing-books/

Half down the page under the subtitle 'Usborne 1980s computer books' you can download PDFs of the old books they have released for the public.

Re: Started learning Machine code: Am i doing this correctly?

Posted: Tue Nov 05, 2019 8:33 pm
by blittled
I found a link to a pdf of a book that contains Z80 routines and a description on how to use assembly language that may be helpful. http://www.bitsavers.org/pdf/osborne/bo ... s_1983.pdf