Page 1 of 3

Difference between New rom and Old Rom

Posted: Mon Nov 05, 2018 8:22 pm
by Crayon21
I was reading the zx81 manual and am confused about 2 things:

1. how was assembly done (Tried to ask the same thing on AtariAge, turned into a clusterf**k), what are some code examples?
2. What is the difference between New Rom and Old Rom and how does it affect Basic?

thanks in advance

Re: Difference between New rom and Old Rom

Posted: Mon Nov 05, 2018 9:15 pm
by McKlaud
regarding your second question, try these:

Code: Select all

PRINT PEEK 3823

PRINT SQR 0.25

PRINT 0.25 ^ 2

PRINT 4 - 0.0000000001

PRINT SQR 0.0625
If you have Zeddy with the bugged ROM results might surprise you.

Re: Difference between New rom and Old Rom

Posted: Mon Nov 05, 2018 10:13 pm
by mrtinb
There is a problem using the term old and new. What happens after that? The new new ROM?

Old and new ROMs have been used to describe ZX80 ROM and ZX81 1st ROM. This was because the ZX80 could use original ROM or the new ZX81 ROM. You can see this in the book Mastering Machine Code on your ZX80/ZX81.

Later - old and new ROM was used to describe the buggy and fixed ROM for the ZX81.

Re: Difference between New rom and Old Rom

Posted: Mon Nov 05, 2018 10:25 pm
by desiv
Crayon21 wrote: Mon Nov 05, 2018 8:22 pm1. how was assembly done (Tried to ask the same thing on AtariAge, turned into a clusterf**k), what are some code examples?
I don't have any answers, sorry.
But I can see why you are asking...
It is confusing...
This is a er.. um. quirky?? system..

First I learn that you can't actually save your programs/data. You save the machine state???
That makes it interesting, including how you would code on the ZX81.. How would a ZX81 assembler package work? I am intrigued...
Second, I have seen some examples of assembler in BASIC, and it is... um... er.. quaint?? ;-)
You put your code in a REM statement at the top of the program and then call a function that calls the data in that memory location??????
(That could be wrong, but it looked like it..)

I will be watching this thread to see what people who actually know say about this..

(These type of things make me appreciate this machine all the more!!!)

Re: Difference between New rom and Old Rom

Posted: Tue Nov 06, 2018 1:34 am
by 1024MAK
Ahh, let the confusion start :lol:

First there was the ZX80. It had a ROM that was 4K bytes in size. It could only handle integer numbers.
Sinclair then developed the ZX81, but arranged for the ROM to be compatible with the ZX80. This ROM is 8K bytes in size and BASIC now uses floating point numbers. Hence at this point in time, some people referred to the ZX80 ROM as the ‘old’ ROM, and the ZX81 ROM as the ‘new’ ROM. As now referring to the ZX80 ROM was rather ambiguous, as the ZX80 now could be running the original ZX80 ROM or the ‘new’ ZX81 ROM... (and a lot of ZX80 owners did upgrade).

That was all fine and good. Until it was discovered that there was an error in the ROM that caused some mathematical results to be very wrong. Sinclair found a hardware “work around”, but later produced a corrected “bug fixed” ROM. So to ZX81 owners, this was a ‘new’ ROM and the buggy ROM was the ‘old’ ROM...

Although BASIC has a function to call machine code programs, there is no other “official” support for machine code.
There are a number of places where a machine code program can be put. The most common place for short machine code routines that will be used from BASIC is indeed in a REM line at the beginning of the BASIC program. This is convenient and simple, as then the address of the memory locations are known. And BASIC will not mess with the machine code. So the machine code is safe (well, unless a user edits that REM line...).

There are other places where machine code can be put. But these other places have disadvantages.

If there is never going to be a return to BASIC from the machine code program, then the machine code program can take over nearly all the RAM.

SAVE does save the BASIC program. It also saves the variables. And some of the system memory (called the “system variables”). If the machine code is in any of these areas, it will be saved as part of the BASIC program. There are no other SAVE commands available from BASIC. But it is possible for a machine code program to be written to save other memory areas.

Mark

Re: Difference between New rom and Old Rom

Posted: Tue Nov 06, 2018 2:01 am
by 1024MAK
Which ROM and hardware “workaround” (if any) you have in your ZX81 can be determined by executing two BASIC instructions and comparing the results to the figures shown:
below:

Code: Select all

                    Edition 1     Edition 1 &    Edition 2
                                 Hardware Fix
PRINT PEEK 3823        33            33             205
PRINT SQR 0.25      1.3591409        0.5            0.5
(Above table copied from Paul’s website www.fruitcake.plus.com).

Where Edition 1 is the first ZX81 ROM, Edition 2 is the second (bug fixed) ROM.

Mark

Re: Difference between New rom and Old Rom

Posted: Tue Feb 05, 2019 4:40 am
by Crayon21
Now that that is out of the way, how do I input this:

Hl,BC
HL(BC)
LD A,24
on the ZX81
please list an example

Re: Difference between New rom and Old Rom

Posted: Tue Feb 05, 2019 7:32 am
by mrtinb
I assume you want the answer to be in the beginner's class, so here we go:

Back in the day, you could either buy an assembler made by someone else, or you could code with paper and pen first. Most people coded with paper and pen to start with.

There's no Z80 statement for LD HL,BC so that has to be LD H,B LD L,C. Then we find the value for that instruction in Appendix A of the user manual: ZX81 Basic Programming. So our paper begins with:

Code: Select all

