Skip to main content

Pyssemble allows to execute pseudo assemply code and it is meant for teaching purposes.

Project description

Pyssembly

A python assembly emulator.

This tool allows to execute pseudo assemply code and it is meant for teaching purposes.

Install

python -m pip install pyssembly

Usage

python -m pyssembly <code.pys>

Examples

Examples are available in the examples folder.

Print the result of 137 * 2322:

mov a 137
mul a 2322
out a "\n"

Comments

To comment a line write ';' at the beginning. For example:

;this is a comment

Labels

To label a line, to use it as destination in a jmp statement, simply write a single word in the line. For example:

this-is-a-label

Instruction set

General
  • in a b: print b to stdout, read string from stdin, store it into a
  • out a b: print a and b to stdout
  • mov a b: store b into a
  • jmp a b: if a, jump to b (b can be a label or a line number)

All conversions, math and boolean operations store the result in the first operand (a).

Conversions
  • bool a b: boolean(b)
  • int a b: integer(b)
  • flt a b: float(b)
  • str a b: string(b)
Math
  • add a b: a + b
  • sub a b: a - b
  • mul a b: a * b
  • div a b: a / b
  • pow a b: ab
  • log a b: logba
  • root a b: a1/b
  • idiv a b: a // b
  • mod a b: a % b
Boolean
  • eq a b: a == b
  • neq a b: a != and b
  • les a b: a < b
  • leq a b: a <= b
  • grt a b: a > b
  • geq a b: a >= b
  • not a b: not b
  • and a b: a and b
  • or a b: a or b
  • xor a b: a xor b
  • nand a b: a nand b
  • nor a b: add a nor b
  • nxor a b: a nxor b

Future work

  • Add arrays
  • Add string manipulation

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyssembly-1.0.0.tar.gz (3.8 kB view hashes)

Uploaded Source

Built Distribution

pyssembly-1.0.0-py3-none-any.whl (4.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page