GithubHelp home page GithubHelp logo

dowdyj / lc3-virtual-machine-and-assembler Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 23.6 MB

A simple LC3 emulator and assembler

License: Creative Commons Zero v1.0 Universal

C++ 96.84% Makefile 3.16%
lc3 lc3-assembler

lc3-virtual-machine-and-assembler's Introduction

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.

lc3-virtual-machine-and-assembler's People

Contributors

dowdyj avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.