• Some users have recently had their accounts hijacked. It seems that the now defunct EVGA forums might have compromised your password there and seems many are using the same PW here. We would suggest you UPDATE YOUR PASSWORD and TURN ON 2FA for your account here to further secure it. None of the compromised accounts had 2FA turned on.
    Once you have enabled 2FA, your account will be updated soon to show a badge, letting other members know that you use 2FA to protect your account. This should be beneficial for everyone that uses FSFT.

Fairly simple assembly program

orgcaptainnemo

Limp Gawd
Joined
Jan 9, 2003
Messages
242
Alright,

I'm writing a little assembly program that takes someone's score (0-100) and then tells you what letter grade they will get. So, 90-100 = A, 80-89 = B, and so on.

I'm writing it in NASM on the 8086, and right now I can get it to read my input correctly. Its stored in:

Code:
buf:
max     db      4
count   db      0
input   db      0,0,0,0

Now I need to find a way to compare what they've inputted into 'input' with 90, 80, etc... I know how to use the cmp and jmp commands (ja, jna, jb, jnb, etc...) BUT I'm not sure how to create a piece of data that I can directly compare with my input.

Since the input is a string in ASCII and the jmp commands are looking at the hex value. So simply saying:

Code:
mov bx, input
mov ax, ninety ; assume ninety was declared as '90'
cmp bx, ax 
jb else              ; if bx is lower than 90 than go to the else

mov ah, 9
mov dx, msga ; msg says the user gets an A
int 0x21

else: <IMAGINE MORE CODE>

If I could just get some suggestions or ideas on how to compare this it would be really great.

Thanks
 
Sorry to hijack your thread, but are you taking a course, or are you learning from a book? (I'm looking for a good assembly book... they're hard to find, I've found.)
 
Its a class taught by an idiot, and this idiot told us not to buy the book. Which I regret now.

BUY THE BOOK NO MATTER WHAT.
 
You can only compare a number with a number...

Given that and you're given the offset to some defined bytes that contain a string; the string should probably be converted to a number.

Using whatever info you're teacher has given, or even just google, you'll probably be able to figure out how to turn and ASCII string into a number.

Then what you'd have is two numbers, and you already know cmp works.

Additionally, you may want to think about an alternate implementation. It might be able to be done with less code than you think...
 
Back
Top