Pyssembly allows to execute pseudo assembly code and it is meant for teaching purposes.
Project description
Pyssembly
A python assembly emulator.
This tool allows to execute pseudo assembly 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:
- create file
example.pys
containing:
mov a 137
mul a 2322
out a "\n"
- run it with:
python -m pyssembly <example.pys>
- result:
318114
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 aout a b
: print a and b to stdoutmov a b
: store b into ajmp 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)
Arithmetic
add a b
: a + bsub a b
: a - bmul a b
: a * bdiv a b
: a / bpow a b
: ablog a b
: logbaroot a b
: a1/bidiv a b
: a // bmod a b
: a % b
Boolean
eq a b
: a == bneq a b
: a != bles a b
: a < bleq a b
: a <= bgrt a b
: a > bgeq a b
: a >= bnot a b
: not band a b
: a and bor a b
: a or bxor a b
: a xor bnand a b
: a nand bnor a b
: a nor bnxor 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.1.tar.gz
(3.9 kB
view hashes)
Built Distribution
Close
Hashes for pyssembly-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cf67697e47162f5458680dfd710a3f0adb4455977e24b64d4aae9b13a711dfa2 |
|
MD5 | 91f1e14dee2d3dbc9262478563018d30 |
|
BLAKE2b-256 | 5d72e36bcf55bf8797ef1ab68e0d19ade7b89d02ac2f9f296b3d2b574c5166f0 |