assembly to compare two numbers

前端 未结 8 1966
情书的邮戳
情书的邮戳 2020-12-10 02:35

What is the assembler syntax to determine which of two numbers is greater?

What is the lower level (machine code) for it? Can we go even lower? Once we get to the bi

8条回答
  •  旧时难觅i
    2020-12-10 03:03

    This depends entirely on the processor you're talking about but it tends to be of the form:

    cmp r1, r2
    ble label7
    

    In other words, a compare instruction to set the relevant flags, followed by a conditional branch depending on those flags.

    This is generally as low as you need to get for programming. You only need to know the machine language for it if you're writing assemblers and you only need to know the microcode and/or circuit designs if you're building processors.

提交回复
热议问题