Commit cec87fc2 authored by Benedikt Geßele's avatar Benedikt Geßele

mips BITSWAP

parent 76e69141
......@@ -158,6 +158,39 @@ val sem-bnec x = sem-b /neq x
val sem-beqzc x = sem-bz /eq x
val sem-bnezc x = sem-bz /neq x
val sem-bitswap-byte rt rd byte_num i = do
if (not (i === 7)) then do
mov 1 (at-offset rd ((byte_num * 8) + (7-i))) (var (at-offset rt ((byte_num * 8) + i)));
sem-bitswap-byte rt rd byte_num (i+1)
end
else
mov 1 (at-offset rd ((byte_num * 8) + (7-i))) (var (at-offset rt ((byte_num * 8) + i)))
end
val sem-bitswap-word rt rd byte_num = do
if (not (byte_num === 3)) then do
sem-bitswap-byte rt rd byte_num 0;
sem-bitswap-word rd rd (byte_num + 1)
end
else
sem-bitswap-byte rt rd byte_num 0
end
val sem-bitswap x = do
rd <- lval Signed x.op1;
rt <- rval Signed x.op2;
size <- return (sizeof-lval x.op1);
rt_in <- mktemp;
mov size rt_in rt;
rd_out <- mktemp;
mov size rd_out (imm 0);
sem-bitswap-word rt_in rd_out 0;
write x.op1 (var rd_out)
end
val revision/semantics i =
case i of
ADDIUPC x: sem-addiupc x
......@@ -189,4 +222,5 @@ val revision/semantics i =
| BNEC x: sem-bnec x
| BEQZC x: sem-beqzc x
| BNEZC x: sem-bnezc x
| BITSWAP x: sem-bitswap x
end
......@@ -29,4 +29,5 @@ val revision/traverse f insn =
| BNEC x: f "BNEC" (TERNOP_RRR x)
| BEQZC x: f "BEQZC" (BINOP_RR x)
| BNEZC x: f "BNEZC" (BINOP_RR x)
| BITSWAP x: f "BITSWAP" (BINOP_LR x)
end
......@@ -161,6 +161,10 @@ val / ['110110 /rs /offset21']
val / ['111110 /rs /offset21']
| bnezc? = binop BNEZC (right rs) offset23
### BITSWAP
### - Swaps (reverses) bits in each byte
val / ['011111 00000 /rt /rd 00000 100000'] = binop BITSWAP rd (right rt)
### LUI
### - Load Upper Immediate
### => see AUI r0, rt, immediate16
......@@ -196,6 +200,7 @@ type instruction =
| BNEC of ternop-rrr
| BEQZC of binop-rr
| BNEZC of binop-rr
| BITSWAP of binop-lr
type imm =
IMM21 of 21
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment