From 15a4be17e331475d3237a55d0cde5f0da3f91a9f Mon Sep 17 00:00:00 2001 From: pommicket Date: Wed, 10 Nov 2021 21:20:49 -0500 Subject: add compares to conditional jump instructions --- 02/README.md | 7 +++++-- 02/in01 | 12 ++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/02/README.md b/02/README.md index a114413..1a77e50 100644 --- a/02/README.md +++ b/02/README.md @@ -74,6 +74,9 @@ plus six new ones: - `//` is for comments - `\n\n` does nothing (used for spacing) +Also, the conditional jump instructions now have a `cmp rax, rbx` +built into them. + ## labels Labels are the most important new feature of this language. @@ -174,7 +177,7 @@ the number of blank lines must be a multiple of 3! Many of the limitations of our previous compilers apply to this one. Also, if you use a label without defining it, it uses address 0, rather than outputting an error message. This could be fixed: if the value in the label table is 0 and we are -on the second pass, output an error message. This compiler was already tedious enough -to implement, though! +on the second pass, output an error message. Also, duplicate labels aren't detected. + But thanks to labels, for future compilers at least we won't have to calculate any jump offsets manually. diff --git a/02/in01 b/02/in01 index f72459c..723c5e3 100644 --- a/02/in01 +++ b/02/in01 @@ -14152,20 +14152,20 @@ the formatting changed appropriately. ;00;00;00;00;00;00;00;00 ;00;00;00;00;00;00;00;00 ;00;00;00;00;00;00;00;00 -;02;0f;87;00;00;00;00;00 -;02;0f;82;00;00;00;00;00 +;05;48;39;d8;0f;87;00;00 ja +;05;48;39;d8;0f;82;00;00 jb ;00;00;00;00;00;00;00;00 ;00;00;00;00;00;00;00;00 -;02;0f;84;00;00;00;00;00 +;05;48;39;d8;0f;84;00;00 je ;00;00;00;00;00;00;00;00 -;02;0f;8f;00;00;00;00;00 +;05;48;39;d8;0f;8f;00;00 jg ;00;00;00;00;00;00;00;00 ;00;00;00;00;00;00;00;00 ;00;00;00;00;00;00;00;00 ;00;00;00;00;00;00;00;00 -;02;0f;8c;00;00;00;00;00 +;05;48;39;d8;0f;8c;00;00 jl ;01;e9;00;00;00;00;00;00 -;02;0f;85;00;00;00;00;00 +;05;48;39;d8;0f;85;00;00 jn ;00;00;00;00;00;00;00;00 ;00;00;00;00;00;00;00;00 ;00;00;00;00;00;00;00;00 -- cgit v1.2.3