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