fix: added dword in sizedir
This commit is contained in:
parent
fb91dc89ee
commit
62df2c2244
@ -260,9 +260,9 @@ object asmGenerator {
|
||||
chain ++= evalExprOntoStack(x)
|
||||
op match {
|
||||
case UnaryOperator.Chr | UnaryOperator.Ord | UnaryOperator.Len => // No op needed
|
||||
case UnaryOperator.Negate => chain += Negate(stack.head(SizeDir.Word))
|
||||
case UnaryOperator.Negate => chain += Negate(stack.head(SizeDir.DWord))
|
||||
case UnaryOperator.Not =>
|
||||
chain += Xor(stack.head(SizeDir.Word), ImmediateVal(1))
|
||||
chain += Xor(stack.head(SizeDir.DWord), ImmediateVal(1))
|
||||
}
|
||||
|
||||
case BinaryOp(x, y, op) =>
|
||||
@ -272,27 +272,27 @@ object asmGenerator {
|
||||
chain += stack.pop(RAX)
|
||||
|
||||
op match {
|
||||
case BinaryOperator.Add => chain += Add(stack.head(SizeDir.Word), EAX)
|
||||
case BinaryOperator.Add => chain += Add(stack.head(SizeDir.DWord), EAX)
|
||||
case BinaryOperator.Sub =>
|
||||
chain += Subtract(EAX, stack.head(SizeDir.Word))
|
||||
chain += Subtract(EAX, stack.head(SizeDir.DWord))
|
||||
chain += stack.drop()
|
||||
chain += stack.push(RAX)
|
||||
case BinaryOperator.Mul =>
|
||||
chain += Multiply(EAX, stack.head(SizeDir.Word))
|
||||
chain += Multiply(EAX, stack.head(SizeDir.DWord))
|
||||
chain += stack.drop()
|
||||
chain += stack.push(RAX)
|
||||
|
||||
case BinaryOperator.Div =>
|
||||
chain += Compare(stack.head(SizeDir.Word), ImmediateVal(0))
|
||||
chain += Compare(stack.head(SizeDir.DWord), ImmediateVal(0))
|
||||
chain += Jump(LabelArg(zeroDivError.errLabel), Cond.Equal)
|
||||
chain += CDQ()
|
||||
chain += Divide(stack.head(SizeDir.Word))
|
||||
chain += Divide(stack.head(SizeDir.DWord))
|
||||
chain += stack.drop()
|
||||
chain += stack.push(RAX)
|
||||
|
||||
case BinaryOperator.Mod =>
|
||||
chain += CDQ()
|
||||
chain += Divide(stack.head(SizeDir.Word))
|
||||
chain += Divide(stack.head(SizeDir.DWord))
|
||||
chain += stack.drop()
|
||||
chain += stack.push(RDX)
|
||||
|
||||
@ -302,8 +302,8 @@ object asmGenerator {
|
||||
case BinaryOperator.GreaterEq => chain ++= generateComparison(x, y, Cond.GreaterEqual)
|
||||
case BinaryOperator.Less => chain ++= generateComparison(x, y, Cond.Less)
|
||||
case BinaryOperator.LessEq => chain ++= generateComparison(x, y, Cond.LessEqual)
|
||||
case BinaryOperator.And => chain += And(stack.head(SizeDir.Word), EAX)
|
||||
case BinaryOperator.Or => chain += Or(stack.head(SizeDir.Word), EAX)
|
||||
case BinaryOperator.And => chain += And(stack.head(SizeDir.DWord), EAX)
|
||||
case BinaryOperator.Or => chain += Or(stack.head(SizeDir.DWord), EAX)
|
||||
}
|
||||
|
||||
case call: microWacc.Call =>
|
||||
@ -353,7 +353,7 @@ object asmGenerator {
|
||||
chain ++= evalExprOntoStack(x)
|
||||
chain ++= evalExprOntoStack(y)
|
||||
chain += stack.pop(RAX)
|
||||
chain += Compare(stack.head(SizeDir.Word), EAX)
|
||||
chain += Compare(stack.head(SizeDir.DWord), EAX)
|
||||
chain += Set(Register(RegSize.Byte, RegName.AL), cond)
|
||||
chain += And(RAX, ImmediateVal(_8_BIT_MASK))
|
||||
chain += stack.drop()
|
||||
|
@ -174,13 +174,14 @@ object assemblyIR {
|
||||
}
|
||||
|
||||
enum SizeDir {
|
||||
case Byte, Word, Unspecified
|
||||
case Byte, Word, DWord, Unspecified
|
||||
|
||||
private val ptr = "ptr "
|
||||
|
||||
override def toString(): String = this match {
|
||||
case Byte => "byte " + ptr
|
||||
case Word => "dword " + ptr // TODO check word/doubleword/quadword
|
||||
case Word => "word " + ptr // TODO check word/doubleword/quadword
|
||||
case DWord => "dword " + ptr
|
||||
case Unspecified => ""
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user