8086 Help

Thread Starter

CaptinClutch

Joined Nov 15, 2011
3
Hello everyone, I am having some trouble figuring out this problem..

Write a program that will generate the following output "your grade is A, B, C, D

Register AL holds a number between 45&100.

"A" 90 < AL <100
"B" 79 < AL <89
 

Thread Starter

CaptinClutch

Joined Nov 15, 2011
3
DATA SEGMENT
EBCDIC DB 'A'
DB 'B'
DB 'C'
DB 'D'




ASCII DB '90'

DB '79'

DB '69'

DB '59'
DATA ENDS

CODE SEGMENT

ASSUME DS:DATA,CS:CODE
GRADE:
MOV AX, DATA
MOV DS, AX
MOV AH,8H
INT 21H
LEA DI, EBCDIC
LEA SI, ASCII

MOV BX,0H

again: MOV DL,[DI]
CMP AL,AL
JNE HERE
MOV BL,[SI]
here:
INC DI
INC SI
LOOP again
RET

CODE ENDS
END GRADE
END

Thats what I have so far....
 

thatoneguy

Joined Feb 19, 2009
6,359
Get the breakpoints for the grades.

Start with grade in AL
Clear Zero Flag
Subtract 50 from AL ; Fail
If Zero Flag is set, Jump to Fail
Subtract 20 from AL ; 60%+
If Zero Flag is set, Jump to "D"
Subtract 10 from AL; 70%+
If Zero Flag is set Jump to "C"
Subtract 10 from AL; 80%+
If Zero Flag is set, Jump to "B"
Subtract 10from AL; 90%+
If Zero flag is set, Jump to "A"

Something along those lines should work, once you get the subtraction correct, though you may want to do bounds checking in the "D" throgh "A" area to subtract the rest of 100 to ensure the answer is Zero in the event a number greater than 100 was input, then display an out of range error.
 
Top