0
    .section    .rodata
fmt:
    .string "result: %d\n"
    .globl main
    .text
main:
    pushq $6
    pushq $3
    popq %rax
    popq %rcx
    xorq %rbx, %rbx
    divq %rcx
    pushq %rax
    movq $fmt, %rdi
    popq %rsi
    movq $0, %rax
    call printf
    ret

I have a x86 assembly code that does 6/3 and prints the result. But I am getting a error that says Floating point exception (core dumped) and I don't know why

Jester
  • 54,538
  • 4
  • 72
  • 115
  • `xorq %rbx, %rbx` should be `xorq %rdx, %rdx` (or better `xor %edx, %edx`). Also it's unclear why you use the stack. – Jester Apr 08 '22 at 13:17

0 Answers0