PocketMatrix forums

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

ASM questions

Hi everybody!

I'm trying to debug a long assembly function with embedded visual C 3.0, using as device an iPAQ 3650 (strongarm), and I've run into some (conceptual) problems when doing so:

the problem is that, in example, my asm function starts at 0x1e01a000, and I've got a pool at 0x1e01a100.
I do an "adr r0,pool" to load the pool address, adr pseudoinstruction turns into a add r0,pc,#f8 (aprox), but r0 incorrectly loads a 0x0001a100 value. (instead of 0x1e01a100)

The problem is afterwards, I do a "ldr r1,[r0]" , and r1 gets the value at [r0] under "step by step" debugging, but when I run it with F5 from the debugger, a memory access error appears (it hangs the iPAQ if executed directly there)

that could be explained with the 26 bits address space, but the problem is I thought Strongarm was no longer using 26 bits address space... and anyway, I don't know if ANDing the address is a feature of strongarm (supposing the 26 bits thingy), or it's a debugger behaviour?

what's happening here? which one of my concepts is wrong? Do I have missed something in the .asm header?

TIA :)
Kak

  1. my asm function starts at 0x1e01a000

    That's the address of your function when it's not been mapped into the "active process" slot.

  2. r0 incorrectly loads a 0x0001a100

    That looks correct to me - when your process runs, it is mapped into "slot 0", i.e. 0x0000 0000 to 0x2000 0000.

    Note that it is also kept mapped in its actual slot. I.e. your "pool" can theoretically be accessed via 0x0001a100 OR 0x1e01a100 - the first is in slot 0, the second in slot 15 (hasty calc).

    The thing is that within the active process you're only allowed to access memory within slot 0 and slot 1 (DLL space). Accessing outside that range will give address exceptions. If you're trying to branch to, or access data from slot 15's pool (0x1e01a100), it'll go <splat> (without special handling).

  3. If the asm compiles and links then there isn't a problem with the headers, etc.

  4. Check your stacking in the prolog and epilog of the assembly function - make sure you're popping the same amount you stacked.

  5. The StrongARM can run in a 26-bit mode, but on the iPAQs it will be running in 32-bit mode.
    (An easy way to test would be to explicitly set the flags using a cmp/tst/teq and dump the PC in hex).

  6. If you want to post the code, I'll have a better look at it.

  7. Oh, last thing, I really don't trust the debugger. It sucks.


HTH,

Ref.
Hi refractor!

thanks for response: I've been having a look again at the code, changed the workarround code to avoid the problem and it misterously worked. It's quite obvious that I changed something that was wrong, however I can't realize what's what I've changed (and why it was working with an ldr + ldr, and not working with add r0,pc,#constant + ldr)

anyway I'm very interested in that issue about
the slots and active process slots (to know the internals of the arm/pocket pc). Do you know of any web/doc talking about it? It seems that arm docs are quite hard to find :(


lots of thanks! :)
Kak
Hi.

When you did:
add r0,pc,#constant

what was your constant? It can only move 4KB (IIRC) backwards or forwards.

There shouldn't really be any ARM specific Windows CE stuff - for ARM documents either go to www.arm.com (for the processor architecture, etc) , or to Intel.com in the case of the XScale.

Anyway, the slot stuff is Window's CE's system, not the ARM's. Googling for info on that is your best bet. I'd google some nice links for you, but google.com is down from here right now.

A search for:
windows ce memory management slots

should turn up some interesting links (there's a PowerPoint .ppt file around somewhere by Douglas Boling that's quite good).

Cheers,

Ref.
refractor wrote:
Hi.

When you did:
add r0,pc,#constant

what was your constant? It can only move 4KB (IIRC) backwards or forwards.


it was arround 200 instructions later (so that's 800 bytes) I did an "adr", which usually calculates the offset with pc+something, and when it's out of scope changes it for an ldr rx,[somewhere in a near pool].
in was in scope and aligned. As you said the problem was probably in another part of code, unfortunately I don't keep a backup of the offending function :(

refractor wrote:

A search for:
windows ce memory management slots

should turn up some interesting links (there's a PowerPoint .ppt file around somewhere by Douglas Boling that's quite good).



great, just having a look right now :)

Thanks :)
Kak