LoginSignup
0
0

More than 5 years have passed since last update.

smallbasicでilasm

Posted at

画像

ilasm.PNG

コード

C = Text.GetCharacter(34)
R = Text.GetCharacter(13) + Text.GetCharacter(10)
code = ""
GraphicsWindow.BackgroundColor = "skyblue"
button1 = Controls.AddButton("caption", 350, 400)
Controls.SetButtonCaption(button1, "clr")
button0 = Controls.AddButton("caption", 300, 400)
Controls.SetButtonCaption(button0, "ilasm")
textbox = Controls.AddTextBox(10, 400)
Controls.SetTextBoxText(textbox, "main.il")
mtextbox = Controls.AddMultiLineTextBox(0, 0)
Controls.HideControl(mtextbox)
Controls.SetSize(mtextbox, 580, 380) 
Controls.SetTextBoxText(mtextbox, code)
Controls.Move(mtextbox, 10, 10)
Controls.ShowControl(mtextbox)
Controls.ButtonClicked = output
Sub output
  button = Controls.LastClickedButton
  If (button = button1) Then
    Controls.SetTextBoxText(mtextbox, "")
  ElseIf (button = button0) Then
    file = "c:\il\" + Controls.GetTextBoxText(textbox)
    text = Controls.GetTextBoxText(mtextbox)
    File.WriteContents(file, text)
    csc = "C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\ilasm.exe"
    code = ""
    code = code + "Function setup(a)" + R 
    code = code + "Set obj = CreateObject(" + C + "WScript.Shell" + C + ")" + R
    code = code + "  obj.run " + C + "cmd /K CD c:\il & " + csc + " " + file + " & main.exe" + C + R
    code = code + "setup = "  + C + C + R
    code = code + "End Function" + R
    a = Class1.VBSrun(code)
  endif
EndSub

サンプルコード

.assembly 
extern mscorlib 
{ 
}
.assembly 
main 
{ 
}
.method static void main() cil managed 
{
    .entrypoint
    .maxstack 2
    ldstr "1 + 2 ="
    call void [mscorlib] System.Console::WriteLine(string)
    ldc.i4 1
    ldc.i4 2
    add
    call void [mscorlib]System.Console::WriteLine(int32)
    ldstr "1 - 2 ="
    call void [mscorlib] System.Console::WriteLine(string)
    ldc.i4 1
    ldc.i4 2
    sub
    call void [mscorlib]System.Console::WriteLine(int32)
    ldstr "5 * 3 ="
    call void [mscorlib] System.Console::WriteLine(string)
    ldc.i4 5
    ldc.i4 3
    mul
    call void [mscorlib]System.Console::WriteLine(int32)
    ldstr "10 / 2 ="
    call void [mscorlib] System.Console::WriteLine(string)
    ldc.i4 10
    ldc.i4 2
    div
    call void [mscorlib]System.Console::WriteLine(int32)
    ldstr "10 % 3 ="
    call void [mscorlib] System.Console::WriteLine(string)
    ldc.i4 10
    ldc.i4 3
    rem
    call void [mscorlib]System.Console::WriteLine(int32)
    ret
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0