Compiling error? Ram vs Rom

By Chilly Willy

Resident (56)

Chilly Willy's picture

12-05-2021, 05:45

I use TNIASM and have had plenty of success in creating very basic stand alone roms.

However, I tried something new this time.

I defined a 2k of ram to use as a buffer and when I compiled it it then added 2k to the size of the rom.

This is basically what I have done

ORG RAMSTART

MAP_ROOM: DS 2 ; Current Room
LEVEL_RAM: DS 1 ; Select Level
DIRECTION: DS 1 ; Direction of Travel
WALL_PATTERN: DS 1 ; Wall Pattern
BARRIER_PATTERN: DS 1 ; Barrier Pattern

Temp_Ram: DS 2048 ; Buffer Space

One would think that RAM is grabbed once the program is running and not grabbing 2k within the cartridge area itself.

Are there commands that I am missing that I need to add to the compiler?

Login or register to post comments

By ToriHino

Paladin (710)

ToriHino's picture

12-05-2021, 06:19

To reserve space (so not include it in the binary itself) you should use RB or RW:

2.5.11 RB/RW

        Reserve a (number of) byte(s)/word(s) as uninitialised data. This
        is basically the same as DS, but does not update the file position,
        neither does it output anything. It merely updates the assembly
        position. RB and RW are useful when declaring variables in RAM.

                ORG     0C000h
        Var1:   RB      2               ; Var1 = 0C000h
        Var2:   RW      1               ; Var2 = 0C002h
        Var3:   RB      0               ; Var3 = 0C004h
        Var4:   RW      -1              ; Var4 = 0C004h because zero and
                                        ; negative values are ignored

By Chilly Willy

Resident (56)

Chilly Willy's picture

12-05-2021, 06:56

Sweeeeeeeeeet

By ro

Scribe (4421)

ro's picture

12-05-2021, 07:55

So, wouldn't that be the same as using EQU on labels?

By Manel46

Hero (625)

Manel46's picture

12-05-2021, 08:16

Yes

Var1: equ 0c000h ;2 bytes
Var2: equ Var1+2 ;1 byte
Var3: equ Var2+1
etc

By ToriHino

Paladin (710)

ToriHino's picture

12-05-2021, 10:30

Yes you can use EQU, but the advantage of RB/RW is that you don't need to 'calculate' the address values, meaning with EQU you need the size of the previous variable to define your next. But I agree, it's not a big difference.

Glass provides similar functionality using 'virtual' behind DS.

By Manel46

Hero (625)

Manel46's picture

12-05-2021, 12:35

I use sjasm, which has a neat way of handling this:
MAP 0xC000
var1 #2
var2 #1
var3 #3
etc.
ENDMAP
The notation #n is the number of bytes reserved for each variable.
The ":" are not needed in the sjasm tags.