|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Senior Member
Iscritto dal: Jul 2003
Città: Alessandria
Messaggi: 10167
|
[Assembler 8086] Numero massimo da vettore
Ciao, ho fatto un programma che, preso in input un vettore di numeri, mi determina e stampa il maggiore, questo è ciò che ho scritto:
Codice:
;You are asked to develop an 8086 assembly program that find the maximum ;element of a 10 elements unsigned 8 bits integer vector .MODEL small .STACK DIM EQU 10 .DATA VETT DB DIM DUP (?) .CODE .STARTUP ;Read Vector MOV CX, DIM MOV AH, 1 ;Prepare for getting input MOV DI,0 ;Clear the index register vRead: INT 21H MOV VETT[DI], AL ;Move the DI-th element from AL to VETT INC DI LOOP vRead ;LOOP decrements CX of 1 then ;if ( CX != 0 ) goto vRead ;else parse next instruction MOV CX, DIM ;Set the original dimension of the vector in CX MOV DI, 0 ;Set DI back to 0 MOV AL, 0 compare: CMP VETT[DI],AL JA maximum ;if (destination > source ) goto maximum INC DI CMP CX, DI ;if (CX != DI) goto compare JNZ compare maximum: MOV AL,VETT[DI] INC DI CMP CX,DI ;if ( DI != CX ) goto compare JNZ compare MOV AH,2 ;Set AH to 2 so that we can print to screen INT 21H .EXIT END Tuttavia mi domandavo una cosa... Questo programma prende 1 solo carattere... Quindi io non posso ad esempio fare un confronto tra numeri che vanno oltre il 9... Come devo fare? Inoltre... Quando mi viene la schermata di input, io digito: Codice:
0 1 2 3 4 5 6 7 8 9 Cioè, nel vettore io ho caricato dei numeri oppure: Codice:
NULL SOH STX ETX EOT ENQ ACK BEL BS TAB Per capirci, per fargli prendere dei numeri ( facciamo, per semplicità per ora, da 0 a 9 ) devo digitare i loro caratteri ascii ( quindi i numeri dal 48 al 57 inclusi)? EDIT: Di questo programma ho la soluzione, ma è molto più complessa rispetto alla mia...
__________________
Dell XPS 13 (9350) :: i5-2500K - HD6870 - AsRock Z68 Pro3 - Corsair Vengeance 8GB (4x2) DDR3 :: Samsung Galaxy S4 GT-i9505
|
|
|
|
|
|
#2 | |||
|
Senior Member
Iscritto dal: Sep 2009
Messaggi: 638
|
Ciao,
Quote:
Quote:
Quote:
|
|||
|
|
|
|
|
#3 | |
|
Senior Member
Iscritto dal: Jul 2003
Città: Alessandria
Messaggi: 10167
|
Quote:
Codice:
while( c=getchar() != \n); Ok, quindi quando io premo 0 lui mi memorizza 48 nell'apposito registro....
__________________
Dell XPS 13 (9350) :: i5-2500K - HD6870 - AsRock Z68 Pro3 - Corsair Vengeance 8GB (4x2) DDR3 :: Samsung Galaxy S4 GT-i9505
|
|
|
|
|
|
|
#4 |
|
Senior Member
Iscritto dal: Sep 2009
Messaggi: 638
|
Esatto, in entrambi i casi.
|
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 15:27.






















