我目前正在研究树莓派,但我的汇编代码遇到了问题。当我尝试使用以下命令运行它时:
as button.o button.s
在终端。出现以下错误:
Assembler messages:
Error: can't open button.o for reading: No such file or directory
button.s:6: Error: bad instruction `errmsg .asciz "Setup didn't work...
Aborting...\n"'
button.s:7: Error: bad instruction `pinup .int 3'
button.s:8: Error: bad instruction `pinleft .int 14'
button.s:9: Error: bad instruction `pindown .int 0'
button.s:10: Error: bad size 0 in type specifier
button.s:10: Error: bad instruction `pinright.int 7'
button.s:11: Error: bad instruction `pinpau .int 15'
button.s:12: Error: bad instruction `pinqu .int 2'
button.s:32: Error: bad instruction `blwiringpisetup'
button.s:48: Error: bad arguments to instruction -- `mov r7#1'
button.s:50: Error: bad instruction `be done'
我不确定这是语法错误还是一般代码有问题。代码如下:
//data Section
.data
.balign 4
Intro: .asciz "Raspberry Pi - Blinking led test inassembly\n"
ErrMsg .asciz "Setup didn't work... Aborting...\n"
pinUp .int 3
pinLeft .int 14
pinDown .int 0
pinRight.int 7
pinPau .int 15
pinQu .int 2
i: .int 0
//Code section
.text
.global main
.extern printf
.extern wiringPiSetup
.extern delay
.extern digitalRead
.extern pinMode
main: push {ip, lr}
// printf message
ldr r0, =Intro
bl printf
//Check for setup error
blwiringPiSetup
mov r1,#-1
cmp r0, r1
bne init
ldr r0, =ErrMsg
bl printf
b done
init:
ldr r0, =pinUp
ldr r1, =pinLeft
ldr r2, =pinDown
ldr r3, =pinRight
ldr r4, =pinPau
ldr r5, =pinQu
mov r6, #1
mov r7 #1
cmp r6, r7
be done
done:
pop {ip,pc}
跟随以下代码的变量声明:
//---------------------------------------
// Data Section
// ---------------------------------------
.data
.balign 4
Intro: .asciz "Raspberry Pi - Blinking led test in assembly\n"
ErrMsg: .asciz "Setup didn't work... Aborting...\n"
pin: .int 0
i: .int 0
delayMs: .int 1000
OUTPUT = 1
任何帮助,将不胜感激。