Assembly Language Programming 3
Output
Output to screen.
To output a single character to the screen, you need to do three things...
Example
This program would output the character 'A' to the screen.
| MOV | AH,2 |
| MOV | DL,65 |
| INT | 21H |
Special characters may be used..
| ASCII code | Character |
| 7 | Beep |
| 8 | Backspace |
| 9 | Tab |
| 10 | Line Feed |
| 13 | Carriage Return |
Example program
This program outputs the character whose ASCII code is stored in store location 'FirstLetter'.
| program OutLetter; | ||||
| var | FirstLetter : byte; | {1 byte store location} | ||
| begin | ||||
| FirstLetter := 65; | {Give value to 'FirstLetter'} | |||
| asm | {start of Assembly program} | |||
| mov dl,FirstLetter; | {Transfer character code from 'FirstLetter' to DL} | |||
| mov ah,2 | { Initialise for output} | |||
| int 21h; | {Output character} | |||
| end; | {end of Assembly language} | |||
| end. | ||||
Exercises
| 1. | Write a program to output the word 'TEN' onto the screen, followed by a 'Beep'. |
| 2. | Write a program which outputs the
word
T vertically on the screen. (You will by now be discovering that it takes a lot of instructions in Assembly language to do even the simplest of tasks!) |
Back to index