Professional Documents
Culture Documents
Convert the following C statements to assembly language, where x and y are variables.
if (x <= y)
x = x +1;
else
y = y 1;
Convert the following C statements to assembly language, where x and y are variables.
y =1;
while (x>0)
{
y=y*x;
x--;
}
3. Procedures
Write a procedure named read that reads a character from a keyboard until a carriage return is
entered or the number of characters entered so far is five. Use INT 21h / ah = 1 to read a character
from keyboard. You can define procedures as follows:
read PROC
;your code here
ret
read ENDP
4. Consider a login system. Suppose you have a 5-character password stored in DS in memory.
Write a program that reads a 5-char password string from the keyboard port; compare the
string with the password in memory; prints access granted if correct or access denied
otherwise. Use the procedure you wrote above to read password from keyboard.
1|Page