PocketMatrix forums

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

assembler on the ipaq

Been doing some PocketPC coding lately and I'm beyond intruiged... but being a vetern PC coder (especially in ASM) I was pretty pissed that eVC can't do inline assembler. So... how do you gurus write asm for the PocketPC?

Thanks

Cardinal
I've made some notes last time I worked with ARM-asm. These are the things that a typical x86 programmer will run into when switching to ARM.

Hope it helps you a bit.

I don't know if the division macro works, but it shows the general syntax of it.




  • Loading of Constants into Registers

    Arbitary Constants:

    Code:
    ldr register, =0xdeadbeef

    stores constant in the code-section and does a pc-relative load. Can be used for every constant.

    Shiftable Constants:

    Code:
    mov register, #constant

    constant must be representable by a byte (imm8) and a shift-value

    Combined Constants:

    Code:
    mov register, #constant:AND:0xff00
    orr register, register, #constant:AND:0x00ff



  • Access of Variables declared in the Data-Section

    Accesss from Assembly Language:

    Code:
    AREA .data, DATA ; declare Data-Area

    TestVariable DCD 0 ; Declare a WORD labled "TestVariable"

    AREA .text, DATA, ARM ; declare Code-Area

    ldr r0, =TestVariable ; Get Address (linker will generates the relocatable in code-segmen)
    ldr r1, (r0)

    Access from C or C++

    extern "C" extern long TestVariable;


  • Working Example of an Macro

    Labels must follow the $label.identifier pattern.
    If you use labels you must define a unique label when you invoke the macro

    Unsigned division macro declaration:

    Code:

    MACRO
    $label udiv $num, $denum, $tmp1, $tmp2

    clz $tmp1, $num
    clz $tmp2, $denum
    subs $tmp2, $tmp2, $tmp1
    mov $tmp1, #0
    bmi $label.ende
    mov $denum, $denum, LSL $tmp2
    $label.nextbit
    cmp $num, $denum
    subcs $num, $num, $denum
    orrcs $tmp1, $tmp1, #1
    movpl $tmp1, $tmp1, LSL #1
    movpl $denum, $denum, LSR #1
    bpl $label.nextbit
    subs $tmp2, $tmp2, #1
    $label.ende
    mov $num, $tmp1
    MEND


    Unsigned division Macro invocation:

    Code:
    anylabel udiv r0, r1, r2, r3


    The used label (anylabel in this case) must not be used twice


  • Definition of Structures

    Definition:

    Code:
    ^ 0 ; don't know exactly..
    drdx # 4 ; reserve space for a word, name it drdx
    dgdx # 4 ; reserve space for a word, name it dgdx
    dbdx # 4 ; reserve space for a word, name it dbdx
    dudx # 4 ; reserve space for a word, name it dudx
    dvdx # 4 ; reserve space for a word, name it dvdx
    PolyVarSize equ @ ; define symbol with structure size..



    Usage:

    Code:
    AREA .data, DATA ; declare Data-Area

    PolyVars % PolyVarSize ; allocate space for a structure, name it PolyVars





  • Setting up eVC Custom Build Step

    Command:

    armasm -CPU XSCALE -32 -list (IntDir)\$(InputName).lst $(InputDir)\$(InputName).asm $(IntDir)\$(InputName).obj

    Outputs:

    $(IntDir)\$(InputName).obj


  • Place a Breakpoint in an Assembler Module

    Command:

    Code:
    DCD 0xe6000010