Simple Calculator

Can i get source for a simple calculator (single digits) that:
The program will prompt the user for the first number (0-9), followed by the operation ( + , - , * , / ), followed by the second number (0-9). The program will then return the answer.
aka
#
operand
#
answer

monkeytothemax@yahoo.com

thankksksksks

Comments

  • Maybe I'm misunderstanding but I only spent 5 minutes on this so....
    [code]
    ; you want a simple 1 digit calulator....?

    org 100h
    mov ah,9
    mov dx,msg
    int 21h

    mov cx,3
    inputLoop:
    mov ah,1
    int 21h
    push ax
    loop inputLoop
    mov al,'='
    int 29h
    pop dx
    pop bx
    pop ax
    mov ah,dl
    sub ax,'00'
    cmp bl,'+'
    jne skip1
    add al,ah
    skip1:
    cmp bl,'-'
    jne skip2
    cmp al,ah
    jge skip2b
    xchg al,ah
    push ax
    mov al,'-'
    int 29h
    pop ax
    skip2b:
    sub al,ah
    skip2:
    cmp bl,'*'
    jne skip3
    mul ah
    skip3:
    cmp bl,'/'
    jne skip4
    mov bl,ah
    xor ah,ah
    div bl
    skip4:
    add al,'0'
    int 29h
    ret

    msg: db 'syntax: X+-*/Y >$'
    [/code]
  • Damn this forum is weird. Tells me "server error" 3 times when I try and post this but the posts went through anyway and the spam filter is going crazy on me right now!
  • Now how do I delete these duplicate posts of mine? I can edit them but can't seem to find a method to remove them...
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion