ShadyA&B
10-12-2009, 12:51
Salve,
sto impazzendo per trovare l'errore (sicuramente un'istruzione mancante) per attivare il doppio "if" che in assembly manca e si può emulare solo con l'istruzione di salto.
Devo richiedere da tastiera un carattere, se "m" deve stampare un messaggio al maschile, se "f" deve stampare un messaggio al femminile.
Ecco il codice completo che ho buttato giù:
; multi-segment executable file template.
data segment
; add your data here!
pkey db 13,10, "press any key...$"
mes_gen1 db 'Sei maschio o femmina? $'
mes_gen2 db 13,10, 'Inserisci m o f -> $'
mes_masch db 13,10,"Benvenuto nel mondo della programmazione assembly $"
mes_femm db 13,10, "Benvenuta nel mondo della programmazione assembly $"
ends
stack segment
dw 128 dup(0)
ends
code segment
start:
; set segment registers:
mov ax, data
mov ds, ax
mov es, ax
MOV DX, 0
; add your code here
;STAMPA DOMANDA
lea dx, mes_gen1
mov ah, 9
int 21h
;STAMPA RICHIESTA SCELTA
lea dx, mes_gen2
mov ah, 9
int 21h
;CHIEDI CARATTERE DA TASTIERA
mov ah,00h
int 16h
cmp al,'m'
je maschio
cmp al, 'f'
je femmina
maschio: lea dx, mes_masch
mov ah,9
int 21h
femmina: lea dx, mes_femm
mov ah,9
int 21h
lea dx, pkey
mov ah, 9
int 21h ; output string at ds:dx
; wait for any key....
mov ah, 1
int 21h
mov ax, 4c00h ; exit to operating system.
int 21h
ends
end start ; set entry point and stop the assembler.
L'istruzione di salto je mi sembra giusta visto che c'è da confrontare un'uguaglianza...in "al" perchè quel tipo di interrupt salva in al il carattere immesso.. Però andando a compilare ed eseguire qualsiasi carattere immetto mi stampa entrambe le stringhe.. in pratica non riesco AD ATTIVARE il salto.
sto impazzendo per trovare l'errore (sicuramente un'istruzione mancante) per attivare il doppio "if" che in assembly manca e si può emulare solo con l'istruzione di salto.
Devo richiedere da tastiera un carattere, se "m" deve stampare un messaggio al maschile, se "f" deve stampare un messaggio al femminile.
Ecco il codice completo che ho buttato giù:
; multi-segment executable file template.
data segment
; add your data here!
pkey db 13,10, "press any key...$"
mes_gen1 db 'Sei maschio o femmina? $'
mes_gen2 db 13,10, 'Inserisci m o f -> $'
mes_masch db 13,10,"Benvenuto nel mondo della programmazione assembly $"
mes_femm db 13,10, "Benvenuta nel mondo della programmazione assembly $"
ends
stack segment
dw 128 dup(0)
ends
code segment
start:
; set segment registers:
mov ax, data
mov ds, ax
mov es, ax
MOV DX, 0
; add your code here
;STAMPA DOMANDA
lea dx, mes_gen1
mov ah, 9
int 21h
;STAMPA RICHIESTA SCELTA
lea dx, mes_gen2
mov ah, 9
int 21h
;CHIEDI CARATTERE DA TASTIERA
mov ah,00h
int 16h
cmp al,'m'
je maschio
cmp al, 'f'
je femmina
maschio: lea dx, mes_masch
mov ah,9
int 21h
femmina: lea dx, mes_femm
mov ah,9
int 21h
lea dx, pkey
mov ah, 9
int 21h ; output string at ds:dx
; wait for any key....
mov ah, 1
int 21h
mov ax, 4c00h ; exit to operating system.
int 21h
ends
end start ; set entry point and stop the assembler.
L'istruzione di salto je mi sembra giusta visto che c'è da confrontare un'uguaglianza...in "al" perchè quel tipo di interrupt salva in al il carattere immesso.. Però andando a compilare ed eseguire qualsiasi carattere immetto mi stampa entrambe le stringhe.. in pratica non riesco AD ATTIVARE il salto.