Exemplo n.º 1
0
def write_greater_then_command(line_def):
    if line_def['arg'][0] != 'gt':
        return
    primitive_ml.read_stack_to('D')
    # a > b => a - b > 0 => m=a d=b
    primitive_ml.read_stack_and_write('D', 'M-D')
    primitive_ml.write_bool_jumps('JGT')
Exemplo n.º 2
0
def write_or_command(line_def):
    if line_def['arg'][0] != 'or':
        return
    primitive_ml.read_stack_to('D')
    primitive_ml.read_stack_and_write('M', 'D|M')
Exemplo n.º 3
0
def write_neg_command(line_def):
    if line_def['arg'][0] != 'neg':
        return
    primitive_ml.read_stack_and_write('M', '-M')
Exemplo n.º 4
0
def write_and_command(line_def):
    if line_def['arg'][0] != 'and':
        return
    primitive_ml.read_stack_to('D')
    primitive_ml.read_stack_and_write('M', 'M&D')
Exemplo n.º 5
0
def write_add_command(line_def):
    if line_def['arg'][0] == 'add':
        primitive_ml.read_stack_to('D')
        primitive_ml.read_stack_and_write('M', 'M+D')
Exemplo n.º 6
0
def write_eq_command(line_def):
    if line_def['arg'][0] != 'eq':
        return
    primitive_ml.read_stack_to('D')
    primitive_ml.read_stack_and_write('D', 'D-M')
    primitive_ml.write_bool_jumps('JEQ')
Exemplo n.º 7
0
def write_less_then_command(line_def):
    if line_def['arg'][0] != 'lt':
        return
    primitive_ml.read_stack_to('D')
    primitive_ml.read_stack_and_write('D', 'M-D')
    primitive_ml.write_bool_jumps('JLT')