Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Simple Calculator

$
0
0
I am just a newbie to this language. I am making a simple calculator using TASM. I already get the function of multiplication but my problem is the addition, subtraction and division.

Here is my code in multiplication:
.model small
.stack 10h
.data
   number db (?)
   digit db 0,0,'$'

.code

    mov ax,@data
    mov ds,ax
	
    mov ax,3
    int 10h
	
    mov ah,1
    int 21h


    mov bl,al
    sub bl,30h

    mov ah,2
    mov dl,10
    int 21h

    mov dl,13
    int 21h

    mov ah,1
    int 21h

    mov number[0],al
    sub number[0],30h



    mov ch,0
    mov cl,number[0]

    mov al,bl
    mov bl,0

 balik:

    add bl,al

    loop balik

   

    mov ah,2
    mov dl,10
    int 21h

    mov dl,13
    int 21h

 
   

    mov bh,0
    
    mov cx,bx
digit_0:
   
    cmp bl,0Ah
    jl digit_1
   
    sub bl,0Ah
    inc digit[0]

    loop digit_0

digit_1:
    mov digit[1],bl
    add digit[1],30h
    add digit[0],30h

    mov ah,2
    mov dl,digit[0]
    int 21h

    mov ah,2
    mov dl,digit[1]
    int 21h

    mov ah,4ch
    int 21h

 end



That is for multiplication only. Can you gave me an idea on how should I convert my formula in multiplication in order that my calculator provide answer for addition, subtraction and multiplication..thanks in advance your attention is much appreciated.

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>