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

X#

X# compiles C# code into assembly, but does it as it runs. This allows the use of intellisense, and modification of the output using C#.

  • 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.
  • Consts

    ref with #. else user would need to use @, and if not woudl get [value] instead. ie consts have direct ref as default while fields have indirect as default. Also treat consts diff since they can only be read from and not assigned, and at parse time we dont know if a label is const, var or other.

    all consts are group based. Need provision for globals in future. Consts cannot be local.

    Method

    name()

  • Usage

    look in tokenpatterns.cs for more

    Labels

    ..Global

    .Group

    Local

    Think of it like a directory path, .. and . are up.

    Checkpoint 'text'

     

    if reg = x goto label

    =
    !=
    >
    >=
    <
    <=

    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 << 2

    Rotate

     ~ "infinite" shift because it loops

    Register Methods

    Register = int

    Example:
    EAX = $40
    EAX = 64

    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(Cosmos.Assembler.ElementReference aReference) { Instance.Move(aReference); return Instance; }

    Register = Label

    Example:
    EAX = AddressOf("Labelname");