-
Notifications
You must be signed in to change notification settings - Fork 1
/
Sum.asm
executable file
·47 lines (35 loc) · 720 Bytes
/
Sum.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
TITLE Row Sum Calculation (RowSum.asm)
INCLUDE Irvine32.inc
.data
tableB BYTE 10h, 20h, 30h, 40h, 50h
BYTE 60h, 70h, 80h, 90h, 0A0h
BYTE 0B0h, 0C0h, 0D0h, 0E0h, 0F0h
RowSize = 5
msg1 BYTE "Enter row number: ",0
msg2 BYTE "The sum is: ",0
.code
main PROC
mov edx,OFFSET msg1
call WriteString
call Readint
mov ebx,OFFSET tableB
mov ecx,RowSize
call calc_row_sum
mov edx,OFFSET msg2
call WriteString
call WriteHex
call Crlf
exit
main ENDP
calc_row_sum PROC uses ebx ecx edx esi
mul ecx
add ebx,eax
mov eax,0
mov esi,0
L1: movzx edx,BYTE PTR[ebx + esi]
add eax,edx
inc esi
loop L1
ret
calc_row_sum ENDP
END main