This project is read-only.

How to get values of All CPU registers using Cosmos ASM code?

Topics: Developing Cosmos (Working on Cosmos source code directly), Using Cosmos (Developing your own OS, projects, etc)
Dec 6, 2012 at 2:52 PM

I have tried to do this:

 

public static void SaveRegsEx()
{
    new CPUx86.Move { SourceReg = CPUx86.Registers.EBX, DestinationReg = CPUx86.Registers.EAX };
    new CPUx86.Move { SourceReg = CPUx86.Registers.EAX, DestinationValue = STACK.aNew.EBX};
}
STACK.aNew is a TSS structure.

Dec 6, 2012 at 5:47 PM
Is this using X#?






On Thu, Dec 6, 2012 at 7:52 AM, forest201 <notifications@codeplex.com> wrote:

From: forest201

I have tried to do this:

public static void SaveRegsEx()
{
    new CPUx86.Move { SourceReg = CPUx86.Registers.EBX, DestinationReg = CPUx86.Registers.EAX };
    new CPUx86.Move { SourceReg = CPUx86.Registers.EAX, DestinationValue = STACK.aNew.EBX};
}
STACK.aNew is a TSS structure.

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 6, 2012 at 6:04 PM
Edited Dec 6, 2012 at 6:05 PM

No it is not X# but i am using Cosmos Direct Assembly!

Dec 6, 2012 at 10:32 PM

C# supports direct assembly?!

On Dec 6, 2012 11:04 AM, "forest201" <notifications@codeplex.com> wrote:

From: forest201

No using Direct Assembly!

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 7, 2012 at 12:11 PM
joshbeitler wrote:

C# supports direct assembly?!


yeh most of x86 instructions  using the Cosmos.Compiler.Assembler.x86 namespace.

Dec 7, 2012 at 4:08 PM

new CPUx86.Move(SourceReg = CPUx86.Registers.EBX, DestinationReg = CPUx86.Registers.EAX) would compile to

MOV EBX, EAX.

Just change the dev kit.

Dec 7, 2012 at 7:15 PM

How would you write a Value let's say "0x80000000 to EAX or any other general purpose register  using the Cosmos.Assemble.X86 or Cosmos.Compiler.Assembler.x86 namspace?

 

I would like to do this:

MOV EAX, 0x80000000

I have tried this:

 new CPUx86.Move { DestinationReg = CPUx86.Registers.EAX , SourceValue = 0x80000000 }

 

but when i read EAX or any other register i don't get the value i wrote to it using the above code.

Dec 7, 2012 at 7:20 PM

It is a compiler facility. Its to be used as part of plug methods..

Op 7 dec. 2012 20:15 schreef "forest201" <notifications@codeplex.com> het volgende:
>
> From: forest201
>
> How would you write a Value let's say "0x80000000 to EAX or any other general purpose register using the Cosmos.Assemble.X86 or Cosmos.Compiler.Assembler.x86 namspace?
>
>
>
> I would like to do this:
>
> MOV EAX, 0x80000000
>
> I have tried this:
>
> new CPUx86.Move { DestinationReg = CPUx86.Registers.EAX , SourceValue = 0x80000000 }
>
>
>
> but when i read EAX or any other register i don't get the value i wrote to it using the above code.
>
> 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 7, 2012 at 9:22 PM

What value do you get? Could it be a little/big endian error?

Dec 8, 2012 at 1:29 PM
Edited Dec 8, 2012 at 1:30 PM

Lets say i write 0x80000000 to EAX, i would probably get a value that was in EAX originally. Its like 0x80000000 wasn't copied to EAX at all. 

Dec 8, 2012 at 3:06 PM

Can you post a complete sample of your code?

Op 8 dec. 2012 14:29 schreef "forest201" <notifications@codeplex.com> het volgende:

From: forest201

Lets say i write 0x80000000 to EAX, i would probably get a value that was in EAX originally. Its like 0x80000000 wasn't copied to EAX at all.

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 9, 2012 at 5:58 PM

Maybe it copies the dword at 0x80000000 to EAX.

Dec 10, 2012 at 2:30 PM
Edited Dec 10, 2012 at 2:30 PM
mterwoord wrote:

Can you post a complete sample of your code?


 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Cosmos.IL2CPU.Plugs;
using Assembler = Cosmos.Compiler.Assembler.Assembler;
using CPUx86 = Cosmos.Assembler.x86;

namespace CKT
{
    [Plug(Target = typeof(Stack))]
    public class StackImpl
    {

        [Inline]
        public static void Experiment()
        {

            new CPUx86.Mov
            {
                DestinationReg = CPUx86.Registers.EAX,
                SourceValue = 0x80000000
            };
        }
    }
}
Dec 10, 2012 at 2:52 PM
Ok, So you're trying to retrieve the EAX in a different method?
probably wont work, as EAX is used as method return value.

On Mon, Dec 10, 2012 at 3:30 PM, forest201 <notifications@codeplex.com> wrote:

From: forest201

mterwoord wrote:

Can you post a complete sample of your code?

Op 8 dec. 2012 14:29 schreef "forest201" <notifications@codeplex.com> het volgende:

From: forest201

Lets say i write 0x80000000 to EAX, i would probably get a value that was in EAX originally. Its like 0x80000000 wasn't copied to EAX at all.

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

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Cosmos.IL2CPU.Plugs;
using Assembler = Cosmos.Compiler.Assembler.Assembler;
using CPUx86 = Cosmos.Assembler.x86;

namespace CKT
{
    [Plug(Target = typeof(Stack))]
    public class StackImpl
    {

        [Inline]
        public static void Experiment()
        {

            new CPUx86.Mov
            {
                DestinationReg = CPUx86.Registers.EAX,
                SourceValue = 0x80000000
            };
        }
    }
}

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