Assembly Language/assembly & C
Expert: Moskovitz Eliezer - 10/6/2000
QuestionA 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.
Answerfirst 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.