here's what i ve done so far can anyone please check for the error i made cause the output is wrong:


.model small
.stack 100h
.data

disp db "Enter Choice:$"
disp1 db "a-IT22A",0ah,0dh,"$"
disp2 db "b-IT22B",0ah,0dh,"$"
disp3 db "c-IT22C",0ah,0dh,"$"
disp4 db "Choose Behaviour Level:$"
disp5 db "1-Excellent",0ah,0dh,"$"
disp6 db "2-Normal",0ah,0dh,"$"
disp7 db "3-Uncomfortable",0ah,0dh,"$"
disp8 db "Wrong Entry, Please Repeat",0ah,0dh,"$"

.code

start:

again:

mov ax, @data
mov ds, ax

mov ah, 9h
lea dx, disp1
int 21h

mov ah, 9h
lea dx, disp2
int 21h

mov ah, 9h
lea dx, disp3
int 21h

mov ah, 9h
lea dx, disp
int 21h

mov ah, 1h
int 21h

mov bl, al
cmp bl, 'a'
je choicea

mov bh, al
cmp bh, 'b'
je choiceb

mov dh, al
cmp dh, 'c'
je choicec

jmp again

choicea:

mov ax, @data
mov ds, ax

mov ah, 9h
lea dx, disp1
int 21h

choiceb:

mov ax, @data
mov ds, ax

mov ah, 9h
lea dx, disp2
int 21h


choicec:
mov ax, @data
mov ds, ax

mov ah, 9h
lea dx, disp3
int 21h

ulit:

mov ah, 9h
lea dx, disp5
int 21h

mov ah, 9h
lea dx, disp6
int 21h

mov ah, 9h
lea dx, disp7
int 21h

mov ah,9h
lea dx, disp4
int 21h

mov ah, 1h
int 21h

mov ch, al
cmp ch,'1'
je exe

mov ah, al
cmp ah, '2'
je nor

mov cl, al
cmp cl, '3'
je uncom

jmp ulit

exe:

mov ax, @data
mov ds, ax

mov ah, 9h
lea dx, disp5
int 21h

nor:

mov ax, @data
mov ds, ax

mov ah, 9h
lea dx, disp6
int 21h

uncom:

mov ax, @data
mov ds, ax

mov ah, 9h
lea dx, disp7
int 21h

mov ah, 4ch
int 21h

end start

Recommended Answers

All 3 Replies

Why are you choosing different registers to compare AL?
You potentially modify three registers do do one comparison.
That could have detrimental effects and make it necessary to reset the values before the next interrupt.

...and please use code tags.

what do u mean

At the top of the box where you type your message, there is a button that says "CODE"

It turns this:
MOV AH, 09H

into:

MOV AH, 09H

On the other issue, you are
1) waiting for a keypress
2) pushing that value from al into bl
3) comparing that to 'a'
-if not 'a':
4) pushing the SAME VALUE into bh
5) comparing that to 'b'
-if not 'b':
6) pushing the SAME VALUE into dh
* Now AL, BL, BH and DH all have the same value

In ASM, having registers set to values you don't expect or need will cause your code to do unexpected things.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.