Sample Solution For Tangled Encoding And Assembler
The following is the
AIK
code for the sample solution.
Sample Solution For Tangled Encoding And Assembler
; opcodes are usually the top 8 bits, ; but the top 4 bits define groups with similar properties sys := 0x0:4 0x000:12 jumpr $.a := 0x10:8 .a:4 0:4 neg $.d := 0x11:8 .d:4 0:4 negf $.d := 0x12:8 .d:4 0:4 not $.d := 0x13:8 .d:4 0:4 brf $.c, .addr := 0x2:4 .c:4 (.addr-.):8 brt $.c, .addr := 0x3:4 .c:4 (.addr-.):8 lex $.d, .imm8 := 0x4:4 .d:4 .imm8:8 lhi $.d, .imm8 := 0x5:4 .d:4 .imm8:8 add $.d, $.s := 0x60:8 .d:4 .s:4 mul $.d, $.s := 0x61:8 .d:4 .s:4 slt $.d, $.s := 0x62:8 .d:4 .s:4 and $.d, $.s := 0x63:8 .d:4 .s:4 or $.d, $.s := 0x64:8 .d:4 .s:4 xor $.d, $.s := 0x65:8 .d:4 .s:4 shift $.d, $.s := 0x66:8 .d:4 .s:4 addf $.d, $.s := 0x70:8 .d:4 .s:4 mulf $.d, $.s := 0x71:8 .d:4 .s:4 sltf $.d, $.s := 0x72:8 .d:4 .s:4 recip $.d := 0x74:8 .d:4 0:4 float $.d := 0x78:8 .d:4 0:4 int $.d := 0x79:8 .d:4 0:4 copy $.d, $.s := 0x80:8 .d:4 .s:4 load $.d, $.s := 0x81:8 .d:4 .s:4 store $.d, $.s := 0x82:8 .d:4 .s:4 not @.a := 0x90:8 .a:8 one @.a := 0x91:8 .a:8 zero @.a := 0x92:8 .a:8 had @.a, .imm4 := 0xa:4 .imm4:4 .a:8 cnot @.a, @.b := 0xb0:8 .a:8 .b:8 0:8 swap @.a, @.b := 0xb1:8 .a:8 .b:8 0:8 ccnot @.a, @.b, @.c := 0xc0:8 .a:8 .b:8 .c:8 cswap @.a, @.b, @.c := 0xc1:8 .a:8 .b:8 .c:8 and @.a, @.b, @.c := 0xc3:8 .a:8 .b:8 .c:8 or @.a, @.b, @.c := 0xc4:8 .a:8 .b:8 .c:8 xor @.a, @.b, @.c := 0xc5:8 .a:8 .b:8 .c:8 meas $.d, @.a := 0xe:4 .d:4 .a:8 next $.d, @.a := 0xf:4 .d:4 .a:8 .const r0 r1 r2 r3 r4 r5 r6 r7 r8 r9 r10 at rv ra fp sp .segment .text 16 0x10000 0 .VMEM .segment .data 16 0x10000 0 .VMEM ; synthesized instructions ; treated as SDIs ; really brt $sp, .addr br .addr := 0x3:4 sp:4 (.addr-.):8 ; lex $.d, .imm16 or lex $.d, .imm16 then lhi $.d, (.imm16>>8) load $.d, .imm16 ?(((.imm16&0xff80)==0xff80) || ((.imm16&0xff80)==0x0000)) { := 0x4:4 .d:4 .imm16:8 } load $.d, .imm16 := 0x4:4 .d:4 .imm16:8 0x5:4 .d:4 (.imm16>>8):8 ; br .addr or lex $at, .addr then lhi $at, .addr then jumpr $at jump .addr ?(((.addr-.)>=-128)&&((.addr-.)<=127)) { := 0x3:4 sp:4 (.addr-.):8 } jump .addr := { 0x4:4 at:4 .addr:8 0x5:4 at:4 (.addr>>8):8 0x10:8 at:4 0:4 } ; brt or sequence of brf, lex, lhi, jumpr jumpt $.d, .addr ?(((.addr-.)>=-128)&&((.addr-.)<=127)) { := 0x3:4 .d:4 (.addr-.):8 } jumpt $.d, .addr := { 0x2:4 .d:4 4:8 0x4:4 at:4 .addr:8 0x5:4 at:4 (.addr>>8):8 0x10:8 at:4 0:4 } ; brf or sequence of brt, lex, lhi, jumpr jumpf $.d, .addr ?(((.addr-.)>=-128)&&((.addr-.)<=127)) { := 0x2:4 .d:4 (.addr-.):8 } jumpf $.d, .addr := { 0x3:4 .d:4 4:8 0x4:4 at:4 .addr:8 0x5:4 at:4 (.addr>>8):8 0x10:8 at:4 0:4 }
Sample Assembly Language Input
.text start: add $1, $2 addf $1, $2 and $1, $2 br start brf $1, start brt $1, start copy $1, $2 float $1 int $1 jump more jumpf $1, start jumpr $1 jumpt $1, start lex $1, -1 lhi $1, 0x42 load $1, $2 load $1, 480 mul $1, $2 mulf $1, $2 neg $1 negf $1 not $1 or $1, $2 recip $1 shift $1, $2 slt $1, $2 sltf $1, $2 store $1, $2 sys xor $1,$2 .data ; switch to data segment .word 0x42 .text ; back to text segment more: and @1, @2, @3 ccnot @1, @2, @3 cnot @1, @2 cswap @1, @2, @3 had @1, 0 meas $1, @1 next $1, @1 not @1 or @1, @2, @3 one @1 swap @1, @2 xor @1, @2, @3 zero @1
Advanced Computer Architecture.