-
Notifications
You must be signed in to change notification settings - Fork 0
/
minmax.asm
83 lines (60 loc) · 972 Bytes
/
minmax.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
include irvine32.inc
.data
value_1 byte 10,20,2,30,90
msg1 byte "the maximum value is",0
MSG2 BYTE "THE minimum value is ",0
Maximum byte 0
Minimum byte 0
.code
main proc
xor ecx,ecx
xor eax,eax
xor edx,edx
mov edx, offset value_1
mov ecx,lengthof value_1
call Maximum_
mov maximum,al
call writeint
xor ecx,ecx
xor eax,eax
xor edx,edx
mov edx, offset value_1
mov ecx,lengthof value_1
call minimum_
mov minimum,al
call writeint
exit
main endp
;--------------------------Maximum_ proc-------------------------
Maximum_ proc
mov al,[edx]
L:
cmp al,[edx]
jb swap
back_4:
inc edx
loop L
jmp back
swap:
mov al,[edx]
jmp back_4
back:
ret
maximum_ endp
;-------------------------Minimum_ proc--------------------------
Minimum_ proc
mov al,[edx]
L:
inc edx
cmp al,[edx]
ja swap
loop L
jmp back
swap:
mov al,[edx]
dec ecx
jmp L
back:
ret
minimum_ endp
end main