Skip to content

Fox682/PyCPU

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PyCPU

Python Script to run an Assembly like language

==================================

PyCPU

Note: The cpu is a emulator of sorts, it is not meant to be fast in any sence of the word. It is however a good intro for programming in assembly (when fleshed out).

To Use:

  • Use a Text Editor to write down Assembly Instructions
  • Run compile.py - Compiles instructions into numerical file NOT Binary file (less code to run)
  • Run cpu.py - Runs the Command from compiled output file. Script will look for file generated by compile.py (output)

Features:

  • Runs Assembly like language
  • cpu.py is the actual CPU
  • compile.py is the Compiler
  • infile <-- Input to compiler --> Output from compiler --> outfile --> CPU.py to run

Current Progress: (for both "AX" & "BX" Registers)

  • Math - ADD, SUB, MUL, DIV, ADI (Add Immediate, instead of Register)
  • INC & DEC
  • CMP >,< & == (Sets Flags)
  • Branching - JMP (Relative), JE (Equal), JL (Less-Than), JG (Greater Than)
  • LDI (Load Immediate Value)
  • LD Load from Memory (use LDR to use Register as Referance eg, ldr ax,bx)
  • ST Store to Memory (use STR to use Register as Referance eg, str ax,bx)
  • Stack - PUSH to Stack. POP from Stack
  • SP Stack Pointer (Stack Grows in Reverse)
  • BP Base Pointer (Stack Manipulation)

The "infile" includes more instructions on how to use the cpu.py. Feel free to edit and or remove this to replace it with your own.

Planned:

  • 2 more Registers (Tenative as this would balloon the code to run...)
  • Labels! (Jumps using words instead)

Future:

  • Optimize
  • Screen Output
  • Networking

============================

Future use case (Goal!):

  • Research into Minimalistic VMs with Networking
  • Custom Protocol Examination
  • Simulated Multiple CPU Cooperation

Disclaimer:

  • License Free
  • Not fit for any use whatsoever, do not use in production. Not Responsible for the results of use at any time.
  • Any Suggestions or feedback appreciated, don't expect a reply in any reasonable amount of time.

About

Python Script to run an Assembly like language

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages