X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=Mate%2FX86CodeGen.hs;h=724cfc4a8ffacc9d6bb6e469bc862da8c62e9ba8;hb=43956341b5219a74d2ce9f2ace38695528e265bd;hp=a44a5d04f45785afdc7a569b0286a1c57f8c3638;hpb=827ad09b6ff2ec1bf3c13a6a84f046ff3313b9f6;p=mate.git diff --git a/Mate/X86CodeGen.hs b/Mate/X86CodeGen.hs index a44a5d0..724cfc4 100644 --- a/Mate/X86CodeGen.hs +++ b/Mate/X86CodeGen.hs @@ -4,6 +4,7 @@ #include "debug.h" module Mate.X86CodeGen where +import Prelude hiding (and) import Data.Binary import Data.BinaryState import Data.Int @@ -181,12 +182,23 @@ emitFromBB method cls hmap = do add ebx (1 :: Word32) pop ecx -- aref mov (ecx, ebx, S4) eax + emit CASTORE = do + pop eax -- value + pop ebx -- offset + add ebx (1 :: Word32) + pop ecx -- aref + mov (ecx, ebx, S1) eax -- TODO(bernhard): char is two byte emit AALOAD = emit IALOAD emit IALOAD = do pop ebx -- offset add ebx (1 :: Word32) pop ecx -- aref push (ecx, ebx, S4) + emit CALOAD = do + pop ebx -- offset + add ebx (1 :: Word32) + pop ecx -- aref + push (ecx, ebx, S1) -- TODO(bernhard): char is two byte emit ARRAYLENGTH = do pop eax push (Disp 0, eax) @@ -194,6 +206,7 @@ emitFromBB method cls hmap = do emit (NEWARRAY typ) = do let tsize = case decodeS (0 :: Integer) (B.pack [typ]) of T_INT -> 4 + T_CHAR -> 2 _ -> error "newarray: type not implemented yet" -- get length from stack, but leave it there mov eax (Disp 0, esp) @@ -218,6 +231,10 @@ emitFromBB method cls hmap = do mtable <- liftIO $ getMethodTable objname mov (Disp 0, eax) mtable emit (CHECKCAST _) = nop -- TODO(bernhard): ... + emit I2C = do + pop eax + and eax (0x000000ff :: Word32) + push eax emit (BIPUSH val) = push (fromIntegral val :: Word32) emit (SIPUSH val) = push (fromIntegral (fromIntegral val :: Int16) :: Word32) emit (ICONST_0) = push (0 :: Word32)