Assembler : Code
..........:......
LD H,B    :   96
LD L,C    :  105
LD HL,(BC) has no instruction on the Z80 either, so we make it in more steps. The HL register is used very much so we create the content for HL in the DE register, and swap them in the end. And HL is the only register that can be used indirectly e.g. (HL), so we use that instead of BC. Back to paper:

Code: Select all

Assembler : Code
..........:......
LD E,(HL) :   94
INC HL    :   35
LD D,(HL) :   86
EX DE,HL  :  235
If this was the actual code it wouldn't make much sense as we have just overwritten the content of HL we just created on paper above.

In the last statement LD A,24, I assume you mean 24 decimal. This instruction is two bytes, as the first byte is instruction and second byte is data. So on paper:

Code: Select all

Assembler : Code
..........:......
LD A,24   :   62
          :   24
We could now enter the program into the computer like this:

Code: Select all

 10 REM XXXXXXXX
 20 POKE 16514,96
 30 POKE 16515,105
 40 POKE 16516,94
 50 POKE 16517,35
 60 POKE 16518,86
 70 POKE 16519,235
 80 POKE 16520,62
 90 POKE 16521,24
100 LET Y=USR 16514
The 8 X'es in line 10 is where we store our program. And the address of the first X is 16514. In line 100 we call the machine language at this address. This program will crash though, as it misses the instruction RET to return to Basic.

Next step is to use a HEX-loader program like described in Usborne's: Machine Code for Beginners page 24+48. Can be downloaded here at the bottom of the page: https://usborne.com/browse-books/featur ... ing-books/

Or in Toni Baker's: Mastering Machine Code on Your ZX81 page 12. That chapter is reproduced in HTML here: http://www.users.waitrose.com/~thunor/m ... ter02.html

Re: Difference between New rom and Old Rom

Posted: Fri Apr 05, 2019 2:08 am
by Crayon21
mrtinb wrote: Tue Feb 05, 2019 7:32 am I assume you want the answer to be in the beginner's class, so here we go:

Back in the day, you could either buy an assembler made by someone else, or you could code with paper and pen first. Most people coded with paper and pen to start with.

There's no Z80 statement for LD HL,BC so that has to be LD H,B LD L,C. Then we find the value for that instruction in Appendix A of the user manual: ZX81 Basic Programming. So our paper begins with:

Code: Select all

Assembler : Code
..........:......
LD H,B    :   96
LD L,C    :  105
LD HL,(BC) has no instruction on the Z80 either, so we make it in more steps. The HL register is used very much so we create the content for HL in the DE register, and swap them in the end. And HL is the only register that can be used indirectly e.g. (HL), so we use that instead of BC. Back to paper:

Code: Select all

Assembler : Code
..........:......
LD E,(HL) :   94
INC HL    :   35
LD D,(HL) :   86
EX DE,HL  :  235
If this was the actual code it wouldn't make much sense as we have just overwritten the content of HL we just created on paper above.

In the last statement LD A,24, I assume you mean 24 decimal. This instruction is two bytes, as the first byte is instruction and second byte is data. So on paper:

Code: Select all

Assembler : Code
..........:......
LD A,24   :   62
          :   24
We could now enter the program into the computer like this:

Code: Select all

 10 REM XXXXXXXX
 20 POKE 16514,96
 30 POKE 16515,105
 40 POKE 16516,94
 50 POKE 16517,35
 60 POKE 16518,86
 70 POKE 16519,235
 80 POKE 16520,62
 90 POKE 16521,24
100 LET Y=USR 16514
The 8 X'es in line 10 is where we store our program. And the address of the first X is 16514. In line 100 we call the machine language at this address. This program will crash though, as it misses the instruction RET to return to Basic.

Next step is to use a HEX-loader program like described in Usborne's: Machine Code for Beginners page 24+48. Can be downloaded here at the bottom of the page: https://usborne.com/browse-books/featur ... ing-books/

Or in Toni Baker's: Mastering Machine Code on Your ZX81 page 12. That chapter is reproduced in HTML here: http://www.users.waitrose.com/~thunor/m ... ter02.html
(sigh) is there an assembler for the zx81 already out there? Can't imagine having to do this by hand. What i need is a Z80 to BASIC table (I.E LD,BC becomes poke 121,4 or something like that. Why the author never included a built in assembler, i will never know

Re: Difference between New rom and Old Rom

Posted: Fri Apr 05, 2019 7:38 am
by RetroTechie
Anyone know where I can find a copy of the old/buggy ZX81 ROM? Some emulators include a ZX81 ROM, and @ one point long ago I typed in the bytes one-by-one from a real ZX81 into a floppy-equipped machine. But that's all the 'new' ZX81 ROM, don't seem to have the buggy version around.
Crayon21 wrote:(sigh) is there an assembler for the zx81 already out there?
Any Z80 assembler can do the job. For small programs, use eg. a PC, write some code in a plain text editor, save, and run through the assembler. Instruct the assembler to produce a listing-file (see manual for that assembler). Then on the (emulated or real) ZX81, type in / load a small program to input those bytes, POKE into memory somewhere, and execute.

For bigger programs, have a look at how ZX81 RAM is organized. Then you can format the assembler output to appear as a .p file for testing on an emulator. When satisfied, you could run through a .p -> .wav utility, and use for example a smartphone to load into a real ZX81.

For what it's worth: for small enough programs, the pen & paper method isn't that bad, and a great way to learn how Z80 assembly is encoded binary (and for example how relative jumps are calculated, how many bytes instructions use, low byte/high byte ordering, IX/IY prefixes, etc). Bonus points for T-cycle counting. :lol: