-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathodd.asm
101 lines (80 loc) · 1.35 KB
/
odd.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
.386
Include \masm32\include\Irvine32.inc
Includelib \masm32\lib\Irvine32.lib
includelib \masm32\lib\Kernel32.lib
includelib \masm32\lib\User32.lib
;in IDE mod:
;TITLE MASM(test.asm)
;include Irvine32.inc
.data
arrayBYTE BYTE 200 DUP (0)
count EQU (LENGTHOF arrayBYTE)
reversearrayBYTE BYTE 200 DUP (0)
N1 DWORD 0
N2 DWORD 0
runvalue DWORD 0
Total DWORD 0
MSG0 BYTE "Enter N1 and N2, Now enter N1",0dh,0ah,0
MSG1 BYTE "Enter N2 Now",0dh,0ah,0
MSG2 BYTE "The reversed Array BYTE is as follows",0dh,0ah,0
MSG3 BYTE "The Total of adding the reversed BYTE array",0dh,0ah,0
.code
main PROC
mov edx, OFFSET MSG0
call writestring
call readint
mov N1,eax
mov edx, OFFSET MSG1
call writestring
call readint
mov N2,eax
mov eax,N2
sub eax,N1
mov ecx,eax
add ecx,1
mov eax,0
mov esi,0
mov eax,N1
L1:
mov arrayBYTE[esi],al
add eax,1
add esi,1
loop L1
mov eax,N2
sub eax,N1
mov ecx,eax
add ecx,1
mov esi,0
mov edi,ecx
sub edi,1
mov eax,0
L2:
mov al,arrayBYTE[esi]
mov reversearrayBYTE[edi],al
add esi,1
sub edi,1
loop L2
mov eax,N2
sub eax,N1
mov ecx,eax
add ecx,1
mov esi,0
mov ebx,0
mov eax,0
mov edx,OFFSET MSG2
call writestring
L3:
mov al,reversearrayBYTE[esi]
add ebx,eax
call writedec
call crlf
add esi,1
loop L3
mov eax,ebx
mov edx, OFFSET MSG3
call writestring
call writeint
call crlf
exit
main ENDP
END main