Make boolean variables be only bottom byte of %rax (%al)
This commit is contained in:
parent
8bd65f4c05
commit
c37e48e8b2
|
@ -780,11 +780,9 @@ def compile_ast(node: ASTnode, compile_data: CompileData) -> None:
|
|||
elif node.value == '<':
|
||||
compile_data.code.append(Instruction('cmpq', [register, '%rax']))
|
||||
compile_data.code.append(Instruction('setl', ['%al']))
|
||||
compile_data.code.append(Instruction('movzbq', ['%al', '%rax']))
|
||||
elif node.value == '=':
|
||||
compile_data.code.append(Instruction('cmpq', [register, '%rax']))
|
||||
compile_data.code.append(Instruction('sete', ['%al']))
|
||||
compile_data.code.append(Instruction('movzbq', ['%al', '%rax']))
|
||||
else: assert False
|
||||
|
||||
# If both operands are dates, divide result by number of seconds in a day
|
||||
|
@ -841,7 +839,7 @@ def compile_ast(node: ASTnode, compile_data: CompileData) -> None:
|
|||
|
||||
# compile condition
|
||||
compile_ast(node.child_condition, compile_data)
|
||||
compile_data.code.append(Instruction('testq', ['%rax', '%rax']))
|
||||
compile_data.code.append(Instruction('testb', ['%al', '%al']))
|
||||
compile_data.code.append(Instruction('jz', [label_loop]))
|
||||
case 'do_unless' | 'unless_expression':
|
||||
label_true = compile_data.get_label()
|
||||
|
@ -849,7 +847,7 @@ def compile_ast(node: ASTnode, compile_data: CompileData) -> None:
|
|||
|
||||
# compile condition
|
||||
compile_ast(node.child_condition, compile_data)
|
||||
compile_data.code.append(Instruction('testq', ['%rax', '%rax']))
|
||||
compile_data.code.append(Instruction('testb', ['%al', '%al']))
|
||||
compile_data.code.append(Instruction('jnz', [label_true]))
|
||||
|
||||
# compile false statements
|
||||
|
|
Loading…
Reference in New Issue