-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexp1.asm
112 lines (85 loc) · 2.97 KB
/
exp1.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
;TITLE Write an assembly language program to add array on n numbers stored into the memory
;NAME:-SAKET.S.KHOPKAR ROLL NO:-SI072
.model small
.data ; data segment starts
arr db 6 dup(0) ;array arr for 6 digits with 0 duplicate values
carry db 0 ;variable for storing carry
count db 6 ;for storing count
count1 db 0
res db 0 ;result variable
msg db 10,13,"Result of addition is $" ;message display
msg1 db 10,13,"Enter two digit number $"
.code
mov ax,@data
mov ds,ax ;activates data segment
input macro ;macro for input the numbers
mov ah,01 ;function value for input
int 21H
endm ;end of input macro
output macro ;macro for display output
mov ah,02 ;function value for display
int 21H
endm ;end of output macro
show macro var ;show macro for message display
mov ah,09 ;function value for string input
lea dx,var
int 21H
endm ;end of show macro
mov al,count
mov count1,al
lea si,arr
again1:show msg1
call accept ;calling accept procedure
mov [si],bl ;input numbers
inc si
dec count1
jnz again1
mov ch,0
mov cl,count
lea si,arr
mov dl,0
again:add dl,[si]
jnc next
inc carry
next:inc si
loop again
mov res,dl
show msg
mov dl,carry
add dl,30H
output ;call output macro
call print ;call print procedure
mov ah,4cH ;terminate program
int 21H
accept proc near ;accept procedure definition
mov bl,0
mov ch,02 ;digit count
mov cl,04 ;rotation count
up1: rol bl,cl ;writing input logic
input ;calling input macro
sub al,30H
cmp al,09
jbe down1
sub al,7
down1:add bl,al
dec ch
jnz up1
ret
endp ;end of accept procedure
print proc near ;print procedure definition
mov dh,res
mov cl,04 ;rotation count
mov ch,02 ;digit count
up: rol dh,cl ;writing display logic
mov dl,dh
and dl,0fH
add dl,30H
cmp dl,39H
jbe down
add dl,07
down: output ;call the output macro
dec ch
jnz up
ret
print endp ;end of print procedure
end ;end of the program