Do you see something wrong here?
MOV AL, NUM1
MOV AL, NUM2
MOV SOMMA, AL
And at that point both
NUM1
and
NUM2
are characters, and not numeric values. So the first thing you need to do is convert each number to its integer equivalent. So change
NUM1
and
NUM2
to
DW
type and save them by:
MOV AH, 01H
INT 21H
XOR AH,AH
SUB AL,'0'
MOV NUM1,AX
Then do the same with NUM2. But when you add them together the total could be greater than 9, so you need to code the algorithm to convert an integer into printable digits. And you could save duplication by using subroutines for capturing the numbers.
[edit]
There are a few issues here
1 .MODEL SMALL
2 .STACK 100H .DATA NUM1 DW ?
3 NUM2 DW ?
4 DOM1 DB 'digit the number: ',13, 10 , '$'
5 DOM2 DB 'digit the other one: ',13, 10 , '$'
6 RIS1 DB 'the sum: ', 13,10, '$'
7 SOMMA WB ?
8 .CODE
9 .STARTUP
10 MOV AX, @DATA
11 MOV DS, AX
12 MOV AH, 09H
13 MOV DX, OFFSET DOM1
14 INT 21H
15 MOV AH, 01H
16 INT 21H
17 MOV NUM1, AL
18
19 MOV AH, 09H
20 MOV DX, OFFSET DOM2
21 INT 21H
22
23 MOV AH, 01H
24 INT 21H
25 MOV NUM2, AL
26
27
28 MOV AH, 01H
29 INT 21H
30 XOR AH,AH
31 SUB AL,'0'
32 MOV NUM1,AX
33
34 MOV AH, 01H
35 INT 21H
36 XOR AH,AH
37 SUB AL,'0'
38 MOV NUM2,AX
39
40
41 MOV AL, NUM1
42 MOV AL, NUM2
43 MOV SOMMA, AL
44
45 MOV AH, 09H
46 MOV DX, OFFSET RIS1
47 INT 21H
48
49 SUB SOMMA, 30H
50
51 MOV AH, 09H
52 MOV DX, OFFSET RIS1
53 INT 21H
54
55 SUB SOMMA, 30H
56
57
58 MOV AH,02H
59 MOV DL, SOMMA
60 INT 21H
61
62 MOV AH, 40H
63 INT 21H
64
65 END
You need to stop coding and write down on paper the steps needed to get this program working. Print the message that asks for a digit, and read the digit from the user. You then convert the digit from a character to a binary integer, and save it in a variable defined as a
DW
type. Once you have two digits then you should add them together and store the result in the
SOMMA
variable. But you cannot print a binary value directly so you need to write a function that converts it to its character representation - and that is a good exercise for you to use your assembler skills. So think slowly what you are trying to achieve and try to make your code follow the logical steps.
[edit]