Incbin?

Por Chilly Willy

Expert (108)

imagem de 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:

jack:
incbin "blah.rom"

Then manipulate jack later.

thanks...

Entrar ou registrar-se para comentar

Por Daemos

Prophet (2169)

imagem de 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)?

Por mcolom

Champion (320)

imagem de 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.

Por Chilly Willy

Expert (108)

imagem de 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 HL, DANNY
LD DE, EC00
LD BC, 2048
LDIR

ORG EC00
DANNY:
Incbin "blah.rom"

Por NYYRIKKI

Enlighted (6092)

imagem de 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

	LD HL,DATA
	LD DE,DEST
	LD BC,DATA_END-DATA
	LDIR
	RET

DATA:
	DB "HELLO WORLD!"
DATA_END:

Por Chilly Willy

Expert (108)

imagem de Chilly Willy

21-01-2023, 13:01

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

Por aoineko

Paragon (1137)

imagem de 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.

Por Accumulator

Champion (351)

imagem de 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.