예제 #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')
예제 #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')
예제 #3
0
def write_neg_command(line_def):
    if line_def['arg'][0] != 'neg':
        return
    primitive_ml.read_stack_and_write('M', '-M')
예제 #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')
예제 #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')
예제 #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')
예제 #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')