Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/20.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 如何使用循环在汇编语言中多次打印字符串_Assembly_X86 - Fatal编程技术网

Assembly 如何使用循环在汇编语言中多次打印字符串

Assembly 如何使用循环在汇编语言中多次打印字符串,assembly,x86,Assembly,X86,我得到了这个错误 cndtlBranch.s: 我不知道如何在汇编语言中使用push和pop指令 这是我的密码: 考虑到您使用的样式,我假设您使用的是GNU汇编程序。在这种情况下,在编译时将选项-32传递给as 这将生成32位代码,这是您正在编写的代码类型,而不是默认情况下生成的64位代码类型 您是否在64位平台上?这些是32位机器的组装说明。 Assembler messages: cndtlBranch.s:47: Error: operand type mismatch for `push

我得到了这个错误

cndtlBranch.s:

我不知道如何在汇编语言中使用push和pop指令

这是我的密码:


考虑到您使用的样式,我假设您使用的是GNU汇编程序。在这种情况下,在编译时将选项-32传递给as


这将生成32位代码,这是您正在编写的代码类型,而不是默认情况下生成的64位代码类型

您是否在64位平台上?这些是32位机器的组装说明。
Assembler messages:
cndtlBranch.s:47: Error: operand type mismatch for `push'
cndtlBranch.s:53: Error: operand type mismatch for `pop'
.data

String1:
.ascii "hai!\n"

String2:
.ascii "hai ra!\n"

String3:
.ascii "hai ra mama!\n"

.text

.globl _start

 _start:

    nop
    movl $10, %eax
    xorl %eax, %eax
    jz HelloWorld

    jumpIfZeroNot:
    movl $4, %eax
    movl $1, %ebx
    movl $String1, %ecx
    movl $5, %edx
    int $0x80
    jmp Exit

    jumpIfZero:
    movl $4, %eax
    movl $1, %ebx
    movl $String2, %ecx
    movl $8, %edx
    int $0x80
    jmp Exit

    Exit:
    movl $1, %eax
    movl $0, %ebx
    int $0x80

    HelloWorld:
    movl $10, %ecx
    printTenTimes:
        push %ecx
        movl $4, %eax
        movl $1, %ebx
        leal String3, %ecx
        movl $13, %edx
        int $0x80
        pop %ecx
    loop printTenTimes
    jmp Exit