GithubHelp home page GithubHelp logo

fxdpntthm / c-sim-swingle Goto Github PK

View Code? Open in Web Editor NEW
1.0 4.0 0.0 420 KB

assembler linker loader and simulator in c with gui in tcl/Tk

C 56.31% Tcl 7.03% Objective-C 0.31% Objective-C++ 32.09% C++ 4.26%

c-sim-swingle's Introduction

simulator for an abstract machine

contains a GUI for assembler, linkage editor and simulator to run the executable in the virtual environment

Machine Architecture

  • can address 4096 memory
  • word addressable
  • 4 general purpose registers A, B, C, D
  • 1 memory pointer M
  • Special purpose registers SP (Stack Pointer), SW(Status Word), PC (Program Counter)

instruction in the form of Label(opt) opcode operand1, operand2(opt)

3 Addressing Modes

  • Register Addressing (Register number given)
  • Immediate Addressing (Data given in instruction)

Register Addressing and Indirect Addressing format:

  • XXYYZZ (ext ref)
  • (XX)->Opcode
  • (YY)->Operand1
  • (ZZ)->Operand2

Immediate Addressing Format(2 bytes):

  • XXYY00 data
    • (XX)->Opcode
    • (YY)->operand1
    • (00)->operand2
    • data->stored in next byte (This acts as op2)

SW (Status word) format X1X0 shows whether arithmetic operation had the following properties

  • Result is Zero/Non-Zero
  • Result is Negative/Positive
  • Zero is considered as positive
  • X1 = 1 indicates result is zero X1 = 0 indicates result is nonzero
  • X0 = 1 indicates result is negative X0 = 0 indicates result is positive
  • hence the valid SW formats will be: 01 00 11

Instruction codes:

  • Op num length(bytes)
  • == === =============
  • ADD 00 1/2 (checked)
  • ADI 01 2 (checked)
  • SUB 02 1/2 (checked)
  • SUI 03 2 (checked)
  • MUL 04 1/2 (checked)
  • MUI 05 2 (checked)
  • MOV 06 1/2
  • MVI 07 2 (checked)
  • DIV 08 1/2
  • DVI 09 2
  • CMP 10 1/2
  • CPI 11 2
  • LDA 12 2
  • STA 13 2
  • CALL 14 2
  • CZ 15 2
  • CNZ 16 2
  • CP 17 2
  • CNP 18 2
  • JMP 19 2
  • JZ 20 2
  • JNZ 21 2
  • JP 22 2
  • JNP 23 2
  • RET 24 1
  • RZ 25 1
  • RNZ 26 1
  • RP 27 1
  • RNP 28 1
  • INR 29 1 (checked)
  • DCR 30 1 (checked)
  • PUSH 31 1 (checked)
  • POP 32 1

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.