This project is read-only.

Using Assembly code in Cosmos User kit (N.B: Milestone 4)

Sep 6, 2010 at 1:20 AM
Edited Sep 6, 2010 at 1:21 AM

Hey i'm trying extend Cosmos Operating System. But i can't find a way to add Assembly code to it. Please show me an example like 

how you would Move  the contents of AX register in BX and  clear AX register.

In  FASM or NASM it would look like this

mov bx,ax

xor ax,ax

but how would it look in Cosmos?

I would really appreciate it if you showed me trick or something to get it done.

also Cpuid is difficult to use.

if I get the code then it would give cosmos the ability to load and execute *.com and  *.bin files and also display files on a disk.

Ohh and If anyone wants   to display Text in a GUI  then please ask me. I would gladly give you the code for it.

N.B: My GUI Text Chars are in Capitals only. I will  add small letters to  it later.

Sep 6, 2010 at 1:34 AM

You can use a plug and X# to write assembly in Cosmos, however its only allowed in the kernel ring and should be avoided. You should not need to write assembly as Cosmos exposes other ways to do things.

It sounds like you want to make a BIOS call? You can't do that in Cosmos because Cosmos runs in 32 bit mode, and BIOS calls are for 16 bit mode only.

Sep 6, 2010 at 9:59 AM

I think we really want to stay away from writing functions in ASM that don't need to be. This is COSMOS not AOSMOS :)

 

