Posted on 06-19-2006, by Tim
There are a few basic concepts that are unique to LC-3 that are quite different than higher-level languages. The first thing you may be asking is, "where are the variables?" Variables are usually created when you ask the user for input. The data that they enter can be stored in registers. Variables may also stored into labels.
Typically you can think of labels as constants in higher-level languages. They should be coded into the the second part of your code, after "HALT".
; enter your labels here
The syntax for creating a label is:
label name .fill value
|ASCII_OFFSET .fill #48 |
There are several supported numbering systems accepted as values. You can input decimal (#) or even hexadecimal (x), which is useful for storing memory addresses.
Two Sections of your Program
There are two sections to all LC-3 programs. The first section is executed, and the second section does not get executed.
; executable code goes here
; non-executable code goes here
You may think of the non-executable part of the code as the pre-processor directives you can place in C++. A good example of code that goes in the second part is a label definition. "HALT" marks the ending of the executable code in your LC-3 program.
- Views: 11259