OS DEV Language

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Jamethiel

Re:OS DEV Language

Post by Jamethiel »

Solar wrote: ...and what means "rlwinm", again?
Rotate Left Word INsert Masked, wasn't it?

PPC ASM feels like microcoding a LispM sometimes... Some of the instructions have a 1-1 correspondance to the semantics of some microinstructions on the TI Explorer I Raven processor... Far more often than those on the x86.

Anyway, back to on-topic. My last OS was written in a mutant Forth variant. My next OS will probably be written in a mutant Lisp variant. Assuming that I write another one, that is. I haven't been in an OS dev mood recently.

--Jamethiel
ASHLEY4

Re:OS DEV Language

Post by ASHLEY4 »

Hi
I take your point too.
I do not meen that asm is more readable than say C,just it is to me.
I do not do any C programing.But i can see what that code dose,but my girlfriend has not a clue, but she new straight away what this means :

mov ax,4 ; put 4 in to the reg ax :D

And there are so few people capable of doing ASM on the x86 that they are talking about reprogramming the bios in a differant language.

http://news.com.com/2100-7337-5131787.html

ASHLEY4
darklife

Re:OS DEV Language

Post by darklife »

I use NASM most the time. SPHiNX C-- or QBasic PDS 7.1 if I want quick-and-dirty programs. I like C also. Pascal is okay. Everyone likes different programming styles and uses. Each language has its place in the world. Some people just prefer the oddball out of the bunch, but this is what makes programming languages so fun to use- choice. Lately I have been using NASM with a preprocessor I programmed to make it almost like a HLL but not taking away from the assembler. Using this method, I can do something like eax=ebx+(eax/[foobar]) or I can do it long hand in assembly, all within the same source code. Choice is a good thing, but can make things look more complex to the outside world ;)
Combinations of languages is a good thing too. Like C+assembly, Pascal+Basic, or Hybrid+assembly, etc.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:OS DEV Language

Post by Solar »

If your girlfriend is capable of reading Intel syntax right away, she should see a psychologist.

Just kidding. :D
Every good solution is obvious once you've found it.
nullify

Re:OS DEV Language

Post by nullify »

ASHLEY4 wrote:my girlfriend has not a clue, but she new straight away what this means :

mov ax,4 ; put 4 in to the reg ax :D
With the natural-language comment in there telling your girlfriend exactly what the line of code does, it doesn't matter how convoluted the actual code is:

Code: Select all

/* program that inputs a name and outputs a greeting */

int main(int argc,char* argv[]){char name[100];printf("Enter name:");gets(name);printf("Hello, %s!\n",name);return 0;}
Case in point. :-)

However, a simple assignment in C is more self-descriptive:

Code: Select all

x = 4;
and doesn't even require a comment for a non-programmer to figure out that x is being assigned the value of 4.
darklife

Re:OS DEV Language

Post by darklife »

Maybe a programming language that is structured well, but uses very descriptive syntax, would be a good thing?

Code: Select all

ShowUser "Hello, I'm a dumb program\r"
While x = nothing {
   x = ReadKeyboard
}
ShowUser x
Exit
I'd think anyone could understand that :) Almost like pseudo code, but it doesn't have to be.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:OS DEV Language

Post by Solar »

darklife wrote: Maybe a programming language that is structured well, but uses very descriptive syntax, would be a good thing?
The most important thing for a language is that it is understood. Unfortunately, that plays in the ballpark of "compatibility" - not beeing too different.

Code: Select all

ShowUser "Hello, I'm a dumb program\r"
While x = nothing {
   x = ReadKeyboard
}
ShowUser x
Exit
Bad example...

Code: Select all

cout << "Hello, I'm a dumb program" << endl;
string x;
cin >> x;
cout << x << endl;
return;
Not much inroad in readability, there...
Every good solution is obvious once you've found it.
chris

Re:OS DEV Language

Post by chris »

Solar wrote:

Code: Select all

cout << "Hello, I'm a dumb program" << endl;
string x;
cin >> x;
cout << x << endl;
return;
Bit off topic but I'm a C programmer and I was just wondering why C++ uses cout/cin instead of printf/scanf.
Tim

Re:OS DEV Language

Post by Tim »

cin and cout are streams. A stream represents something which looks like a file, but data written to or read from a stream could go to or come from anywhere. Standard types of stream are the file stream (base classes ifstream and ofstream), for reading and writing files; and the string stream (base class strstream), for reading and writing blocks of memory. Of course, you can define you own subclasses which do whatever you want with their data.

You program all streams in the same way, regardless of their type. << is called the insertion operator here, and is used to write. >> is called the extraction operator, and is used to read. Alternatively, streams define the read and write methods, if you prefer to use those. << and >> will behave correctly according to the type you give them, so you don't have to worry about getting the right %s, %d or %f. It's possible to change the formatting used for numbers, though I forget the syntax at the moment.

All in all, streams are a lot more powerful, more extensible, and safer than fprintf, fscanf, fwrite etc. Alternatively, C++ still supports the C functions, so you can use those too.
chris

Re:OS DEV Language

Post by chris »

Thanks :).
Post Reply