1.4. Script Command

This article uses the ghost user program in the git repository.

Below on the left is the user program code. On the right is the red ghost LC3 image code. The red ghost code was generated using the LC3 Image Generator tool.



To run this program, there are three files to assemble (if needed) and three objects to load. Instead of typing each command separately, the simulator allows the use of basic scripting. An example is below. The script is just a text file. Each line in the file is a command, that is just like what would be typed into the command line.


Each line explained:

  1. “reset” resets the simulator,
  2. “clear” clears out the command line,
  3. “as path/to/assembly/file.asm” assembles file.asm,
  4. “ld path/to/object/file.obj” loads the object into memory,
  5. “continue” runs the LC3 code loaded into memory.
  6. Re-assembling lc3os.asm is not needed since it does not change. However, it does not hurt to include in the script.

To run the script all that is needed is to run use the script command. For example: “script ghost.txt”.



© 2024 LC3Tutor

Privacy

results matching ""

    No results matching ""