Warning
You're browsing the old v2.x documentation. This version is no longer maintained. Click here to go the v3.x documentation.
ORIGIN
Syntax:
origin <int number address>
The ORIGIN
command instructs the underlying assembler to compile subsequent code or data to a new address instead of the current address.
- If the new address is less than the current address, the program won't compile.
- If the new address is greater than the current address, the gap between the current and new address will be filled in with $FF bytes.
The ORIGIN
command can take a decimal or hexadecimal address, but no variables, constants or expressions are allowed here.
Example:
rem -- the program starts here goto start incbin "sprites.bin" origin $3800 incbin "charset.bin" origin $4000 start: rem -- the actual code starts here print "welcome to my game"
In the example above, sprite data will start right after the GOTO
statement. The gap between the sprites and the charset will be filled with $FF-s.
It is very important that the program code must never execute the empty gaps between the different “segments” that you define with ORIGIN
, because that would lead to a crash. Consider the following example:
rem -- segment #1 print "hello world" origin $1000 rem -- segment #2 print "hello again"
The above program will break if there is a gap between the two segments. The good practice is the following:
rem -- segment #1 print "hello world" goto seg2 origin $1000 rem -- segment #2 seg2: print "hello again"