ORG, RES and constants in asm
Jasper_M
Posts: 222
1) ORGs and RESs: It seems that org only sets program counter, and doesn't relocate data following it. What's the purpose of this? I'd have used it to insert empty space at the top of my program but I had to add long 0,0,0,0,0,0,0,... RES directive seems to just modify PC also. So: What to do? What's the purpose of ORG and RES if not relocating stuff? Will there be some directives to support relocation in future?
2) Assembly constants: Is there any way of defining a constant in assembly language? Putting them in CON section won't work because what I wanna do is to use constants that have assembly labels in them, eg. data_begin+45 ... I don't want to put them as register contents either because I don't want to waste my valuable RAM... And also, data_begin is followed by my initialization code (that'll be wiped out when I write data over it) so I can't use RES directive. It's not fun to search the whole file for #data_begin+ something always when I want to expand some portion of data (it's divided into sections of different lengths for different stuffs). So what to do? And if there are no assembly constant directives will there be someday?
Thank you in advance. ^_^
EDIT: Removed the "Why they have identical behavior (or am I mistaken)?" question after realizing that RES is relative and ORG absolute.
Post Edited (Jasper_M) : 1/9/2007 12:10:47 PM GMT
2) Assembly constants: Is there any way of defining a constant in assembly language? Putting them in CON section won't work because what I wanna do is to use constants that have assembly labels in them, eg. data_begin+45 ... I don't want to put them as register contents either because I don't want to waste my valuable RAM... And also, data_begin is followed by my initialization code (that'll be wiped out when I write data over it) so I can't use RES directive. It's not fun to search the whole file for #data_begin+ something always when I want to expand some portion of data (it's divided into sections of different lengths for different stuffs). So what to do? And if there are no assembly constant directives will there be someday?
Thank you in advance. ^_^
EDIT: Removed the "Why they have identical behavior (or am I mistaken)?" question after realizing that RES is relative and ORG absolute.
Post Edited (Jasper_M) : 1/9/2007 12:10:47 PM GMT
Comments
This is important because when a COG loads your ASM code. It's pulled from the HUB-RAM into the COG's RAM.
Cog's don't directly execute ASM code from the 32k RAM, but instead execute it from a small 2k RAM (32x512) on the cog running it.
ORG resets the (Program Counter) so the ASM code is compiled with the correct addressing for the 2k COG-RAM.
EDIT: I'm not sure if this is the answer your looking for or if its something else more complex.
Post Edited (Ym2413a) : 1/9/2007 3:25:27 PM GMT
And Ym2413a, that was a partial answer, thank you for that ^__^ It didn't help me right now, but it's gonna save a lot of trouble when I'm gonna put 2 ASM programs in same spin file one day. Ie. thank you. ^.^
Yes. I would use it to reposition my video driver code after a palette. But it won't work. The code after org is really at memory location #1 even though it's preceded by "jmp #Initialize" and "org 128". The PC is reset to 128 anyway. So I did this: "jmp #initialize" and add 127 longs after that. I think it'd be nice if there was a way to do this in a "cleaner" way.
So I can decrease the binary size be replacing the zeroes by copying code. Ok, now I got it. Thank you very much ^^
I'm trying to put an assembly label as a parameter in ORG statement. However, the value that gets as the parameter is not a cog address but an obj address. So they have an offset and are 4 times larger numbers than they should. Does this serve any purpose, or is it a bug or am I just not supposed to do that?