summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--01/in002
-rw-r--r--02/in012
-rw-r--r--03/Makefile2
-rw-r--r--03/in02113
-rw-r--r--03/in037
-rw-r--r--instructions.txt2
6 files changed, 123 insertions, 5 deletions
diff --git a/01/in00 b/01/in00
index 2d5488a..d3d0582 100644
--- a/01/in00
+++ b/01/in00
@@ -12240,7 +12240,7 @@ cc cc cc cc cc cc cc cc
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
-03 f8 d3 f8 00 00 00 00
+03 48 d3 f8 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
diff --git a/02/in01 b/02/in01
index c7e1e8d..b008079 100644
--- a/02/in01
+++ b/02/in01
@@ -12458,7 +12458,7 @@ 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
-;03;f8;d3;f8;00;00;00;00
+;03;48;d3;f8;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
diff --git a/03/Makefile b/03/Makefile
index e25c8f0..dd06acd 100644
--- a/03/Makefile
+++ b/03/Makefile
@@ -1,5 +1,5 @@
all: out02
-out02: in02
+out02: in02 ../02/out01
../02/out01
out03: out02 in03
./out02
diff --git a/03/in02 b/03/in02
index a687e10..5a0f113 100644
--- a/03/in02
+++ b/03/in02
@@ -158,6 +158,10 @@ im
je
:-|= X|=Y
im
+##5e. ascii '^'
+je
+:-^= X^=Y
+im
##3c. ascii '<'
je
:-<= X<=C / X<=imm
@@ -166,6 +170,10 @@ im
je
:->= X>=C / X>=imm
im
+##5d. ascii ']'
+je
+:-]= X]=C / X]=imm
+im
##3d. ascii '='
je
:-x= X=imm / X=:label / X=nY
@@ -322,6 +330,37 @@ jm
:-rl next line
::|B
|B
+// deal with bitwise xor
+::^=
+im
+--=?
+cl
+// put operand 1 in rbx,
+im
+--B1
+cl
+// operand 2 in rax
+im
+--A2
+cl
+// emit 'xor rax, rbx'
+im
+--^B
+IA
+im
+##3.
+DA
+im
+--wr
+cl
+// put rax in operand 1
+im
+--1A
+cl
+jm
+:-rl next line
+::^B
+^B
// deal with left shift
::<=
im
@@ -434,6 +473,62 @@ jm
:-rl next line
::>I
>I
+// deal with arithmetic right shift
+::]=
+im
+--=?
+cl
+im
+--A1 put operand 1 in rax
+cl
+// look at 2nd operand (line[3])
+im
+##3.
+BA
+im
+--LI
++B
+BA
+zA
+lb
+BA
+im
+##43. ascii 'C'
+je
+:-]c non-constant shift
+// write sar rax,
+im
+--]I
+IA
+im
+##3.
+DA
+im
+--wr
+cl
+// now write immediate. calculate number
+im
+##3.
+BA
+im
+--LI
++B
+BA
+im
+--nu
+cl
+// we now have the shift amount in rax. write it to the file
+BA
+im
+--wb
+cl
+im
+--1A put rax back in operand 1
+cl
+jm
+:-rl next line
+::]I
+]I
// left shift by cl
::<c
im
@@ -470,6 +565,24 @@ jm
:-rl next line
::>C
>C
+// arithmetic right shift by cl
+::]c
+im
+--]C
+IA
+im
+##3.
+DA
+im
+--wr
+cl emit 'sar rax, cl'
+im
+--1A put rax back in operand 1
+cl
+jm
+:-rl next line
+::]C
+]C
// deal with set immediate (e.g. "A=d3, B=:label, C=1B")
::x=
im
diff --git a/03/in03 b/03/in03
index 0266447..6d66bf5 100644
--- a/03/in03
+++ b/03/in03
@@ -1,5 +1,10 @@
-D|=C
+
+D]=d7
e
+
+D]=C
+D^=C
+D|=C
D&=C
~C
B|=A
diff --git a/instructions.txt b/instructions.txt
index 88c2a82..7e88f0d 100644
--- a/instructions.txt
+++ b/instructions.txt
@@ -70,7 +70,7 @@ shr rax, cl
shr rax, imm8
>48 c1 e8 IMM8
sar rax, cl
->f8 d3 f8
+>48 d3 f8
sar rax, imm8
>48 c1 f8 IMM8
sub rsp, imm32