Unsigned integers in assembly

后端 未结 1 1821
伪装坚强ぢ
伪装坚强ぢ 2021-01-13 16:00

Brand new to assembly need some help with unsigned arithmetic. Converting from a C program is that means anything.

Using:

Linux

NASM

x86 (3

相关标签:
1条回答
  • 2021-01-13 16:22

    In assembly, there are no distinct signed and unsigned types. A register holds a value that can be either signed or unsigned, depending on how you look at it.

    The are instructions that are consistent with the signed interpretation (jg, jl, etc.) and instructions that are consistent with the unsigned interpretation (ja, jb, etc.) The cmp instruction works for both - it sets flags that can be used by instructions like jl to jump based on the signed interpretation, and flags that can be used by instructions like jb to jump based on the unsigned interpretation. Whichever flags you're not using, you just ignore.

    So when you say "my register storing that is negative", that's nonsense. It can only appear negative if you chose to interpret it that way.

    0 讨论(0)
提交回复
热议问题