PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

asm help again

I'm lost in a (apparently) trivial problem. I have a variable "near enough" my code, in a data pool, and I want to get its contents however I'm unable to find the syntax

i.e. I have this code:
Code:

code_start
ldr r0,[pc,#4]
mov pc,lr

npixels DCD 0x12345678
END

and it works (#4 might be incorrect, I've just put it as example). of course each time I modify the function size I have to readjust all the offsets, which is stupid.

so I'd prefer something like
Code:

code_start
ldr r0,[npixels]
mov pc,lr

npixels DCD 0x12345678
END


but I'm unable to find the correct syntax :( (in evc's builtin assembler)

any ideas?
TIA
Kak
check this thread:
http://www.pocketmatrix.com/forums/view ... hp?t=18096

the solution should be (but i didn't try it):
Code:
ldr r0,[pc,#(npixels-.-8)]
picard wrote:check this thread:
http://www.pocketmatrix.com/forums/view ... hp?t=18096

the solution should be (but i didn't try it):
Code:
ldr r0,[pc,#(npixels-.-8)]


mmm, seems to compile, I'll try as soon as I can get the platform manager ready (it's always giving me lots of problems :( )

Thanks :)
Kak
Depending on the value you're loading, you may be able to synthesize it more cheaply than the load... (assuming it's a constant).
refractor wrote:Depending on the value you're loading, you may be able to synthesize it more cheaply than the load... (assuming it's a constant).


unfortunately it's not constant, but anyway the method/link picard said works flawlessly :)
Kak wrote:
Code:

code_start
ldr r0,[npixels]
mov pc,lr

npixels DCD 0x12345678
END




I found an easy solution :)

Code:

code_start
ldr r0,npixels
mov pc,lr

npixels DCD 0x12345678
END


ldr r0,npixels is translated to ldr r0,[pc,#offset] (it's probably the only way I haven't checked)
thanks. good to know :)