Im trying to create calculator...but rt now just trying the addition and subtraction numbers with user input. Im using 16 bits DOS o/s. I can sure used some help. This is part of my codes...
my add and sub code is not function correctly.
input:
mov dx, userinput
call Writestring
call Readint
call Crlf
mov bx,10
call Crlf
mov al, userinput
;user input operation proc(-,+,/,*):
mov dx, offset operator
call Writestring
call Readstring
ja opercmp ; jump to operation procedure
; operation proc
opercmp:
cmp al,43 ; value for + sign
je add1 ; add1 label proc
cmp al,45
je sub1 ; sub1 label
;storage1 the value
stor1:
cmp storage1,0
jne stor2
mov stor1,al
jum input
;storage2 value
mov storage2, al
jmp input
addition proc:
add1:
push bx
push cx
mov ax,0
cs1: add ax,[bx]
add bx, 2
loop cs1
pop cx
pop bx
ret
addition endp
subtraction proc:
sub1:
push bx
push cx
mov ax,0
cs2: sub ax,[bx]
sub bx, 2
loop cs2
pop cx
pop bx
ret
subtracition endp
my add and sub code is not function correctly.
input:
mov dx, userinput
call Writestring
call Readint
call Crlf
mov bx,10
call Crlf
mov al, userinput
;user input operation proc(-,+,/,*):
mov dx, offset operator
call Writestring
call Readstring
ja opercmp ; jump to operation procedure
; operation proc
opercmp:
cmp al,43 ; value for + sign
je add1 ; add1 label proc
cmp al,45
je sub1 ; sub1 label
;storage1 the value
stor1:
cmp storage1,0
jne stor2
mov stor1,al
jum input
;storage2 value
mov storage2, al
jmp input
addition proc:
add1:
push bx
push cx
mov ax,0
cs1: add ax,[bx]
add bx, 2
loop cs1
pop cx
pop bx
ret
addition endp
subtraction proc:
sub1:
push bx
push cx
mov ax,0
cs2: sub ax,[bx]
sub bx, 2
loop cs2
pop cx
pop bx
ret
subtracition endp