Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Assembly 给出非法指令的ARM代码_Assembly_Arm - Fatal编程技术网

Assembly 给出非法指令的ARM代码

Assembly 给出非法指令的ARM代码,assembly,arm,Assembly,Arm,我在运行代码时遇到非法指令错误。没有编译错误-但即使在调试时,它也会给我这个错误 以下是我目前使用的代码: .global .fopen .global .fclose .global getc .data fin: .word 0x00 r: .asciz "r" format: .asciz "%d\n" .global main main: PUSH {R1} LDR R0, [R1, #0x04] LDR R1, =r BL fo

我在运行代码时遇到非法指令错误。没有编译错误-但即使在调试时,它也会给我这个错误

以下是我目前使用的代码:

.global .fopen
.global .fclose
.global getc

.data
    fin: .word 0x00
    r: .asciz "r"
    format: .asciz "%d\n"
.global main
main:
    PUSH {R1}
    LDR R0, [R1, #0x04]
    LDR R1, =r
    BL fopen
    LDR R1, =fin
    STR R0, [R1]
    POP {R1}
endl:
    LDR R1, =fin
    LDR R0, [R1]
    BL fclose
_exit:
    MOV R7, #1
    MOV R0, #0
    SWI 0

计入@EOF和@Notlikethat:

。。。您需要在main:之前写入.text,以向汇编器/链接器/加载器指示以下内容将被解释为可执行代码。 -@EOF


谢谢大家

您可能是在一个健全的系统上,.data节被标记为no execute…@即使在我删除.data时,它也不起作用,并给出相同的错误。我使用的是一个树莓皮,@notliketh的意思是,您需要在
main:
之前编写
.text
,以指示汇编器/链接器/加载程序将以下代码解释为可执行代码。