Certain things need to be plugged with ASM (for speed, efficiency or because they require something that can't be done in the C# language such as inp/outp) but the rest should be plugged in C# IMO

Sep 6, 2010 at 5:16 PM

So where can I find this X# u where talkin about?

Sep 6, 2010 at 5:20 PM
first, switch over to using devkit (you'll need vs2010 for this), as X# has been HUGELY improved since MS4.

Then, you'll need to add a plug, and then add a plugassembler...


On Mon, Sep 6, 2010 at 6:16 PM, forest201 <notifications@codeplex.com> wrote:

From: forest201

So where can I find this X# u where talkin about?

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


Sep 6, 2010 at 7:09 PM

do you know that System.IO.Directory.Gefiles(String) and System.IO.Directory.GetDirectories(String) Both don't work at all.

Hopefully when I write my asm plug it will be able to list Directories and execute files.

Sep 6, 2010 at 10:25 PM
I'm not sure on the state of MS4, but iirc it should work.

how did you test? be sure to not partition your disk (no fdisk, etc)
and format it using ext2. this means you'll need linux to write to
the disk.
Sep 7, 2010 at 1:56 AM
forest201 wrote:
> So where can I find this X# u where talkin about?

http://www.gocosmos.org/blog/20080428.en.aspx
Sep 7, 2010 at 1:57 AM
forest201 wrote:
> do you know that System.IO.Directory.Gefiles(String) and
> System.IO.Directory.GetDirectories(String) Both don't work at all.
>
> Hopefully when I write my asm plug it will be able to list Directories
> and execute files.

Why would you use ASM to list dirs?
Sep 7, 2010 at 9:23 AM

I don't get it either.

Your code would be unmaintainable and replaced by a C# implementation anyway

Sep 7, 2010 at 4:42 PM

because it's faster and more reliable.I know my Assembly code works because i have tried it over and over again.  System.IO.Directory.GetFiles and System.IO.Directory.GetDirectories both give a System Fault error even if I use it on real hardware or virtual machine(vmware and Qemu). Even  Console.Writeline has problems. Strings work perfectly with it but numbers are another story. So you asm would be great to use in that case. I'm not saying that everything should be written in asm but just  the parts that give problems.

Asm is safer.

And I don't have Visual Studio 2010. I have Visual Studio 2008 professional + SDK 1.1. I tried installing it but it gaves problems on problems. SO isn't there another way of writing asm plugs in Visual Studio 2008? I can't afford Visual Studio 2010 so don't ask me to buy it.

 

Sep 7, 2010 at 6:08 PM
The whole point of Cosmos is to NOT let normal users write assembler code, so the compiler can ensure safety (and performance, later on, but with vmware now being default, that's not really an issue for now..)


I asked you some questions regarding your setup, which you didn't answer yet. Have some followup question: can you post the code which crashes?


On Tue, Sep 7, 2010 at 5:42 PM, forest201 <notifications@codeplex.com> wrote:

From: forest201

because it's faster and more reliable.I know my Assembly code works because i have tried it over and over again.  System.IO.Directory.GetFiles and System.IO.Directory.GetDirectories both give a System Fault error even if I use it on real hardware or virtual machine(vmware and Qemu). Even  Console.Writeline has problems. Strings work perfectly with it but numbers are another story. So you asm would be great to use in that case. I'm not saying that everything should be written in asm but just  the parts that give problems.

Asm is safer.

And I don't have Visual Studio 2010. I have Visual Studio 2008 professional + SDK 1.1. I tried installing it but it gaves problems on problems. SO isn't there another way of writing asm plugs in Visual Studio 2008? I can't afford Visual Studio 2010 so don't ask me to buy 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


Sep 7, 2010 at 6:23 PM
Edited Sep 7, 2010 at 6:37 PM

This is my code for listing directories.

 public static void DirList()      

      {
            var dirs = System.IO.Directory.GetDirectories("/", "P*", System.IO.SearchOption.AllDirectories);  

            Console.WriteLine("Files:");

            for (int i = 0; i < dirs.Length; i++)            

              {      

                    Console.WriteLine(dirs[i]);          

               }
            if (dirs.Length < 1)          

            {    

               Console.WriteLine("No files Found");          

            }          

           OSShell.Reada();   //this is a function that reads console Input and stores it in a string then calls OS functions depending on what the string is equal to or StartsWith.
        }

Sep 7, 2010 at 9:59 PM
OK. as i expected. you're using stuff we did not implement yet.

MS4 supports Directory.GetDirectories(string) and
Directory.GetFiles(string), no other overloads implemented yet. which
is causing your issues...

On 9/7/10, forest201 <notifications@codeplex.com> wrote:
> From: forest201
>
> This is my code for listing directories. public static void DirList()
> {
> var dirs = System.IO.Directory.GetDirectories("/", "P*",
> System.IO.SearchOption.AllDirectories);
> Console.WriteLine("Files:"); for (int i = 0; i < dirs.Length;
> i++) {
> Console.WriteLine(dirs[i]); }
> if (dirs.Length < 1) {
> Console.WriteLine("None files Found"); }
> OSShell.Reada(); //this is a function that reads console Input and
> stores it in a string then calls OS functions depending on what the string
> is equal to or StartsWith.
> }
>
>
Sep 7, 2010 at 10:30 PM

if you're right then should I use System.IO.Directory.GetDirectories("/") instead of  System.IO.Directory.GetDirectories("/","P*",System.IO.SearchOption.AllDectories) ?

what i want to do is list all directories.

so how would you list all files too. Please be specific Don't tell me to use Directory.GetFiles(string) but give me an example. That's how i learn.

 

 

Sep 8, 2010 at 1:13 AM

is it because theres no files or folders in the disk if so why havent have you implementes create directory yet

Sep 8, 2010 at 5:16 AM
We dont support writing yet (not in current development sources either).

For getting a list of files, you do: Directory.GetFiles("/");

One thing to note: you should not partition your harddisk. Then format the disk using Ext2.

/ should contain a list of "directories", where each is a name of a recognized ATA (IDE) disk. What settings do you have ?


On Wed, Sep 8, 2010 at 2:13 AM, xdalutzx <notifications@codeplex.com> wrote:

From: xdalutzx

is it because theres no files or folders in the disk if so why havent have you implementes create directory yet

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


Sep 8, 2010 at 9:42 AM
Edited Sep 8, 2010 at 9:43 AM
forest201 wrote:

 I'm not saying that everything should be written in asm but just  the parts that give problems.

Or write proper implementations in c#? The reason the functions you mentioned don't work is because they haven't been 100% plugged.

Hard coding ASM routines is bad. What happens if the user wants to use a different FS or a ram disk for example?

 

I repeat:

Certain things *MUST* be plugged with ASM but the rest should be plugged in C# 

Sep 8, 2010 at 5:38 PM

So you saying the Partition Manager in Cosmos Doesn't work huh?

Well that's not important now.  

Just like C# and other languages use methods and functions  Assembly also has them if you know  how to use it. The only disadvantage of writing asm code is that some functions would not work with 

certain computers. I know that because asm is the second language i learnt.

But by far Cosmos Seems to have exceeded most operating systems. 

And if any of you are thinking of upgrading Milestone 5 or making another milestone please add support for Printing  Integer variables.

Trying to print a integer variable and it Prints a number that isn't even close to the number in the variable.

My OS is growing quite well thanks to your help. Soon it will support String Manipulation at the user level.

Thanx for your help.

Happy Developing!!!

Sep 8, 2010 at 5:45 PM
What you are doing (probably) is using Console.WriteLine(MyIntValue).
Try: Console.WriteLine(MyIntValue.ToString());

On Wed, Sep 8, 2010 at 6:38 PM, forest201 <notifications@codeplex.com> wrote:

From: forest201

So you saying the Partition Manager in Cosmos Doesn't work huh?

Well that's not important now.  

Just like C# and other languages use methods and functions  Assembly also has them if you know  how to use it. The only disadvantage of writing asm code is that some functions would not work with 

certain computers. I know that because asm is the second language i learnt.

But by far Cosmos Seems to have exceeded most operating systems. 

And if any of you are thinking of upgrading Milestone 5 or making another milestone please add support for Printing  Integer variables.

Trying to print a integer variable and it Prints a number that isn't even close to the number in the variable.

My OS is growing quite well thanks to your help. Soon it will support String Manipulation at the user level.

Thanx for your help.

Happy Developing!!!

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


Sep 8, 2010 at 5:47 PM
Btw, regarding your comment on assembly and methods: we do that, we just dont want people to write too much assembler (they shouldn't need any)


On Wed, Sep 8, 2010 at 6:45 PM, Matthijs ter Woord <matthijsterwoord@gmail.com> wrote:
What you are doing (probably) is using Console.WriteLine(MyIntValue).
Try: Console.WriteLine(MyIntValue.ToString());


On Wed, Sep 8, 2010 at 6:38 PM, forest201 <notifications@codeplex.com> wrote:

From: forest201

So you saying the Partition Manager in Cosmos Doesn't work huh?

Well that's not important now.  

Just like C# and other languages use methods and functions  Assembly also has them if you know  how to use it. The only disadvantage of writing asm code is that some functions would not work with 

certain computers. I know that because asm is the second language i learnt.

But by far Cosmos Seems to have exceeded most operating systems. 

And if any of you are thinking of upgrading Milestone 5 or making another milestone please add support for Printing  Integer variables.

Trying to print a integer variable and it Prints a number that isn't even close to the number in the variable.

My OS is growing quite well thanks to your help. Soon it will support String Manipulation at the user level.

Thanx for your help.

Happy Developing!!!

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



Sep 8, 2010 at 7:34 PM

can u guys tell us exactly how or a place where we can find out how to use memory. btw im using vmware i tried it with a brand neww virtual disk and it still didnt work

Sep 9, 2010 at 1:58 AM

I formated a USB drive using Ext2 on Ubuntu  and add some directories and text files to it. But  the directories don't show in Cosmos On Qemu or Vmware. What could be the problem.

I tried Listing directories usin System.IO.Directory.GetDirectories("/") and System.IO.Directory.GetDirectories("G:/") and System.IO.Directory.GetDirectories("G:\") but it doesn't work at all.

OOh and  the code you gave for printing a integr works fine.

Sep 9, 2010 at 7:23 AM
For formatting, you used a command like mkfs.ext2 /dev/hdaX where X is a number? That means you partitioned. Also, cosmos doesn't support usb..

On Thu, Sep 9, 2010 at 2:58 AM, forest201 <notifications@codeplex.com> wrote:

From: forest201

I formated a USB drive using Ext2 on Ubuntu  and add some directories and text files to it. But  the directories don't show in Cosmos On Qemu or Vmware. What could be the problem.

I tried Listing directories usin System.IO.Directory.GetDirectories("/") and System.IO.Directory.GetDirectories("G:/") and System.IO.Directory.GetDirectories("G:\") but it doesn't work at all.

OOh and  the code you gave for printing a integr works fine.

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


Sep 9, 2010 at 4:59 PM
Edited Sep 9, 2010 at 5:05 PM

so why do you have USB boot

 Can you add C++ DLL to Cosmos Dev Kit?

Sep 9, 2010 at 6:23 PM
USB boot is something else than cosmos using usb: USB boot is a BIOS feature, where the bios knows how to access and use usb etc. Cosmos does not and cannot use USB, so we have to implement USB all by ourselves...


On Thu, Sep 9, 2010 at 5:59 PM, forest201 <notifications@codeplex.com> wrote:

From: forest201

so why do you have USB boot

 

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


Sep 9, 2010 at 6:30 PM

So Can you Use C++ dll in Cosmos Dev Kit?

 

Sep 9, 2010 at 6:31 PM
C++? No. Only managed code (.NET, so C#, VB.NET, F#, etc). I should note, however, that it might be possible that some language (like VB and F#) emit code which for now is incompatible with the cosmos compiler..


On Thu, Sep 9, 2010 at 7:30 PM, forest201 <notifications@codeplex.com> wrote:

From: forest201

So Can you Use C++ dll in Cosmos Dev Kit?

 

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


Sep 9, 2010 at 6:34 PM
Edited Sep 9, 2010 at 6:37 PM

So how am I supposed to Write new Methods in C# when most of C# is not cross-platformed or platform indepent.

 

Sep 9, 2010 at 6:38 PM
Please be specific: what stuff do you want to use?


On Thu, Sep 9, 2010 at 7:34 PM, forest201 <notifications@codeplex.com> wrote:

From: forest201

So how an I supposed to Write new Methods in C# when most of C# is not cross-platformed or platform indepent.

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


Sep 9, 2010 at 6:42 PM

I want to make a FAT32 filesystem but the only thing in C# that is  Cross platform it System.IO.Path class.

Sep 9, 2010 at 6:45 PM
FAT32 support is planned. Will take a bit to implement that though. If you have VS2010 (standard or up) you're welcome to help out on that..

Regarding the "Only thing in c# that is crossplatform.." message: have a look at Mono..

On Thu, Sep 9, 2010 at 7:42 PM, forest201 <notifications@codeplex.com> wrote:

From: forest201

I want to make a FAT32 filesystem but the only thing in C# that is  Cross platform it System.IO.Path class.

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


Sep 9, 2010 at 6:48 PM

So it Cosmos methods  written in Mono?

If so then that simplifies everything.

Sep 9, 2010 at 6:52 PM
No. We (for now) use .NET framework, and "plug" methods which are not working. Plugging basically means replacing the method body with another method body. Some methods are replaced by lowlevel assembly versions, but most are just replaced by c# alternatives. (like the full ATA and Ext2 code is written in pure c#).

Userkit users right now cannot write plugs themselves. We're working on this.

On Thu, Sep 9, 2010 at 7:48 PM, forest201 <notifications@codeplex.com> wrote:

From: forest201

So it Cosmos methods  written in Mono?

If so then that simplifies everything.

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


Sep 9, 2010 at 6:58 PM

One more thing I'm Trying to install Visual Studio Express 2010  but it keeps telling me to Remove Visual C++ 2010 Beta 2  ENU. I have already removed it a long time ago.

I have Download the ISO and web installer over and over but both say the same thing.

Sep 9, 2010 at 7:00 PM
Have a google for that: most likely you need to cleanup something.

One thing to note: express edition is not yet supported...


On Thu, Sep 9, 2010 at 7:58 PM, forest201 <notifications@codeplex.com> wrote:

From: forest201

One more thing I'm Trying to install Visual Studio Express 2010  but it keeps telling me to Remove Visual C++ 2010 Beta 2  ENU. I have already removed it a long time ago.

I have Download the ISO and web installer over and over but both say the same thing.

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


Sep 9, 2010 at 7:03 PM

I know it is not supported. I am going to Update it to Professional after i install it.

Thanx for you help.

Sep 14, 2010 at 1:38 PM
xdalutzx wrote:
> can u guys tell us exactly how or a place where we can find out how to
> use memory. btw im using vmware i tried it with a brand neww virtual
> disk and it still didnt work

In the old code, use unsafe code and pointers. In the new code, use the
memory classes.
Sep 18, 2010 at 8:14 PM

i meant like harddrive memory i would really like to beable to save files