This project is read-only.

Asm in Cosmos

Dec 23, 2010 at 11:45 PM
Edited Dec 23, 2010 at 11:48 PM

Hey i want to know if the Registers in Cosmos.IL2CPU.X86  are really the CPU registers or Will these Enumated registers Send their values to the actual CPU Registers.

 

Dec 24, 2010 at 11:20 AM
Cosmos.IL2CPU is our compiler. Those namespaces are not used at all at runtime.

On Fri, Dec 24, 2010 at 12:45 AM, forest201 <notifications@codeplex.com> wrote:

From: forest201

Hey i want to know if the Registers in Cosmos.IL2CPU.X86 are really the CPU registers or Will these Enumated registers Send their values to the actual CPU Registers.

Read the full discussion online.

To add a post to this discussion, reply to this email (Cosmos@discussions.codeplex.com)

To start a new discussion for this project, email Cosmos@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Dec 24, 2010 at 6:51 PM

Is there a way of Using asm code in cosmos?

Dec 24, 2010 at 9:41 PM

I'd totally LOVE to be able to combine native code with C# in Cosmos.

Like __asm { } and __cpp { } ...

As Cosmos does not target VSE, it will very likely already have C++ and Assembler compilers.

Dec 25, 2010 at 8:22 AM
The only way to use assembly in cosmos is to use plugs with plugassemblers. BUT....

this should (and can be) kept to a minimum, as it will disable that code to be used on other platforms (not applicable yet, but in the future we will be targetting multiple platforms)

What are you trying to achieve?


On Fri, Dec 24, 2010 at 10:41 PM, vercas <notifications@codeplex.com> wrote:

From: vercas

I'd totally LOVE to be able to combine native code with C# in Cosmos.

Like __asm { } and __cpp { } ...

As Cosmos does not target VSE, it will very likely already have C++ and Assembler compilers.

Read the full discussion online.

To add a post to this discussion, reply to this email (Cosmos@discussions.codeplex.com)

To start a new discussion for this project, email Cosmos@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Dec 26, 2010 at 10:40 PM
Edited Dec 26, 2010 at 10:40 PM

I want to Save the State of the Registers and Reload them at a later time. I am trying to implement Multitasking.

 

        ;save all registers in the kernel-level stack of the process and switch to the kernel stack
        cld
        pushad
        push ds
        push es
        push fs
        push gs
        mov eax,[p] ;put the adress of the struct of CURRENT PROCESS in eax.(the CONTENT of pointer p)
        mov [eax],esp ;save esp in the location of esp in the CURRENT PROCESS-STRUCT.
        lea eax,[kstackend] ; switch to the kernel's own stack.
        mov esp,eax

 

                ;Restore all registers

        mov eax,[p] ;put adress of struct of current process in eax.
        mov esp,[eax] ;restore adress of esp.
        mov ebx,[eax+8];put content of the k-stack field into ebx.
        mov [sys_tss+4],ebx ;update system tss.
        mov al,0x20
        out 0x20,al
        pop gs
        pop fs
        pop es
        pop ds
        popad
        iretd

  the rest of code can be written in C# except the ones above.
Dec 30, 2010 at 9:26 PM

How do you  write a method using the AssemeblerMethod{ } I have wrote the above the code for the Assemble Method but i don't know what else to do . I keep getting the same error

 

Error 1 'Cosmos.Kernel.Plugs.Assemblers.Tasking' does not implement inherited abstract member 'Indy.IL2CPU.Plugs.AssemblerMethod.AssembleNew(object, object)'

 

could you please show me an example of how to write a method that uses the AssemeblerMethod function.

 

if it helps the code i have now is

using System;using

Indy.IL2CPU.Assembler;

using System.Collections.Generic;

using Indy.IL2CPU.Assembler.X86;

using Indy.IL2CPU.Plugs;

using Assembler = Indy.IL2CPU.Assembler.Assembler;

using CPUAll = Indy.IL2CPU.Assembler;

