diff options
-rw-r--r-- | 01/in00 | 2 | ||||
-rw-r--r-- | 02/in01 | 2 | ||||
-rw-r--r-- | 03/Makefile | 2 | ||||
-rw-r--r-- | 03/in02 | 113 | ||||
-rw-r--r-- | 03/in03 | 7 | ||||
-rw-r--r-- | instructions.txt | 2 |
6 files changed, 123 insertions, 5 deletions
@@ -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 @@ -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 @@ -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 @@ -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 |