# LAB 3 (Take two input and print the two digit and their sum)

Oct 24th, 2021
1,097
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1.
2.  ; Write a program to
3.  ; (a) display a "?",
4.  ; (b) read two decimal digits whose sum "is less than 10
5.  ; (c) display them and their sum on the next line, with an appropriate message Simple Assembly Language Solution.
6.
7.
8.
9. .MODEL SMALL   ; IN THIS COURSE ALL MODEL ARE SMALL
10. .STACK 100H    ; WE ALWAYS USE STACK 100H
11.
12.
13. .DATA     ; DATA SEGMENT
14.
15.     STR1 DB 0AH,0DH,'THE SUM OF '     ; PRINT A NEW LINE AFTER TAKING INPUT SO WE USE 0AH,0DH
16.     FIRSTNUM DB ?                     ; TAKE A VARIABLE WHERE WE TAKE FIRST NUMBER
17.     STR2 DB ' AND '                   ; ASSIGN A STRING IN STR 2
18.     SECONDNUM DB ?                    ; TAKING SENOCD NUMBER
19.     STR3 DB ' IS '                    ; ASSIGN ANOTHER STRING IN STR3
20.     ANS DB ?                          ; TAKE A VARIABLE WHERE WE WILL PUT OUT SUMMATION, AND DO NOT END THE STRING BY \$ SIGN
21.     STR4 DB ' \$'                      ; ASSIGN \$ HERE AFTER PRINT THE ANSWER
22.
23.
24.
25. .CODE
26.
27. MAIN PROC       ; MAIN CODE START HERE
28.
29.     ;PROGRAMME SEGMENT PREFIX
30.     MOV AX,@DATA
31.     MOV DS,AX    ; INITILATION OF DS
32.
33.
34.     MOV AH,2     ; PRINT SOME STRING
35.     MOV DL,3FH   ; PRINT ? SIGN, WE CAN ALSO PRINT IT BY       MOV DL,'?'
36.     INT 21H      ; INTRUPT THE WORK
37.
38.     MOV AH,1            ; TAKING SOME INPUT
39.     INT 21H             ; INTRUPT THE WORK
40.     MOV BL,AL           ; IF WE TAKE INPUT GENERALY GOES TO AL SO WE MOVE THE INPUT VALUE INTO BL.
41.     MOV FIRSTNUM,AL     ; TAKE THE FIRST NUMBER INTO REGISTER
42.     INT 21H             ; INTRUPT THE WORK
43.     MOV SECONDNUM,AL    ; TAKE THE SECOND NUMBER INTO REGISTER
44.
46.     SUB BL,30H     ; TO COVERT ASCII TO DECIMAL WE SUBSTRACR 30 FROM SUMMATION     BL - 30 = BL ,   NOW IT IS DECIMAL.. CHECK ASCII TO  UNDERSTAND BETTER
47.     MOV ANS,BL     ; NOW MOVE THE VALUE INTO ANSWER
48.
49.     MOV AH,9      ; PRINT STRING
50.     LEA DX,STR1   ; VARIABLE PRINTING FIRST TO LAST  BECAUSE WE USE \$ AT LAST. SO IT PRINT FIRST TO LAST
51.     INT 21H       ; INTRUPT THE WORK
52.
53.
54.
55.     MOV AX,4CH ; TERMINATED THE CODE AND EXIT
56.     INT 21H
57.     MAIN ENDP
58. END MAIN
RAW Paste Data