using CPUx86 = Indy.IL2CPU.Assembler.X86;

 

    public override void Assemble(Assembler aAssembler)    {          

new CPUAll.Label("_kernel_lbl_int_00");          

new CPUx86.Push {DestinationValue = 0};          

 new CPUx86.Jump { DestinationLabel = "_kernel_lbl_to_kernel"};

 new CPUAll.Label("_kernel_lbl_int40");          

 new CPUx86.Push {DestinationValue = 0};          

 new CPUx86.Push {DestinationValue = 64};          

 new CPUx86.Jump { DestinationLabel = "_kernel_lbl_to_kernel"};


 new CPUAll.Label("_kernel_lbl_to_kernel");          

 new CPUx86.Push {DestinationReg = RegistersEnum.GS};          

 new CPUx86.Push {DestinationReg = RegistersEnum.FS};          

 new CPUx86.Push {DestinationReg = RegistersEnum.ES};          

 new CPUx86.Push {DestinationReg = RegistersEnum.DS};          

 new CPUx86.Push {DestinationReg = RegistersEnum.EBP};          

 new CPUx86.Push {DestinationReg = RegistersEnum.EDI};          

 new CPUx86.Push {DestinationReg = RegistersEnum.ESI};          

 new CPUx86.Push {DestinationReg = RegistersEnum.EDX};          

 new CPUx86.Push {DestinationReg = RegistersEnum.ECX};          

 new CPUx86.Push {DestinationReg = RegistersEnum.EBX};          

 new CPUx86.Push {DestinationReg = RegistersEnum.EAX};


 
new CPUx86.Move {DestinationReg = RegistersEnum.ESP ,SourceReg = RegistersEnum.EBX};          

new CPUx86.Move {DestinationValue = KernelStack , SourceReg = RegistersEnum.ESP};          

new CPUx86.Push {DestinationReg = RegistersEnum.EBX};          

new CPUx86.Move {DestinationValue = 16, SourceReg = RegistersEnum.AX};          

new CPUx86.Move {DestinationReg = RegistersEnum.AX , SourceReg = RegistersEnum.DS};          

new CPUx86.Move {DestinationReg = RegistersEnum.AX , SourceReg = RegistersEnum.ES};          

new CPUx86.Move {DestinationReg = RegistersEnum.AX , SourceReg = RegistersEnum.FS};          

new CPUx86.Move {DestinationReg = RegistersEnum.AX , SourceReg = RegistersEnum.GS};          

ExternalLabel Shell = new ExternalLabel("OSShell.Reada");          

new CPUx86.Call {DestinationLabel = Shell.Name};          

new CPUx86.Pop { DestinationReg = RegistersEnum.EBX};          

new CPUx86.Move { DestinationReg = RegistersEnum.EBX ,SourceReg =  RegistersEnum.ESP };                     

new CPUx86.Pop { DestinationReg = RegistersEnum.EAX};          

new CPUx86.Pop { DestinationReg = RegistersEnum.EBX};          

new CPUx86.Pop { DestinationReg = RegistersEnum.ECX};        

 new CPUx86.Pop { DestinationReg = RegistersEnum.EDX};          

new CPUx86.Pop { DestinationReg = RegistersEnum.ESI};          

new CPUx86.Pop { DestinationReg = RegistersEnum.EDI};          

new CPUx86.Pop { DestinationReg = RegistersEnum.EBP};          

new CPUx86.Pop { DestinationReg = RegistersEnum.DS};          

new CPUx86.Pop { DestinationReg = RegistersEnum.ES};          

new CPUx86.Pop { DestinationReg = RegistersEnum.FS};          

new CPUx86.Pop { DestinationReg = RegistersEnum.GS};          

new CPUx86.Add { DestinationValue = 8 , SourceReg  = RegistersEnum.EDI};          

new CPUx86.InterruptReturn();        }

Dec 31, 2010 at 8:16 AM
an AssemblerMethod implementation is used as implementation for a plug.

Do you understand the meaning of the error message?



On Thu, Dec 30, 2010 at 10:26 PM, forest201 <notifications@codeplex.com> wrote:

From: forest201

How do you write a method using the AssemeblerMethod{ } I have wrote the above the code for the Assemble Method but i don't know what else to do . I keep getting the same error

Error 1 'Cosmos.Kernel.Plugs.Assemblers.Tasking' does not implement inherited abstract member 'Indy.IL2CPU.Plugs.AssemblerMethod.AssembleNew(object, object)'

could you please show me an example of how to write a method that uses the AssemeblerMethod function.

if it helps the code i have now is

using System;using

Indy.IL2CPU.Assembler;

using System.Collections.Generic;

using Indy.IL2CPU.Assembler.X86;

using Indy.IL2CPU.Plugs;

using Assembler = Indy.IL2CPU.Assembler.Assembler;

using CPUAll = Indy.IL2CPU.Assembler;

