3. First Program: Pseudo Code, ADD, AND

1. Introduction
2. Loading Programs
3. First Program:
Psuedo code
4. Basic Input/Output
To get started with creating programs, we need to know some instructions and how to use them. However, before that we need a little extra code in our assembly file. This code is called Pseudo-ops (pseudo operations). Information on pseudo-ops can be found on page 182 of our reference. Pseudo-ops provide information to the assembler during the assembly process. They do not execute when we are running the script. We will make use of these when writing our programs. Here we will cover the .ORIG, .END, .FILL, .BLKW, .STRINGZ pseudo-ops. First we will discuss .ORIG and .END, which we first saw in "lc3_first.asm". .ORIG tells PennSim where to load our program. On line 7 above, we see that "lc3_first.asm" will begin at memory location x3000 (hexadecimal 3000). This is important because, the operating system begins at x0000 and uses the memory before x3000 for other things. We need the OS to run our program, but to make sure our program doesn't class with the OS, the OS designates an area for our program to be loaded and that area starts at x3000. Each program we write will begin with .ORIG x3000, so all of our programs will start at memory location x3000. Note that other memory locations can be used, just be careful not to clash with the OS.

Complementary to .ORIG, we have .END, which tells the assembler when to expect the end of the script. It indicates that there will be no more code, and for that reason, it will always be the last line. These two pseudo-ops are essential for each program we will be writing. The remaining pseudo-ops: .FILL, .BLKW, and .STRINGZ are used to reserve memory and allow us to initialize those reserved memory locations with whatever we want.

Before talking about the other three pseudo-ops, it is beneficial to quickly go over how the program is stored in memory.

(To be continued...)