<%@ Page Language="C#" AutoEventWireup="true" CodeFile="index.html.cs" Inherits="XSharp_index" %>

To Do

Call/JumpIf(EAX == 0x04, ....)

Can do reg = reg + 4 - define the + overload as a type that can then be reimplicitly converted to a register, or whatever type goes inside Memory[x]

Make it so X# doesnt require the 32 and that it checks register size Memory[EBX, 32] = ECX;

Register.cs - public void Push() { // TODO: This emits Push dword which generates warnings about dword being ignored new Push { DestinationReg = GetId() }; } |
AL.Push does not work at all.

X#milation would need to be implemented.
  • One of the goals of Cosmos is the need to write very little assembly, so only debug stub, compiler users, etc need assembly. Too much work on X# may not be worth the resources required.
  • Usage

    Register Arithmetic

     EBP = EBP + 32;
    This is not possible because C# operator overloading does not look at return type but only the operand types. That is C# sees Register + int. If we supported the previous example, then X# could not support:
    EAX = Memory[EBP + 4];
    In short, C# sees these two as the same and so X# can only support one. Because the memory addressing is used more frequently than adding a constant to a register, X# supports it.
    To add a constant to a register use:
    EBP.Add(32);

    Register-- / Register++

    Valid and usable. Correspond to Inc and Dec.

    Register Shifting

    Example:
    EAX = EAX << 2;

    Source and destination register must be the same.

    Register Methods

    Register = int

    Example:
    EAX = 0x40;

    Register = Register

    Example:
    EAX = EBP;

    Register = Memory[Address];
    Register = Memory[Address + int];

    Address can be a string label. i.e. EAX = Memory["Data1"]

    Register = Port[x]
    Register = Port[EAX]

    public static implicit operator RegisterEAX(ElementReference aReference) { Instance.Move(aReference); return Instance; }

    Register = Label

    Example:
    EAX = AddressOf("Labelname");