Skip to content

DowdyJ/LC3-Virtual-Machine-and-Assembler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LC3 Virtual Machine and Assembler

This is my implementation of a VM for the LC3. The VM will only run on Unix-like machines but the assembler should run on either.

To build, run make in the base directory.
To run the VM, run ./lc3.pls [path] [swap_endianness]
  • path: relative or abolute path to input binary code using forward slashes.
  • swap_endianness: whether to swap byte order during loading of binary image. Acceptable values are TRUE or FALSE. Should typically be TRUE.

To run the Assembler, run ./assembler.pls [path] [swap_endianness]
  • path: relative or abolute path to input LC3 assembly code file using forward slashes.
  • swap_endianness: whether to swap byte order during writing of binary image. Acceptable values are TRUE or FALSE. Should typically be TRUE.

LC3 VM

The VM portion of the project could not have been made without the help of this excellent site.

LC3 Assembler

I made the assembler portion of this project by reading the project docs and reverse engineering pre-assembled binaries and comparing them to their assembly code. For the two projects I tested against, it produces byte identical binary.

As per the LC3 standard, SEMICOLON marks a comment. Comments can be on a line by themselves or after an instruction.

Tokens can be seperated by any combination of TAB, SPACE or COMMA.

Labels

Labels may be placed on the same line as an instruction or alone on the line above it. Labels are not case sensitive. LOOP is regarded as the same as Loop/lOOp/loop and so on.

Assembler Macros

BLKW is not implemented. The following macros are valid for use with the assembler:

.ORIG

Requires an argument in hex format. (e.g. x3000)

.FILL

.FILL will accept an argument of either a literal value in either hex format (x123), LC3 decimal (#123) or decimal literals (123). .FILL also accepts an argument of a label. In this case, this will resolve to the position in memory of the label. (e.g. 0x3000 + label line index)

.STRINGZ

.STRINGZ takes an argument enclosed by double quotes. Semi-colons inside of STRINGZ arguments are not culled as comments. The escape characters ESC \e) and NEWLINE (\n) are replaced with their actual ASCII values. Other escape codes unsupported.

.END

.END marks the end of the file. All text is stripped past the .END before any interpretation occurs.

About

A simple LC3 emulator and assembler

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published