1

I create this program for viewing the max and min number in an array, I want to print the position of these too, how I can do this? For example if I give in input 1234567895, I want in output max=9 position=8, min=1 position=0. At the moment max and min works but I don't know how to print indices for outputting the position

   dosseg
  .model small
  .stack 100h
  .data
  vettore db 10 dup(0)
  msg1 db 'insert 10 numbers',10,13,"$"
  msg2 db ' Min:',"$"
  msg3 db 'Max:',"$"
  .code
  start:
  mov ax,@data
  mov ds,ax
  lea dx,msg1
  mov ah,9
  int 21h
  mov di,0

  inserimento:
  mov ah,1
  int 21h
  mov vettore[di],al
  add di,1
  cmp di,10
  jl inserimento
mov di,0
mov si,0
mov bl,'9'
jmp testz

b:
mov bl,vettore[di]
cmp di,10
jge finee
jmp testzzz

a: 
mov cl,vettore[di]
cmp di,10
jge finee
jmp testzz

testz:
cmp vettore[di],cl
jge a

testzz: 
cmp vettore[di],bl
jl b

testzzz:
inc di
inc si
cmp di,9
jle testz

finee:
lea dx,msg3
mov ah,9
int 21h
mov ah,2
mov dl,cl
int 21h

lea dx,msg2
mov ah,9
int 21h
mov ah,2
mov dl,bl
int 21h

fine:
mov ah,4ch
int 21h
end start
Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
Gatpis
  • 11
  • 1
  • Save the position when you find a new min or a new max. – Peter Cordes May 25 '18 at 16:35
  • Yeah, but I don't know the command for printing di or si – Gatpis May 25 '18 at 18:37
  • There is no single "command" to print a register. You will need to convert the value to ASCII, then look up the DOS interrupt for printing a character or string. – lurker May 25 '18 at 18:45
  • Ok, can you help me in this? – Gatpis May 25 '18 at 18:45
  • I have never done this – Gatpis May 25 '18 at 18:46
  • 1
    If you do a Google search, or even a search on this website, you should be able to find lots of examples. I would suggest writing a little subroutine that prints what's in `ax` in hexadecimal. Then, just call that after moving `si` to `ax`. Here's one example, popped right up on a search: [Assembly basics: output register value](https://stackoverflow.com/questions/34254461/assembly-basics-output-register-value) – lurker May 25 '18 at 18:46

0 Answers0