6.3 A Program Example
We are now ready to write our first machine-language program, which will be to write “Hi” to the screen. We’ll need five machine-language instructions to do this: two loads, two stores, and one to stop the program execution.
First consideration: should we store the character data in memory and load it using direct addressing mode, or should we store it in the operand specifier and use immediate addressing mode? We’ll use immediate addressing in this example and leave direct addressing as an exercise. So, for this example, when we load the characters the addressing mode specifier will be 000 and the ASCII code for each letter will go directly in the operand specifier (the second and third byte of the load instruction—and ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access