By Chilly Willy

Expert (103)

Аватар пользователя Chilly Willy

20-01-2023, 01:04

Is there a way to incbin to a certain memory address or do you give it a pointer than move it later.

I am thinking org $9000
Incbin "blah.rom"

or a pointer such as:

incbin "blah.rom"

Then manipulate jack later.


Для того, чтобы оставить комментарий, необходимо регистрация или !login

By Daemos

Prophet (2051)

Аватар пользователя Daemos

20-01-2023, 08:29

It strongly depends on your purpose. Do you want to load data from a specific adress (first copied to it) ? Or do you want it to reside physically on a specific adress (cartridge)?

By mcolom

Champion (310)

Аватар пользователя mcolom

20-01-2023, 15:39

I'd say that

org $9000
Incbin "blah.rom"

won't really work. It's just an indication for the assembler to generate code assuming that it starts at that address, but the ORG won't do much when including the file.

The second way makes more sense to me.
Other option is to add some padding in the first case to ensure that your binary actually starts at that position. For example, to add segments in a megarom.

By Chilly Willy

Expert (103)

Аватар пользователя Chilly Willy

21-01-2023, 01:02

I have never used it and just started.
I did not know if there was a way to load it into a specific address location or it was part of the program and you move it after it was assembled.

Ultimately the binary portion is located at EC00 so I would have to org it to that location because the jumps and routines are meant for that area.

so it will probably be something like this...

LD BC, 2048

Incbin "blah.rom"


Enlighted (6033)

Аватар пользователя NYYRIKKI

21-01-2023, 03:04

It does not really matter if you use DB or INCBIN... It is just data. If you ie. have a HELLO.TXT file that contains "HELLO WORLD!" as text you can either do INCBIN "HELLO.TXT" or you can include the data to source file by writing DB "HELLO WORLD!" Once the source is compiled the data is part of your output file and changing source or the HELLO.TXT does not affect the compiled file unless you compile again.

How you get the data to correct address is then another thing, but I would not use ORG. Try ie.

DEST	EQU $9000



By Chilly Willy

Expert (103)

Аватар пользователя Chilly Willy

21-01-2023, 13:01

I never heard of DEST, what is the advantage over using ORG?

By aoineko

Paladin (887)

Аватар пользователя aoineko

21-01-2023, 13:12

DEST is just a constant in the previous exemple.
The adventage of NYYRIKKI method is that you don't need to dicide the data address in advance. The label will tell the linker where your data are located into the final binary.

If your data is formated to work at a given address, this method don't works.

By Accumulator

Master (150)

Аватар пользователя Accumulator

21-01-2023, 14:13

Another way is to disassemble the 'blah.rom' and include, assemble on the memory segment you like.
Also this gives information about the jumps (JP/JR) and used /saved data locations.
If it is using only relational jumps and no fixed calls and no fixed save locations within the routine, you can put it almost anywhere you like.