PocketMatrix forums

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

ARM question. Direct addressing?

Hi,

I would like to know if it's possible to get the value from an address directly in ARM. I mean right now I am using something like this:

ldr r1, [pc, #0x784]

But if the indirect value becomes more than 0xFFF I am screwed. Can I directly load a value from an address into a register?

ldr r1, 0x1BC23000

Regards,
Kornalius
kornalius wrote:
ldr r1, [pc, #0x784]


You need to get the data area address in the register, which you'll probably pass it unless every model has the value at that address.

ldr r1,[r0,r2]

so r0 is 0x1BC23000, r2 is a relative pointer to it.

You'll learn it quicker if you are using Embedded VC++ go to C/C++ tab in Project Settings under category set Listing Files, then Listing File Type as Assembly with Source Code and you will see lots of example code with comments of the program in C you are writing.

Write a piece of C that does it, then use that function as assembler and modify it.

If you really do want to do this then
mov r0,#0x1b000000
orr r0,r0,#0xc20000
orr r0,r0,#0x3000
ldr r1,[r0,r2]

Which just looks plain mad to me, get it from where the value is.
Hi Jinks,

Thanks for your post but I would like to do something like this:


Load 0xAABBCCDD into r0.

MOV R0, #0xAA000000
ADD R0, R0, #0x00BB0000
ADD R0, R0, #0x0000CC00
ADD R0, R0, #0x000000DD


But I am affraid this is going to slow down things a lot.

Btw, I am writing a compiler and everything was working fine with indirect addressing until my programs got too big.

Regards,
Kornalius
kornalius wrote:
Btw, I am writing a compiler and everything was working fine with indirect addressing until my programs got too big.


Sorry I modified my answer (as I hadn't read all your question).

Damn you are quick!!!

Use a data area, get the data area from a C program passing to a function. SO you use C to do what it does well and Assembler to do what it does well.
Hi Jinks,

I like your idea a lot. But how can I activate assembly in C? I tried with __asm but it doesn't work for ARM only Intel.

Regards,
Kornalius
Can't put ASM in C, IMHO bad idea anyway.

Write a function to do something trivial that you can pass all the value you want to the data blocks.

Example all my ARM code is via something called

int paintthing(unsigned long *start,unsigned long *dest, int par,int pix);

Make a .h and .c/.cpp for this one function and compile your program.

You now have a template of whatever you wrote, your projects from what I've heard is complete so just wait for a mass cut and paste.

Get ARMASM.EXE from wherever you've got it and put it in with all you .cpp files or some place you know.

in my case the file was painter.asm dig it out of debug directory put it up with .cpp. Add it to your files and goto project settings.

Under Custom Build tab set your file painter.asm to have the command.
Full path of ARMASM painter.asm painter.obj , command line style.

Outputs painter.obj

Then take painter.cpp out of the build.

Now you should be able to edit your arm code and have access to your parameters with the code compiling when changed.

Hope that helps with the language generator. I've written a few so I know when you are writing the program that writes the program its not always as simple as the dumb ass app code. Yeah I wrote too much of mine in Assembler thats what makes them dead, along with far too many of my older things.
Boy this look easy! :D

Thanx a lot for your time and information. I will try it.

Regards,
Kornalius
Glad to save you the time of hunting down lots of bits of info here and there. Let you spend time on the language.

Just a thought but if your language is of the from Program given script which compiles then runs it. So some call to the routine prompts
mov r15,r0 after you flush data instruction cache in C.

Don't think you have to stay in Assembler (maybe it's machine code when it's running) all the time. You can always exit with a code that tells 'C' to run a function that is best done or only available in 'C' then jumps back to the code at the exit point to continue with your generated code.
kornalius wrote:I would like to know if it's possible to get the value from an address directly in ARM. I mean right now I am using something like this:

ldr r1, [pc, #0x784]

But if the indirect value becomes more than 0xFFF I am screwed. Can I directly load a value from an address into a register?

ldr r1, 0x1BC23000

Since both of us a implementing a JIT, I am simply telling how I have been solving this problem within the OpenGL implementation: Instead of using a data area, have a constant pool added at the end of each individual function that you compile. Just make sure you have a way to indirectly address into this pool. Then each address or other constant gets stored into a slot within this pool (prefereably use a uniqueness computation to store different bit patterns only once). I am also using this pool to make the addresses of C and operating system functions available.

In the most simplistic implementation (i.e you just add the pool), each individual *function* is limited in size by the range you can reach through indirect addressing relative to the PC. If you need more, you have to build "bridges": Either, you introduce secondary pointers at fixed offsets, or you create a lookup table somewhere. When your procedures get large, you will run into a similar problem for you data area/stack local storage. So its a good idea to design a solution that works for both cases.

Hope that helps,
Martin
Hi hm,

Thanks for your help. I already have this method implemented in my compiler. However the problem I was having was that I was indexing from the pc and not starting from the data area in the first place. I just fixed that today. If you need help you can ask me, my compiler / interpreter are working very well now.

Regards,
Kornalius
kornalius wrote: If you need help you can ask me, my compiler / interpreter are working very well now.

Not immediately. Right now my focus is on passing the OpenGL ES conformance tests. However, I have a couple of items on my list I still want to address, most notably the coordination of instruction scheduling with register allocation, and making more use of the register interference graph and DU-chain analysis during register pre-selection (I'd like to avoid having to solve a full graph coloring problem, but would rather use some form of register targeting to avoid using registers that live across function calls into the set of temp registers). Have you addressed those already? If so, I'd be interested in the approach you took...

Cheers,
HM
most notably the coordination of instruction scheduling with register allocation, and making more use of the register interference graph and DU-chain analysis during register pre-selection (I'd like to avoid having to solve a full graph coloring problem, but would rather use some form of register targeting to avoid using registers that live across function calls into the set of temp registers).


Oooh, I love it when people talk dirty. :mrgreen: Gotta love constraint satisfaction.