PocketMatrix forums

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

help on this assembler

Hello,

I am trying to implement this assembler routine, but I get several errors. Please help :-)
Code:

mov r0, r12 ; preserve r0, the argument pointer, into scratch register r12
stmdb sp!, {r1} ; preserve r1, the function pointer, onto the stack
ldr r0, [r12]+ ; load argument 0 from the argument pointer and increment the arg pointer by 4
ldr r1, [r12] ; load argument 1 from the argument pointer
ldmia {r12}, sp! ; load the function pointer from the stack, into r12
jmp r12 ; jump to the function pointer in r12

ARM Macro Assembler, Version 12.20.9409
Copyright (C) Microsoft Corporation 1984-2001
c:\vce\bin\test.asm(26) : error A0051: unknown opcode: jmp
jmp r12 ; jump to the function pointer in r12

c:\vce\bin\test.asm(23) warning : A0005: improper line syntax: +
ldr r0, [r12]+ ; load argument 0 from the argument pointer and increment the arg pointer by 4

c:\vce\bin\test.asm(25) : error A0008: ARM register expected: {
ldmia {r12}, sp! ; load the function pointer from the stack, into r12
mov r0,r12 is not r12=r0, but r0=r12

stmdb is stacking onto an empty, descending stack, which is a shame because it should be a full descending

ldr r0, [r12]+ --> ldr r0,[r12],#4 (no +)

ldmia {r12}, sp! makes no sense whatsoever

jmp isn't an ARM instruction at all


You really need to go read up on ARM code, you just can't make stuff up... If you post what you want to do in pseudocode/C/whatever then I'll translate it into ARM for you so you get the idea...
Thanks for your help,

I finally managed to implement what I was looking for in pure C :)