| |||||||||
| |||||||||
String Output:A string is a list of characters treated as a unit. In programming languages we denote a string constant by using quotation marks, e.g. "Enter first number". In 8086 assembly language, single or double quotes may be used. In order to display a string we must know where the string begins and ends. The beginning of string is given by its address, obtained using the offset operator. The end of a string may be found by either knowing the length of the string or by storing a special character at the end of the string which acts as a sentinel. Function 09:MS-DOS provides subprogram number 9h to display strings which are terminated by the ‘$’ character. In order to use it we must: The following code illustrates how the string ‘Hello world’, followed by the Return and Line-feed characters, can be displayed.
In this example, we use the .data directive. This directive is required when memory variables are used in a program. The offset operator allows us to access the address of a variable. In this case, we use it to access the address of message and we store this address in the dx register. Subprogram 9h can access the string message (or any string), once it has been passed the starting address of the string. Example:Write a program that prompts the user to enter a small letter through the keyboard. The program should read the letter without echo. The program displays then a message with the capital equivalent of the letter the user entered through the keyboard.
|