using CPUx86 = Indy.IL2CPU.Assembler.X86;

public override void Assemble(Assembler aAssembler) {

new CPUAll.Label("_kernel_lbl_int_00");

new CPUx86.Push {DestinationValue = 0};

new CPUx86.Jump { DestinationLabel = "_kernel_lbl_to_kernel"};

new CPUAll.Label("_kernel_lbl_int40");

new CPUx86.Push {DestinationValue = 0};

new CPUx86.Push {DestinationValue = 64};

new CPUx86.Jump { DestinationLabel = "_kernel_lbl_to_kernel"};


new CPUAll.Label("_kernel_lbl_to_kernel");

new CPUx86.Push {DestinationReg = RegistersEnum.GS};

new CPUx86.Push {DestinationReg = RegistersEnum.FS};

new CPUx86.Push {DestinationReg = RegistersEnum.ES};

new CPUx86.Push {DestinationReg = RegistersEnum.DS};

new CPUx86.Push {DestinationReg = RegistersEnum.EBP};

new CPUx86.Push {DestinationReg = RegistersEnum.EDI};

new CPUx86.Push {DestinationReg = RegistersEnum.ESI};

new CPUx86.Push {DestinationReg = RegistersEnum.EDX};

new CPUx86.Push {DestinationReg = RegistersEnum.ECX};

new CPUx86.Push {DestinationReg = RegistersEnum.EBX};

new CPUx86.Push {DestinationReg = RegistersEnum.EAX};


new CPUx86.Move {DestinationReg = RegistersEnum.ESP ,SourceReg = RegistersEnum.EBX};

new CPUx86.Move {DestinationValue = KernelStack , SourceReg = RegistersEnum.ESP};

new CPUx86.Push {DestinationReg = RegistersEnum.EBX};

new CPUx86.Move {DestinationValue = 16, SourceReg = RegistersEnum.AX};

new CPUx86.Move {DestinationReg = RegistersEnum.AX , SourceReg = RegistersEnum.DS};

new CPUx86.Move {DestinationReg = RegistersEnum.AX , SourceReg = RegistersEnum.ES};

new CPUx86.Move {DestinationReg = RegistersEnum.AX , SourceReg = RegistersEnum.FS};

new CPUx86.Move {DestinationReg = RegistersEnum.AX , SourceReg = RegistersEnum.GS};

ExternalLabel Shell = new ExternalLabel("OSShell.Reada");

new CPUx86.Call {DestinationLabel = Shell.Name};

new CPUx86.Pop { DestinationReg = RegistersEnum.EBX};

new CPUx86.Move { DestinationReg = RegistersEnum.EBX ,SourceReg = RegistersEnum.ESP };

new CPUx86.Pop { DestinationReg = RegistersEnum.EAX};

new CPUx86.Pop { DestinationReg = RegistersEnum.EBX};

new CPUx86.Pop { DestinationReg = RegistersEnum.ECX};

new CPUx86.Pop { DestinationReg = RegistersEnum.EDX};

new CPUx86.Pop { DestinationReg = RegistersEnum.ESI};

new CPUx86.Pop { DestinationReg = RegistersEnum.EDI};

new CPUx86.Pop { DestinationReg = RegistersEnum.EBP};

new CPUx86.Pop { DestinationReg = RegistersEnum.DS};

new CPUx86.Pop { DestinationReg = RegistersEnum.ES};

new CPUx86.Pop { DestinationReg = RegistersEnum.FS};

new CPUx86.Pop { DestinationReg = RegistersEnum.GS};

new CPUx86.Add { DestinationValue = 8 , SourceReg = RegistersEnum.EDI};

new CPUx86.InterruptReturn(); }

Read the full discussion online.

To add a post to this discussion, reply to this email (Cosmos@discussions.codeplex.com)

To start a new discussion for this project, email Cosmos@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Dec 31, 2010 at 4:55 PM

 i don't understanding the error code thats why i posted it.

Dec 31, 2010 at 5:10 PM
nothing related to cosmos: please read up on abstract classes and methods in .net.


On Fri, Dec 31, 2010 at 5:55 PM, forest201 <notifications@codeplex.com> wrote:

From: forest201

i don't understanding the error code thats why i posted it.

Read the full discussion online.

To add a post to this discussion, reply to this email (Cosmos@discussions.codeplex.com)

To start a new discussion for this project, email Cosmos@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com