added jump shortcut mnemonics to MU8A
This commit is contained in:
+21
-1
@@ -17,13 +17,33 @@ import sys, re, struct
|
||||
mnemos = ['nop', 'jmp', 'iat', 'out', 'inp', 'set', 'cpy', 'fma',
|
||||
'sub', 'div', 'mdf', 'abs', 'sqr', 'nel', 'tri', 'rnd']
|
||||
|
||||
# mu808 jump shortcuts
|
||||
jmp_shorts = {
|
||||
'jeq': 'jmp 0', # direct jump if equals to zero
|
||||
'jgt': 'jmp 1', # direct jump if greater than zero
|
||||
'jlt': 'jmp 2', # direct jump if less than zero
|
||||
'jge': 'jmp 3', # direct jump if greater than or equals to zero
|
||||
'jle': 'jmp 4', # direct jump if less than or equals to zero
|
||||
'jne': 'jmp 5', # direct jump if not equals to zero
|
||||
'juc': 'jmp 6 0', # direct unconditional jump
|
||||
'ieq': 'jmp 7', # indirect jump if equals to zero
|
||||
'igt': 'jmp 8', # indirect jump if greater than zero
|
||||
'ilt': 'jmp 9', # indirect jump if less than zero
|
||||
'ige': 'jmp 10', # indirect jump if greater than or equals to zero
|
||||
'ile': 'jmp 11', # indirect jump if less than or equals to zero
|
||||
'ine': 'jmp 12', # indirect jump if not equals to zero
|
||||
'iuc': 'jmp 13 0' # indirect unconditional jump
|
||||
}
|
||||
|
||||
# converts the MU8A source code to the plaintext machine code representation
|
||||
def assemble(source):
|
||||
labels = {}
|
||||
out = ''
|
||||
lno = 0
|
||||
vreg = re.compile(r'\s+')
|
||||
for line in source.split('\n'):
|
||||
for shrt, meaning in jmp_shorts.items(): # replace the jump shortcuts
|
||||
source = source.replace(shrt, meaning)
|
||||
for line in source.split('\n'): # parse the main code
|
||||
fields = []
|
||||
line = line.split(';')[0].strip()
|
||||
if len(line) > 0: # actual line to be counted on
|
||||
|
||||
Reference in New Issue
Block a user