Windless Posted September 7, 2022 Share Posted September 7, 2022 (edited) Hi, When you want to modify code at runtime, the code has to be in RAM. Since RAM is random at switch-on, you need to copy the code from ROM to RAM and then modify it. But its address changes, that's where the RORG instruction comes handy : you can tell the assembler at which place the code will be in memory, so it can use the runtime, not compilation time, addresses. E.G. : RORG $80 ; RORGed address, tells the assembly "compile this code here, but do as if if were as $80" start: nop ; this might physically be at e.g. $1500 jmp .loop ; will compile a jump to $80, no $1500, so this code is ready to be copied in RAM at $80 end: This works fine. You then make a loop with (end-start) iterations to copy this code from $1500 to $80. (end-start) here will be ($84-$80=)$04, and for destination address of course you can use the start label ($80). But for source destination, you can't use start which as been RORGed, so I usually do something like this : physical_start: ; used as source address for the copy to RAM RORG $80 start: ... ; your code goes here end: ; (end-start+1) is the code length so I can now use physical_start as a source address since it has not been RORGed I was wondering if this is usually how people do it, if there are other ways, if some assemblers has a way of getting the physical address for a label (I could not find one in DASM documentation)... Edited September 7, 2022 by Windless Quote Link to comment Share on other sites More sharing options...
+Bruce-Robert Pocock Posted September 7, 2022 Share Posted September 7, 2022 Ref: "some assemblers" 64tass (Turbo Assembler) you'd do basically the same thing as what you wrote: PhysicalAddress: .logical $02 DestinationAddress: Loop: jmp Loop .here where PhysicalAddress might be $f500 and DestinationAddress would be $0002, and jmp Loop would be jmp $0002 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.