Click here to Skip to main content
15,886,919 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
C++
.model small
.data
mes db  'Enter a number[000 - 999] ', '$'
input db 0
input2 db 0
.stack 100h
.code

getchar proc

mov ah, 01h
int 21h
ret

getchar endp

newline proc

mov dl, 10
mov ah, 02h
int 21h
ret
newline endp



    main    proc

mov ax, @data
mov ds, ax

lea dx, mes
mov ah, 09h
int 21h

call getchar

sub al, 48
mov bl, 100
mul bl

add input , al

call getchar

sub al, 48
mov bl, 10
mul bl


add input , al

call getchar

sub al, 48
mov bl, 1
mul bl

add input , al

call newline

lea dx, mes
mov ah, 09h
int 21h


call getchar

sub al, 48
mov bl, 100
mul bl

add input2 , al

call getchar

sub al, 48
mov bl, 10
mul bl


add input2 , al

call getchar

sub al, 48
mov bl, 1
mul bl

add input2 , al



mov ax, 4c00h
int 21h

main endp
end main


i have this code in assembly language. it asks for 2 user inputs then im suppose to add subtract multiply divive and print the modulo.

how can i add input and input2?
is the syntax
add input , input2?
Posted
Updated 20-Feb-15 5:44am
v2
Comments
ZurdoDev 20-Feb-15 10:36am    
Move them both into memory locations and then add them, as I recall. But refer to the documentation.
Reuben Cabrera 20-Feb-15 10:49am    
what documentation??
Reuben Cabrera 20-Feb-15 10:52am    
can you give an example?
Richard MacCutchan 20-Feb-15 11:46am    
Read your assembler reference and check the syntax for the different operations. Most mathematical operations work on two registers, or one register and one memory location. You should also learn to use loops in your code rather than all sequential code.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900