Glad to hear it's going better for you. I'm still having an awful time. I feel like a "clueless newbie" and an "obsolete old man" at the same time. I give myself the same advice I'd give you: "just keep slogging along"...
Your results for the unsigned comparison sound right to me. I attempted, for "extra credit", to print out the results instead of just leaving max and min in ax and dx...
; nasm -f elf32 myprog.asm
; ld -o myprog myprog.o -melf_i386
section .data
VAR1:
dw 30000
VAR2:
dw 0ABCDH
VAR3:
dw 7FFFH
VAR4:
dw 100010001000B
; the character '0' will be overwritten with the correct answer as we find it
smax db "VAR0 is signed maximum.", 10
smax_size equ $ - smax
smin db "VAR0 is signed minimum.", 10
smin_size equ $ - smin
umax db "VAR0 is unsigned maximum.", 10
umax_size equ $ - umax
umin db "VAR0 is unsigned minimum.", 10
umin_size equ $ - smin
section .text
global _start
_start:
nop
; find signed maximum, put it in ax
mov ax, [VAR1]
mov byte [smax + 3], '1'
cmp [VAR2], ax
jle skip1
mov ax, [VAR2]
mov byte [smax + 3], '2'
skip1:
cmp [VAR3], ax
jle skip2
mov ax, [VAR3]
mov byte [smax + 3], '3'
skip2:
cmp [VAR4], ax
jle skip3
mov ax, [VAR4]
mov byte [smax + 3], '4'
skip3:
; print "result"
mov edx, smax_size
mov ecx, smax
mov ebx, 1
mov eax, 4
int 80h
; find signed minimum, put it in dx
mov dx, [VAR1]
mov byte [smin + 3], '1'
cmp [VAR2], dx
jge skip4
mov dx, [VAR2]
mov byte [smin + 3], '2'
skip4:
cmp [VAR3], dx
jge skip5
mov dx, [VAR3]
mov byte [smin + 3], '3'
skip5:
cmp [VAR4], dx
jge skip6
mov dx, [VAR4]
mov byte [smin + 3], '4'
skip6:
; print "result"
mov edx, smin_size
mov ecx, smin
mov ebx, 1
mov eax, 4
int 80h
; find unsigned maximum, put it in ax
mov ax, [VAR1]
mov byte [umax + 3], '1'
cmp [VAR2], ax
jbe skip7
mov ax, [VAR2]
mov byte [umax + 3], '2'
skip7:
cmp [VAR3], ax
jbe skip8
mov ax, [VAR3]
mov byte [umax + 3], '3'
skip8:
cmp [VAR4], ax
jbe skip9
mov ax, [VAR4]
mov byte [umax + 3], '4'
skip9:
; print "result"
mov edx, umax_size
mov ecx, umax
mov ebx, 1
mov eax, 4
int 80h
; find unsigned minimum, put it in dx
mov dx, [VAR1]
mov byte [umin + 3], '1'
cmp [VAR2], dx
jae skip10
mov dx, [VAR2]
mov byte [umin + 3], '2'
skip10:
cmp [VAR3], dx
jae skip11
mov dx, [VAR3]
mov byte [umin + 3], '3'
skip11:
cmp [VAR4], dx
jae skip12
mov dx, [VAR4]
mov byte [umin + 3], '4'
skip12:
; print "result"
mov edx, umin_size
mov ecx, umin
mov ebx, 1
mov eax, 4
int 80h
done:
mov eax, 1
mov ebx, 0
int 0x80
At the moment, I'm not at all sure it's correct, but it "seems to work". Not necessarily the "best" way to do it.
Although it isn't written as an "array", as long as the variables stay together, it could be treated as an array and the comparisons done in a loop instead of individually. If you had 100 variables instead of just 4, you'd probably want to do that. I may take a crack at that, but... not right now...
Best,
Frank
Edit: Well, already...
umin db "VAR0 is unsigned minimum.", 10
umin_size equ $ - smin
should be "$ - umin" of course. I didn't even notice it was printing "too much" at first...