Commit 6a3ace98 authored by Julian Kranz's avatar Julian Kranz
Browse files

X86 RREIL Translator

- Added semantics for: POP
parent 8771fc9f
...@@ -7,8 +7,9 @@ val t-mode64? = do ...@@ -7,8 +7,9 @@ val t-mode64? = do
return mode64 return mode64
end end
val runtime-opnd-sz = do val runtime-opnd-sz x = do
return 32 sz <- guess-sizeof1 x;
return sz
end end
val address-size = do val address-size = do
...@@ -19,7 +20,7 @@ val runtime-stack-address-size = do ...@@ -19,7 +20,7 @@ val runtime-stack-address-size = do
return 32 return 32
end end
val segmentation-offset-ss-add sz reg = do val segmentation-ss-map sz reg = do
ss <- sdt-ss; ss <- sdt-ss;
t <- mktemp; t <- mktemp;
add sz t (var t) (var ss); add sz t (var t) (var ss);
...@@ -491,11 +492,47 @@ val sem-nop x = do ...@@ -491,11 +492,47 @@ val sem-nop x = do
end end
val sem-pop x = do val sem-pop x = do
return void opnd-sz <- runtime-opnd-sz x.opnd1;
stack-addr-sz <- runtime-stack-address-size;
dst <- write opnd-sz x.opnd1;
temp-dest <- mktemp;
sp-reg <-
if stack-addr-sz === 32 then
return ESP
else if stack-addr-sz === 64 then
return RSP
else
return SP
;
sp <- return (semantic-register-of sp-reg);
sp-size <- guess-sizeof1 (REG sp-reg);
sp-seg <- segmentation-ss-map sp-size sp;
load opnd-sz temp-dest stack-addr-sz (var sp-seg);
if stack-addr-sz === 32 then
if opnd-sz === 32 then
add sp-size sp (var sp) (imm 4)
else
add sp-size sp (var sp) (imm 2)
else if stack-addr-sz === 64 then
if opnd-sz === 64 then
add sp-size sp (var sp) (imm 8)
else
add sp-size sp (var sp) (imm 2)
else
if opnd-sz === 16 then
add sp-size sp (var sp) (imm 2)
else
add sp-size sp (var sp) (imm 4)
#Todo: Special actions in protected mode
end end
val sem-push x = do val sem-push x = do
opnd-sz <- runtime-opnd-sz; opnd-sz <- runtime-opnd-sz x.opnd1;
src-size <- guess-sizeof1 x.opnd1; src-size <- guess-sizeof1 x.opnd1;
src <- read src-size x.opnd1; src <- read src-size x.opnd1;
...@@ -518,7 +555,7 @@ val sem-push x = do ...@@ -518,7 +555,7 @@ val sem-push x = do
end; end;
mode64 <- t-mode64?; mode64 <- t-mode64?;
stack-address-size <- runtime-stack-address-size; stack-addr-sz <- runtime-stack-address-size;
if mode64 then if mode64 then
do do
sp-reg <- return RSP; sp-reg <- return RSP;
...@@ -534,14 +571,14 @@ val sem-push x = do ...@@ -534,14 +571,14 @@ val sem-push x = do
else else
do do
sp-reg <- sp-reg <-
if stack-address-size === 32 then if stack-addr-sz === 32 then
return ESP return ESP
else else
return SP return SP
; ;
sp <- return (semantic-register-of sp-reg); sp <- return (semantic-register-of sp-reg);
sp-size <- guess-sizeof1 (REG sp-reg); sp-size <- guess-sizeof1 (REG sp-reg);
sp-seg <- segmentation-offset-ss-add sp-size sp; 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
......
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