Commit 6f5843e2 authored by Julian Kranz's avatar Julian Kranz

X86 RREIL Translator

- Segmentation
- Cleanup
parent 425b0bf8
...@@ -2,11 +2,6 @@ ...@@ -2,11 +2,6 @@
export = translate translateBlock export = translate translateBlock
val t-mode64? = do
mode64 <- query $mode64;
return mode64
end
val runtime-opnd-sz x = do val runtime-opnd-sz x = do
sz <- sizeof1 x; sz <- sizeof1 x;
return sz return sz
...@@ -82,14 +77,13 @@ type signedness = ...@@ -82,14 +77,13 @@ type signedness =
Signed Signed
| Unsigned | Unsigned
#val segment-add address seg = do val segment-add address seg = let
# addr-with-segment <- mktemp; val seg-sem = SEM_LIN_VAR(semantic-register-of seg)
# seg-sem <- return (semantic-register-of seg); in
# SEM_LIN_ADD{opnd1=seg-sem,opnd2=address}
#end end
#Todo: Für alle Größen automatische Erweiterung (Konfigurierbar auch bei read?) #Todo: Für alle Größen automatische Erweiterung (Konfigurierbar auch bei read?)
#Todo: Segmentation, siehe oben und unten...
val conv-with conv sz x = val conv-with conv sz x =
let let
val conv-imm conv x = case conv of val conv-imm conv x = case conv of
...@@ -135,7 +129,7 @@ val conv-with conv sz x = ...@@ -135,7 +129,7 @@ val conv-with conv sz x =
| MEM x: | MEM x:
do t <- mktemp; do t <- mktemp;
address <- conv-mem x; address <- conv-mem x;
load sz t x.psz address; load sz t x.psz (segment-add address x.segment);
return (var t) return (var t)
end end
end end
...@@ -631,7 +625,7 @@ val sem-call x = do ...@@ -631,7 +625,7 @@ val sem-call x = do
return 32 return 32
; ;
mode64 <- t-mode64?; mode64 <- mode64?;
temp-dest <- mktemp; temp-dest <- mktemp;
temp-ip <- mktemp; temp-ip <- mktemp;
...@@ -791,7 +785,7 @@ val sem-jcc x cond = do ...@@ -791,7 +785,7 @@ val sem-jcc x cond = do
target <- read-flow target-sz x.opnd1; target <- read-flow target-sz x.opnd1;
#Todo: fix #Todo: fix
mode64 <- t-mode64?; mode64 <- mode64?;
opnd-sz <- opnd-sz <-
if mode64 then if mode64 then
return 64 return 64
...@@ -836,7 +830,7 @@ val sem-jmp x = do ...@@ -836,7 +830,7 @@ val sem-jmp x = do
#Todo: Jetzt in Instruktion => x.opndsz #Todo: Jetzt in Instruktion => x.opndsz
opnd-sz <- static-flow-opnd-sz x.opnd1; opnd-sz <- static-flow-opnd-sz x.opnd1;
mode64 <- t-mode64?; mode64 <- mode64?;
ip-sz <- ip-sz <-
if mode64 then if mode64 then
...@@ -1008,8 +1002,16 @@ val ps-pop opnd-sz opnd = do ...@@ -1008,8 +1002,16 @@ val ps-pop opnd-sz opnd = do
sp <- return (semantic-register-of sp-reg); sp <- return (semantic-register-of sp-reg);
sp-size <- sizeof1 (REG sp-reg); sp-size <- sizeof1 (REG sp-reg);
sp-seg <- segmentation-ss-map sp-size sp;
load opnd-sz opnd stack-addr-sz (var sp-seg); mode64 <- mode64?;
segment <-
if mode64 then
return DS
else
return SS
;
load opnd-sz opnd stack-addr-sz (segment-add (var sp) segment);
if stack-addr-sz === 32 then if stack-addr-sz === 32 then
if opnd-sz === 32 then if opnd-sz === 32 then
...@@ -1039,7 +1041,7 @@ val sem-pop x = do ...@@ -1039,7 +1041,7 @@ val sem-pop x = do
end end
val ps-push opnd-sz opnd = do val ps-push opnd-sz opnd = do
mode64 <- t-mode64?; mode64 <- mode64?;
stack-addr-sz <- runtime-stack-address-size; stack-addr-sz <- runtime-stack-address-size;
if mode64 then if mode64 then
do do
...@@ -1051,7 +1053,7 @@ val ps-push opnd-sz opnd = do ...@@ -1051,7 +1053,7 @@ val ps-push opnd-sz opnd = do
else else
sub sp-size sp (var sp) (imm 2) sub sp-size sp (var sp) (imm 2)
; ;
store (address sp-size (var sp)) (lin opnd-sz opnd) store (address sp-size (segment-add (var sp) DS)) (lin opnd-sz opnd)
end end
else else
do do
...@@ -1063,13 +1065,12 @@ val ps-push opnd-sz opnd = do ...@@ -1063,13 +1065,12 @@ val ps-push opnd-sz opnd = do
; ;
sp <- return (semantic-register-of sp-reg); sp <- return (semantic-register-of sp-reg);
sp-size <- sizeof1 (REG sp-reg); sp-size <- sizeof1 (REG sp-reg);
sp-seg <- segmentation-ss-map sp-size sp;
if opnd-sz === 32 then if opnd-sz === 32 then
sub sp-size sp (var sp) (imm 4) sub sp-size sp (var sp) (imm 4)
else else
sub sp-size sp (var sp) (imm 2) sub sp-size sp (var sp) (imm 2)
; ;
store (address sp-size (var sp-seg)) (lin opnd-sz opnd) store (address sp-size (segment-add (var sp) SS)) (lin opnd-sz opnd)
end end
end end
...@@ -1121,7 +1122,7 @@ val sem-ret-far x = ...@@ -1121,7 +1122,7 @@ val sem-ret-far x =
val pop-ip = do val pop-ip = do
#Todo: fix #Todo: fix
mode64 <- t-mode64?; mode64 <- mode64?;
opnd-sz <- opnd-sz <-
if mode64 then if mode64 then
return 64 return 64
...@@ -1152,7 +1153,7 @@ val sem-ret-far-without-operand = do ...@@ -1152,7 +1153,7 @@ val sem-ret-far-without-operand = do
address <- pop-ip; address <- pop-ip;
#Todo: fix #Todo: fix
mode64 <- t-mode64?; mode64 <- mode64?;
opnd-sz <- opnd-sz <-
if mode64 then if mode64 then
return 64 return 64
......
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