assembly to compare two numbers

前端 未结 8 1918
情书的邮戳
情书的邮戳 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条回答
  •  执念已碎
    2020-12-10 03:07

    Compare two numbers. If it equals Yes "Y", it prints No "N" on the screen if it is not equal. I am using emu8086. You can use the SUB or CMP command.

    MOV AX,5h
    MOV BX,5h
    SUB AX,BX 
    JZ EQUALS
    JNZ NOTEQUALS
    
    EQUALS:
    MOV CL,'Y'
    JMP PRINT
    
    NOTEQUALS:
    MOV CL,'N'
    
    PRINT:
    MOV AH,2
    MOV DL,CL
    INT 21H
    
    RET
    

提交回复
热议问题