This is a program with two procedures MIN and MAX to find the minimum and the maximum grade in a set of grades.
For example, if the grades are: 81, 65, 78, 83,74, 57, 88, 92, 51 ,80 ,60,
then the minimum grade is 51 and the maximum grade is 92.
The program saves the results in a new memory locations starting at offset 500h.
Last active
May 7, 2018 16:12
-
-
Save 0xD9D0/2bae969ab3ff6b07add9ca3584ffbae6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.386 | |
.model flat, stdcall | |
.stack 4096 | |
ExitProcess proto,dwExitCode:dword | |
.data | |
org 100h | |
grades db 81, 65, 78, 83,74, 57, 88, 92, 51 ,80 ,60 | |
org 500h | |
results db 2 dup(?) | |
.code | |
main proc | |
call max | |
call min | |
call ExitProcess | |
main endp | |
max: | |
mov dl,byte ptr [grades] | |
mov esi, offset grades + 1 | |
mov cx,10 | |
looph: cmp dl,byte ptr[esi] | |
ja cond | |
mov dl,byte ptr[esi] | |
cond: inc esi | |
loop looph | |
mov byte ptr [results],dl | |
ret | |
min: | |
mov esi,offset grades | |
mov dl,byte ptr[grades] | |
inc esi | |
mov cx,10 | |
loophe: cmp dl,byte ptr[esi] | |
jb condi | |
mov dl,byte ptr[esi] | |
condi: inc esi | |
loop loophe | |
mov byte ptr[results+1],dl | |
ret | |
end main | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment