-1

i am getting this error

cndtlBranch.s:

Assembler messages:
cndtlBranch.s:47: Error: operand type mismatch for `push'
cndtlBranch.s:53: Error: operand type mismatch for `pop'

I am confused how to use push and pop instructions in assembly language.

Here is my code:

.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
Devolus
  • 21,661
  • 13
  • 66
  • 113

1 Answers1

0

Given the style you're using, I'm assuming you're using the GNU assembler. In that case, pass the option --32 to as when compiling.

This will generate 32-bit code (which is the kind of code you're writing in) instead of 64-bit code (likely the kind of code you're generating by default).

randomusername
  • 7,927
  • 23
  • 50