汇编语言。 NASM计算器

时间:2018-06-13 16:30:55

标签: assembly nasm

代码编译并运行。出于某种原因,虽然它只允许我输入一个数字我的符号来执行计算,然后在我可以输入另一个数字之前关闭。我试图将程序输出为以下

3
+
2
= 
5

到目前为止,这是我的NASM代码:

segment .data
  num1: db 4
  num2: db 4
  button: db 2

        segment .bss


        segment .text
         global  asm_main

        asm_main:
    push    ebp
    mov     ebp, esp

----------- 代码在这里开始 -----------------

  call read_int
    mov DWORD[num1], eax

    call read_char
    mov DWORD[button], edx

    call read_int
    mov DWORD[num2], eax

    cmp DWORD[button], '+'
    jne addition

    cmp DWORD[button], '-'
    je subtraction

    cmp DWORD[button], '*'
    je multiplication

    cmp DWORD[button], '/'
    je division

    cmp DWORD[button], '%'
    je modulus

    addition:
    mov eax, DWORD[num1]
    add eax, DWORD[num2]
    call print_int
    jmp end

    subtraction:
    jmp end
    multiplication:
    jmp end
    division:
    jmp end
    modulus:
    jmp end

   end:

0 个答案:

没有答案