簡體   English   中英

在Rasperry pi中編譯和運行ARM Assembly thumb-2?

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

我正在上一個匯編類,結果由於與Windows 95兼容,我無法運行他們給出的匯編程序xx

我正在運行Rasperry PI,可以通過以下方式輕松運行ARM代碼的Assembly

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

但這是標准的ARM 32位設置,並且需要編譯並運行以進行Thumb-2設置,例如:

    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

有人知道我需要在Pi中運行此拇指樣式嗎? 編輯:

對於上面的命令,我嘗試添加-mthumb,但由於我看不到任何更改,因此認為它是正確的。

作為-mthumb -o test.o test.s

查看您的匯編器是否采用以下行:

AREA PrintText, CODE, READONLY, THUMB
.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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM