ZX-IDE and ROMs

Any discussions related to the creation of new hardware or software for the ZX80 or ZX81
Post Reply
nollkolltroll
Posts: 325
Joined: Sat Sep 27, 2014 8:02 pm
Location: Stockholm, Sweden

ZX-IDE and ROMs

Post by nollkolltroll »

Hello all, my first post here, please be gentle.
I've been hacking away at my old ZX81 again these last weeks. It's been a while since last, like 11 years...

I've used ZX-IDE which is really nice, though I quickly stumbled in some places. Here is a description on how to solve a specific problem I had: creating ROMs that are not completely filled with code. An example is perhaps the easiest way to illustrate.
ORG 0
db $ff
ORG 3
db $ff

Most assemblers I've used before would make a binary 4 bytes long, containing $ff, 0, 0, $ff. ZX-IDE makes a 2-byte binary containing $ff, $ff.
The solution looks like this:
ORG 0
db $ff
repeat Last-$
db 0
end repeat
Last:
db $
/Adam
sirmorris
Posts: 2811
Joined: Thu May 08, 2008 5:45 pm

Re: ZX-IDE and ROMs

Post by sirmorris »

A very gentle welcome aboard! Thanks for the tip :D
User avatar
1024MAK
Posts: 5101
Joined: Mon Sep 26, 2011 10:56 am
Location: Looking forward to summer in Somerset, UK...

Re: ZX-IDE and ROMs

Post by 1024MAK »

nollkolltroll wrote:Hello all, my first post here, please be gentle.
:arrow: RED ALERT! :shock: :?
:arrow: Battle stations!
:arrow: Newbie approaching dead ahead! Arm all weapons!

Oh! Your friendly... :oops:

Well, why didn’t you say so ;)

Welcome on board nollkolltroll!

:D :D :D

And thanks for all the fish, sorry, I mean code :mrgreen:

Mark
ZX81 Variations
ZX81 Chip Pin-outs
ZX81 Video Transistor Buffer Amp

:!: Standby alert :!:
There are four lights!
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb :!:
Looking forward to summer later in the year.
David G
Posts: 387
Joined: Thu Jul 17, 2014 7:58 am
Location: 21 North, 156 West

Re: ZX-IDE and ROMs

Post by David G »

Hi, welcome to the club.

DB is "define byte", so the example aboves define two bytes. Result is two bytes long. Some assemblers (but not all) also do other functions with the ORG statement. But here it only defines the origin address of the code that follows.

One helpful feature of ZX-IDE is to press CTRL+F8 which opens a listing after compilation. It will show the addresses used, bytes generated, along with the source code.
nollkolltroll
Posts: 325
Joined: Sat Sep 27, 2014 8:02 pm
Location: Stockholm, Sweden

Re: ZX-IDE and ROMs

Post by nollkolltroll »

Yes, I found CTRL+F8 in the documentation, which is why I could see how the assembler generated things. The way the assembler works is not wrong, just different from what I expected. I did search for quite a while, but I didn't find an answer to my problem. I hope someone else finds my post helpful.
/Adam
User avatar
PokeMon
Posts: 2264
Joined: Sat Sep 17, 2011 6:48 pm

Re: ZX-IDE and ROMs

Post by PokeMon »

Hi,
nice to see you working with ZX-IDE.

Well, normally ORG defines only the runtime address of the following code. I know there are few assemblers handling it different for example Microsoft did so with the ORG 100h for creating executables. I think they would have better created a new statement for this purpose than changing the behaviour of ORG.

Imagine you want to write a code for starting in the first REM line and start with traditional ORG 16514. So what would you then expect ? Creating a binary file with 16514 kByte plus containing zero's in the beginning ?

The programmer has to load the program at the desired address, not the linker which flat assembler doesn't have by the way. That's by the way the reason for calling it flat assembler. It creates a flat binary file.

You may use following alternatives:

For "round" boundaries you can use align statement but it accepts only powers of 2 (2,4,8,16 and so on) which will fill with zero to the next boundary or you can use dw, dd and dq for having 2,4,8 byte distance which may be out of fixed boundaries but require a fixed length:

Code: Select all

                                        org $4000
0000: [4000] FF                         db $ff
0001: [4001] 00 00 00                   align 4h
0004: [4004] FF                         db $ff
0005: [4005] 00 00 00 00 00 00 00 00    align 80h
             00 00 00 00 00 00 00 00    
             00 00 00 00 00 00 00 00    
             00 00 00 00 00 00 00 00    
             00 00 00 00 00 00 00 00    
             00 00 00 00 00 00 00 00    
             00 00 00 00 00 00 00 00    
             00 00 00 00 00 00 00 00    
             00 00 00 00 00 00 00 00    
             00 00 00 00 00 00 00 00    
             00 00 00 00 00 00 00 00    
             00 00 00 00 00 00 00 00    
             00 00 00 00 00 00 00 00    
             00 00 00 00 00 00 00 00    
             00 00 00 00 00 00 00 00    
             00 00 00                   
0080: [4080] 01                         db 1
0081: [4081] FF 00                      dw $ff
0083: [4083] FF 00 00 00                dd $ff
0087: [4087] FF 00 00 00 00 00 00 00    dq $ff
Another way would be writing a macro which does your special wanted output. ;)
Post Reply