Home > Enterprise >  How do I solve the error: Segmentation fault(core dumped) in my code? AT&T syntax
How do I solve the error: Segmentation fault(core dumped) in my code? AT&T syntax

Time:11-29

I've been looking for hours, and i can't find the mistake in my code. The program seems to exit at the "opadd" tag. I am using x86_64 on Linux, with AT&T syntax.

The program takes as input a string of characters, for example, "2 3 add 4 mul", and then, for this particular example, should do as follows:

  • adds 2 to the stack
  • adds 3 to the stack
  • computes the sum of 2 and 3 and then adds 5 to the stack
  • multiplies 5 and 4 and adds 20 to the stack, and then prints 20.
.data
    formatPrintf: .asciz "%d"
    sir: .space 1000
    delim: .asciz " "
    formatScanf: .asciz "00[^\n]"
    cuvant: .space 100
    primulNumar: .space 4
    atoiCuvant: .long 0
    x: .space 4
    y: .space 4
    eval: .long 0
    op: .space 4
    add: .asciz "add"
    sub: .asciz "sub"
    mul: .asciz "mul"
    div: .asciz "div"
.text

.global main

main:
    pushl $sir
    pushl $formatScanf
    call scanf
    popl            
  • Related