Skip to content

Commit

Permalink
Implement various ILOpCode math instructions
Browse files Browse the repository at this point in the history
Co-authored-by: Mike Corsaro <[email protected]>
Co-authored-by: Mike Corsaro <[email protected]>
  • Loading branch information
3 people committed Sep 19, 2024
1 parent cdee779 commit 7cf4309
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/dotnes.tasks/Utilities/IL2NESWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,24 @@ public void Write(ILOpCode code, ushort sizeOfMain)
case ILOpCode.Add:
Stack.Push(Stack.Pop() + Stack.Pop());
break;
case ILOpCode.Sub:
Stack.Push(Stack.Pop() - Stack.Pop());
break;
case ILOpCode.Mul:
Stack.Push(Stack.Pop() * Stack.Pop());
break;
case ILOpCode.Div:
Stack.Push(Stack.Pop() / Stack.Pop());
break;
case ILOpCode.And:
Stack.Push(Stack.Pop() & Stack.Pop());
break;
case ILOpCode.Or:
Stack.Push(Stack.Pop() | Stack.Pop());
break;
case ILOpCode.Xor:
Stack.Push(Stack.Pop() ^ Stack.Pop());
break;
default:
throw new NotImplementedException($"OpCode {code} with no operands is not implemented!");
}
Expand Down

0 comments on commit 7cf4309

Please sign in to comment.