Default origin
Moderator: Moderators
Forum rules
- For making cartridges of your Super NES games, see Reproduction.
- jeffythedragonslayer
- Posts: 344
- Joined: Thu Dec 09, 2021 12:29 pm
Default origin
What is the default origin that ld65 uses if the source doesn't have a .org directive? Is there any way to predict where a variable created with .res will be in memory when not using .org?
Re: Default origin
Do not use .org, that's just bad practise. Do not hardcode memory locations either, access them using the variable's name.
The linker's map file will show you where symbols ended.
The linker's map file will show you where symbols ended.
- rainwarrior
- Posts: 8734
- Joined: Sun Jan 22, 2012 12:03 pm
- Location: Canada
- Contact:
Re: Default origin
In general, you place assembly code in segments (.segment directive), and then in the CFG file used by the linker, the segments are placed at specific locations in the ROM or other memory region.
The default segment is called "CODE". The starting address for that segment will be defined in the CFG you are using.
You can edit your CFG to add new segments at specific addresses if you need to place things. That's more or less the equivalent to ".org" used by other assemblers.
If you need reference: ld65 user's guide
The default segment is called "CODE". The starting address for that segment will be defined in the CFG you are using.
You can edit your CFG to add new segments at specific addresses if you need to place things. That's more or less the equivalent to ".org" used by other assemblers.
If you need reference: ld65 user's guide