orbitaldecay Posted May 1, 2016 Share Posted May 1, 2016 (edited) This question is specifically about cartridge development using assembly language. I have noticed with all of the assemblers that I've used, it is necessary to set AORG >6000 at the begining of the file to produce any output (otherwise the resulting binary file is filled with zeros). If I set the origin to >6000 at the begining of the file, then copy some code (say to >2000) and attempt to set AORG >2000 later, the subsequent symbols have the proper values, but the output past the second AORG is all zeros! Does anyone know why this is, or how I can achieve what I am attempting to achieve? If it helps, I'm currently using xa99 for assembling and l99 for linking. Thanks! Edit: I have also tried RORG and DORG, though I admittedly don't really understand what these are supposed to do Edited May 1, 2016 by orbitaldecay Quote Link to comment Share on other sites More sharing options...
+Lee Stewart Posted May 1, 2016 Share Posted May 1, 2016 (edited) I use Asm994a for my fbForth 2.0 cartridge development, which has four banks. I assemble it all as one file with “AORG 6000” at the beginning of each bank. I split it into the separate binaries with @Tursi's DF802BIN, which pads each bank to exactly 8KiB. Regarding the other directives you mentioned, RORG defines a relocatable origin beginning with 0 but marked for relocation to go to the first available block of memory big enough for it. I do not use RORG for cartridge development. DORG marks the beginning of a dummy block meant to be used during assembly—no code is generated. I use it for the User Variable Table in fbForth 2.0. I also load code into RAM from the cartridge; but, I do not AORG it to its location. I can show you how that is done, if you are interested. ...lee Edited May 1, 2016 by Lee Stewart Quote Link to comment Share on other sites More sharing options...
orbitaldecay Posted May 1, 2016 Author Share Posted May 1, 2016 I use Asm994a for my fbForth 2.0 cartridge development, which has four banks. I assemble it all as one file with “AORG 6000” at the beginning of each bank. I split it into the separate binaries with @Tursi's DF802BIN, which pads each bank to exactly 8KiB. Regarding the other directives you mentioned, RORG defines a relocatable origin beginning with 0 but marked for relocation to go to the first available block of memory big enough for it. DORG marks the beginning of a dummy block meant to be used during assembly—no code is generated. I use it for the User Variable Table in fbForth 2.0. I also load code into RAM from the cartridge; but, I do not AORG it to its location. I can show you how that is done, if you are interested. ...lee Hey Lee, thanks for your response. I am quite interested in your method for loading coding into RAM from the cartridge and jumping to it. How do you set the origin of the labels appropriately without using AORG or something similar? Quote Link to comment Share on other sites More sharing options...
+Lee Stewart Posted May 1, 2016 Share Posted May 1, 2016 Hey Lee, thanks for your response. I am quite interested in your method for loading coding into RAM from the cartridge and jumping to it. How do you set the origin of the labels appropriately without using AORG or something similar? Let me see if I can find my previous post with the explanation. If I cannot find it in a few minutes I'll put together a small example and post it here a little later. ...lee Quote Link to comment Share on other sites More sharing options...
+Lee Stewart Posted May 2, 2016 Share Posted May 2, 2016 OK...Here's the example code mentioned in my last post: AORG 6000 <--ROM start ... CDDST EQU >3000 <--destination starting address CDSTRT <--start of code to copy from ROM ... LABEL1 EQU CDDST+$-CDSTRT ... JPLBL1 CLR R0 <--jump target must have a ROM address within reach ... JMP JPLBL1 <--jump to ROM address within reach ... BL @LABEL1 <--branch & link to RAM address where routine moved ... LABEL2 EQU CDDST+$-CDSTRT ... CDEND <--end of code to copy from ROM ... ... * * Copy routine * CPYCOD LI R0,CDSTRT <--source start address LI R1,CDDST <--destination start address LI R2,CDEND-CDSTRT <--copy count CPLOOP MOVB *R0+,*R1+ <--copy next byte DEC R2 JNE CPLOOP <--copy another byte if not done RT The part of the above code that makes it easy to implement is that every EQUated label between CDSTRT and CDEND is defined with the same expression. The only thing that changes is the value of '$'—that is what tracks the destination address. '$-CDSTRT' is the count from the destination starting address, CDDST, to which it gets added. Here are a couple of caveats: The only reference there can be to a ROM label within the block of code (except, of course, the copy routine) is a jump statement because that is used to calculate a distance to jump, not a destination. All other references to locations within the block of code must use EQUated labels within that code. ...lee 1 Quote Link to comment Share on other sites More sharing options...
Asmusr Posted May 2, 2016 Share Posted May 2, 2016 In xas99 you can use XORG to specify that code is assembled at one address but destined for another. So you start with AORG >6000, then XORG >2000 before the code you want to copy to >2000, then AORG without any argument to return to the cartridge code. 2 Quote Link to comment Share on other sites More sharing options...
orbitaldecay Posted May 2, 2016 Author Share Posted May 2, 2016 @Lee: Thanks for posting your example. That way is nice because it doesn't require any assembler specific directives. @Asmusr that's more along the lines of what I was looking for. Too bad it isn't supported in more assemblers. 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.