I'm programming for the Sega Mega Drive using vasm 1.7d assembler. I'm copying a block of my code from ROM to RAM so I can do some self-modifying code.
; First $200 bytes are header, dc.b declarations etc. RAM_BEGIN = $00FF0000 entry_point: ; Copy (cool_routine_in_rom_source, cool_routine_in_rom_source+SIZE-1) to RAM_BEGIN lea cool_routine_in_rom_source,a0 lea RAM_BEGIN,a1 move.w #(SIZE-1),d0 copy_loop: move.b (a0)+,(a1)+ dbf d0,copy_loop jmp cool_routine_in_ram_entry_point align 2 cool_routine_in_rom_source = * org RAM_BEGIN cool_routine_in_ram_entry_point: ; Some code here that uses absolute addressing and self-modifying code. cool_routine_in_ram_some_label1: ; code rts cool_routine_in_ram_some_label2: ; code rts align 2 SIZE = (*-cool_routine_in_ram_entry_point)
If I assemble this using the command:
vasmm68k_mot_win32.exe -Fbin -o main.bin main.68k.asm
I get a binary that contains
entry_point then ~16 megabytes of zero padding up to address $00FF0000 then my
Some assemblers (for 6502) let you change the current address while assembling the output consecutively by assigning to
* but I don't think vasm accepts that syntax.
What I want is
cool_routine to be assembled consecutively in ROM, with the second routine (and all labels following it) being assembled as if the PC was at
RAM_BEGIN. What is the correct directive/approach to use?