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 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)
Math
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 != and 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
: add 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.0.tar.gz
(3.8 kB
view hashes)
Built Distribution
Close
Hashes for pyssembly-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 312207e006db63827a69272167dd18607c0137a93880b792c5aae176f89ca9ae |
|
MD5 | a4ddd285adc1afc5dc545f1e678a2b4b |
|
BLAKE2b-256 | d1a158e6c976ada34715d10fddeb1771a7a920d4bc123123c70fb4e78c37b428 |