Assembly Language/assembly & C

Advertisement


Question
A C function using string function returns a value 0 if the stored password is not same as entered password or 1 if both are same. write a program in 8086 assembly which accepts this returned value from c program and displays the message - "Please try again", if the returned value is 0 or "You are allowed to access all the facilities", if the returned value is 1.

Answer
first you have to know that a C function return value is saved in ax.
now you have to check the value of ax and print the right message

 cmp ax,0
 jz passok
 ; here the password is not ok.printing message
 mov dx,offset not_ok_mes
 jmp print
passok :
 mov dx,offset ok_mes
print :
 mov ah,9
 int 21h ; printing using dos function number 9
 ; ending program
 mov ax,4c00h
 int 21h
 ; the messages
 ok_mes db 'you are allowed to ... $'
 not_ok_mes db 'Please try again $'

hope that helps mail me If you need more info. note the message must end with $ and jz check that the value is zero.

Assembly Language

All Answers


Ask Experts

Volunteer


Moskovitz Eliezer

Expertise

I can answer question about 80x86 asm programs and also software only 8051 asm programs. not good in hardware. I can also help in dos interrupts but not in windows asm.

Experience

dos, 8051, 80x86

©2012 About.com, a part of The New York Times Company. All rights reserved.