Page 2 of 2

Re:OS DEV Language

Posted: Mon Feb 23, 2004 10:08 am
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

Re:OS DEV Language

Posted: Mon Feb 23, 2004 10:22 am
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

Re:OS DEV Language

Posted: Mon Feb 23, 2004 11:42 am
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.

Re:OS DEV Language

Posted: Mon Feb 23, 2004 12:27 pm
by Solar
If your girlfriend is capable of reading Intel syntax right away, she should see a psychologist.

Just kidding. :D

Re:OS DEV Language

Posted: Mon Feb 23, 2004 2:54 pm
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.

Re:OS DEV Language

Posted: Tue Feb 24, 2004 3:38 am
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.

Re:OS DEV Language

Posted: Tue Feb 24, 2004 3:53 am
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...

Re:OS DEV Language

Posted: Tue Feb 24, 2004 3:29 pm
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.

Re:OS DEV Language

Posted: Tue Feb 24, 2004 4:37 pm
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.

Re:OS DEV Language

Posted: Tue Feb 24, 2004 5:29 pm
by chris
Thanks :).