-
Notifications
You must be signed in to change notification settings - Fork 0
/
4LAB.Asm
112 lines (94 loc) · 2.17 KB
/
4LAB.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
; Template for console application
.586
.MODEL flat, stdcall
OPTION CASEMAP:NONE
Include kernel32.inc
Include masm32.inc
IncludeLib kernel32.lib
IncludeLib masm32.lib
.CONST
MsgInp DB "Input array:", 10,13,0
MsgExit DB "Press Enter to Exit",0AH,0DH,0
MsgOrg db "Original matrix:",10,13,0
MsgRes db "Result: ",0
spc db " ",0
ent db 10,13,0
.DATA
n dd 5
space db " "
.DATA?
inbuf DB 100 DUP (?)
arr_str DB 100 DUP(?)
arr_length DB ?
arr DD 25 DUP(?)
len dd ?
len_str dd ?
res db 10 dup (?)
.CODE
Start:
Invoke StdOut,ADDR MsgInp
Invoke StdIn,ADDR arr_str,LengthOf arr_str
sub eax, 2
mov len_str, eax
Invoke StripLF,ADDR arr_str
cld
lea edi, arr_str
mov ecx, len_str
mov ebx, 0
CycleS:
push ecx
Invoke atol, edi
mov arr[ebx*4], eax
inc ebx
pop ecx
mov al, space
repne scasb
je CycleS
mov len, ebx
Invoke StdOut,ADDR MsgOrg
mov ebx, 0
Outp1:
mov ecx, 0
Outp2:
push ebx
push ecx
Invoke dwtoa, arr[ebx][ecx*4], ADDR res
Invoke StdOut, ADDR res
Invoke StdOut, ADDR spc
pop ecx
pop ebx
inc ecx
cmp ecx, n
jl Outp2
Invoke StdOut, ADDR ent
add ebx, 20
cmp ebx, 100
jl Outp1
mov ecx, arr[0][4]
mov ebx, 0
Cycle1:
mov eax, ebx
xor edx, edx
mov ebp, 20
div ebp
add eax, 1
Cycle2:
cmp ecx, arr[ebx][eax*4]
jnl Cont
mov ecx, arr[ebx][eax*4]
Cont:
inc eax
cmp eax, n
jl Cycle2
add ebx, 20
cmp ebx, 80
jl Cycle1
Invoke dwtoa, ecx, ADDR res
Invoke StdOut, ADDR MsgRes
Invoke StdOut, ADDR res
Invoke StdOut, ADDR ent
XOR EAX,EAX
Invoke StdOut,ADDR MsgExit
Invoke StdIn,ADDR inbuf,LengthOf inbuf
Invoke ExitProcess,0
End Start