HexBlit
HexBlit

Reputation: 1162

Compiling and Running ARM Assembly thumb-2 in Rasperry pi?

I am taking an assembly class and turns out i can't run the Assembly program they gave, due to being Windows 95 compliant x.x

I am running Rasperry PI and can easily run the Assembly for ARM code via

http://thinkingeek.com/2013/01/09/arm-assembler-raspberry-pi-chapter-1/

/* -- first.s */
/* This is a comment */
.global main /* 'main' is our entry point and must be global */
.func main   /* 'main' is a function */

main:          /* This is main */
    mov r0, #2 /* Put a 2 inside the register r0 */
    bx lr      /* Return from main */

$ as -o first.o first.s
$ gcc -o first first.o
$ ./first ; echo $?
2

But this is the standard ARM 32 bit setup and need to compile and run for a thumb-2 setup for example:

    AREA PrintText, CODE, READONLY
SWI_WriteC  EQU &0     ;output character in r0 
SWI_Exit    EQU &11    ;finish program
        ENTRY

        BL  Print   ;call print subroutine
        =   "Text to print",&0a,&0d,0   
        ALIGN
        SWI     SWI_Exit    ;finish
Print       LDRB    r0,[r14], #1    ;get a character
        CMP     r0, #0      ;end mark NUL?
        SWINE   SWI_WriteC  ;if not, print
        BNE Print
        ADD r14, r14, #3    ; pass next word boundary
        BIC r14, r14, #3    ; round back to boundary
        MOV pc, r14     ;return
        END

Does anyone know what I need to in Pi to run this thumb style ? EDIT:

for the commands above I tried adding -mthumb but dont think its right as i dont see any changes.

as -mthumb -o test.o test.s

Upvotes: 0

Views: 1581

Answers (2)

old_timer
old_timer

Reputation: 71576

.code 32 @ stuff after this line is arm code

.globl hello_arm
hello_arm:  @an arm function


.thumb @stuff after this line is thumb

.thumb_func @the next function is a thumb function and called properly
.globl hello
hello: @ a thumb function

Upvotes: 0

Seva Alekseyev
Seva Alekseyev

Reputation: 61388

See if your assembler would take the following line:

AREA PrintText, CODE, READONLY, THUMB

Upvotes: 0

Related Questions