Started learning Machine code: Am i doing this correctly?

Anything Sinclair ZX Basic related; history, development, tips - differences between BASIC on the ZX80 and ZX81
Crayon21
Posts: 135
Joined: Sun Nov 04, 2018 2:33 am

Started learning Machine code: Am i doing this correctly?

Post by Crayon21 » Tue Nov 05, 2019 2:00 am

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
zx81: great yet flawed
Zx spectrum: masterpiece that keeps on giving

(wish it weren't so expensive) :o

User avatar
XavSnap
Posts: 795
Joined: Sat May 10, 2008 4:23 pm

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

Post by XavSnap » Tue Nov 05, 2019 4:21 am

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.

Crayon21
Posts: 135
Joined: Sun Nov 04, 2018 2:33 am

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

Post by Crayon21 » Tue Nov 05, 2019 4:35 am

i honestly can't tell if that's sarcasm or genuine annoyance?

Never been good with MC, so kindly explain the process
Last edited by Crayon21 on Tue Nov 05, 2019 6:33 am, edited 1 time in total.
zx81: great yet flawed
Zx spectrum: masterpiece that keeps on giving

(wish it weren't so expensive) :o

User avatar
mrtinb
Posts: 1125
Joined: Fri Nov 06, 2015 5:44 pm
Location: Denmark
Contact:

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

Post by mrtinb » 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.
Martin
ZX81, Lambda 8300, Commodore 64, Mac G4 Cube

Crayon21
Posts: 135
Joined: Sun Nov 04, 2018 2:33 am

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

Post by Crayon21 » Tue Nov 05, 2019 6:35 am

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
zx81: great yet flawed
Zx spectrum: masterpiece that keeps on giving

(wish it weren't so expensive) :o

Lardo Boffin
Posts: 1093
Joined: Sat Nov 26, 2016 2:42 am

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

Post by Lardo Boffin » Tue Nov 05, 2019 8:55 am

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.
ZX80
ZX81 iss 1 (bugged ROM, kludge fix, normal, rebuilt)
Iss 3 ZXVid
TS 1000 iss 3, ZXPand AY, ZX8-CCB, ZX-KDLX & ChromaSCART
TS 1500
TS 2000
Spectrum 16k (iss 1 s/n 1499)
Various Spectrum 48ks plus a DIVMMC future and SPECTRA

User avatar
mrtinb
Posts: 1125
Joined: Fri Nov 06, 2015 5:44 pm
Location: Denmark
Contact:

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

Post by mrtinb » Tue Nov 05, 2019 8:58 am

The online version I linked to, should have all the typos corrected.
Martin
ZX81, Lambda 8300, Commodore 64, Mac G4 Cube

Moggy
Posts: 1880
Joined: Wed Jun 18, 2008 2:00 pm

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

Post by Moggy » Tue Nov 05, 2019 2:15 pm

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.

User avatar
mrtinb
Posts: 1125
Joined: Fri Nov 06, 2015 5:44 pm
Location: Denmark
Contact:

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

Post by mrtinb » Tue Nov 05, 2019 3:51 pm

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.
Martin
ZX81, Lambda 8300, Commodore 64, Mac G4 Cube

User avatar
blittled
Posts: 187
Joined: Fri Dec 19, 2008 3:04 am
Location: Northwestern Pennsylvania, USA

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

Post by blittled » Tue Nov 05, 2019 8:33 pm

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
2X Timex Sinclair 1000, ZX81, ZX80Core, 5X 16K Ram Pack, ZXBlast, ZX P file to Ear Input Signal Converter, Elf II

Post Reply