Skip to main content
1 of 3
E. Ginzburg
  • 207
  • 1
  • 2
  • 9

what commands in assembly cast value from hexa to decimal when they are called?

how can I know if a command is treating an immediate as a decimal or as a hexadecimal? e.g div casts the values into decimal before it make the arithmetic division:

.data x: .quad 0x16 y: .quad 0x7 z: .space 8

.text .global main main: xor %rax, %rax xor %rbx, %rbx xor %rdx, %rdx movq x, %rax
movq y, %rbx div %rbx movq %rax, z ret

I'm getting those results:

enter image description here

and my guess is that div looks at the decimal value of the number inside a register (cast it from hex to dec) but is it always like that in all arithmetic commands? are there commnads from different type that also act like this? I've tried reading the manual, but it doesn't specified there, I found it out by accident when debugging in sasm.

thank you very much for your time and attention.

E. Ginzburg
  • 207
  • 1
  • 2
  • 9