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 ...

Get Computer Science Illuminated, 7th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.