Default origin

Discussion of hardware and software development for Super NES and Super Famicom. See the SNESdev wiki for more information.

Moderator: Moderators

Forum rules
  • For making cartridges of your Super NES games, see Reproduction.
Post Reply
User avatar
jeffythedragonslayer
Posts: 344
Joined: Thu Dec 09, 2021 12:29 pm

Default origin

Post by jeffythedragonslayer »

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?
calima
Posts: 1745
Joined: Tue Oct 06, 2015 10:16 am

Re: Default origin

Post by calima »

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.
User avatar
rainwarrior
Posts: 8734
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Default origin

Post by rainwarrior »

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
Post Reply