How do you write a program using binary code? Without using any other programs? Like.. basically.. How do you program something from nothing? What comes before DOS?
We don't need no education.. We don't need no thought control..
Printable View
How do you write a program using binary code? Without using any other programs? Like.. basically.. How do you program something from nothing? What comes before DOS?
We don't need no education.. We don't need no thought control..
Actually, I'm curious about that too.
That's a good song, by the way.
You don't write programs in binary code...you have to use some sort of language and compiler/interpreter.
If your interested in low levels languages..Try Assembly...
Assembly is as low level as it gets...next to machine language (binary).
Sencond...What do you mean...What comes before DOS?
Clarification is Needed !
Hope This Has Helped :)
Maybe something like this.
11100100 {Begin Prog}
01001001{Var}
01000111
00100100
00110110
10001010
01001001
01000100
10010010
01001001
01001101
01001000{End Prog}.:)
Okay.. let's say.. first of all, I'm just getting ahead of myself as far as school goes, I don't think I'll be up to this for some time.. But.. I'd like to make my own motherboard let's say.. (If you know anything about that.. like where I can get parts to build it, etc.. please include whatever you know) Okay, so after you get your motherboard.. You have DOS.. How do you program DOS? I mean.. It's a basic output system.. and.. now this is gonna sound like a religious.. "who made god, who made the creator of god, repeat.." question.. but.. how do you program an OS or a compiler without an OS or a compiler..???
Who says the phonograph is out of style???
Ok...Maybe I can clear some of the misconception here... :)
On your motherboard is a chip..that contains the BIOS (Basic Input Output System)
The BIOS is what communicates with the hardware...The "DOS" that you have been referring to...is in essense "DOS", but is not.... The "DOS" within the BIOS only supports a handful of commands (The actual DOS (Disk Operating System) is as it's name implies an operating system!) . But there is such as thing as a LINUX BIOS (It comes as a chip that replaces the old BIOS)
Now... All an operating system is...Is a piece of system software that takes user input and "interprets" it into the language of the BIOS, which is then responsible for communicating with the hardware. :)
Please Keep This In Mind: The only language the computer actually understands is Binary (1's & 0's) ALL data is converted into binary. :)
I hope this has helped :)
That cleared up more than you know. Thanks. :p
From memory... So not entirely accurate.
In the beginning, there was Babbage. (Sort of.) And this Babbage character tried to make a 'difference engine', basically an extremely simple calculator out of gears and cogs and mechanical stuff. Whether he completed it or it worked... dunno, but he had an influence.
Then came vacuum tubes, these tubes had a (gasp!) vacuum (nearly) inside, and were basically old-and-bulky (size of your thumb) transistors. A transistor is a very simple circuit component which has three wires. If the third wire has current on it, current will flow between the other two wires. It was, in essence, a switch, and could be turned on by giving it electricity.
Then came a time when almost all programming was done by purely hardware methods. (See ENIAC) Eventually true NPN/PNP (not Plug'n'Play) transistors were developed, and vacuum tubes done away with. Then came Von Neuman, or, at any rate, ideas of his. And then things started to use software as well as hardware, and ways were introduced to approximate a series of signals as a series of transistor switches!
In other words, you could turn a string of 1's and 0's into a function for manipulating MORE 1's and 0's! Holy smokes! How did they do that? The hardware is still the same... I can't answer too well without looking it up.
Then you got some lady called (Researched this...) Grace Murray Hopper. (End research.) She figured out how to make the first computer compiler. Before this, people had to program in long, tedious, tortuous binary. Although sometimes they used Hexedecimal notation to shorten the amount of writing they needed to do, and to make it look clearer.
I'm not sure if Assembly came before the compiler, I think it might have been the first compiled language. At any rate, things exploded from there, with more and more complexity in each sucessive language, and more routines to break each language down to machine code.
So, theoretically, the .exe file contains the source code that the person wrote... the problem is that deciphering the stream of binary is a monumental task, and putting it back into C++ or whatever it came from takes so long that nobody really bothers. But it is possible to change it to Assembly, the closest thing to writing ones and zeroes that anyone (who doesn't have serious psychological problems) gets to these days.
Okay, back. I had to catch my virtual breath. Now I shall impart what my sieve-like mind caught from last-year's A+ certification class... (Haven't taken test yet.)
On to BIOS. Now, motherboards have their own processors on them, in a sense. They just are specialized chips (the northbridge and southbridge chips, in certain terminologies.) To make your own motherboard would be quite a challenge, and you'd need a manufacturing plant to do a good job.
BIOS stands for Basic Input/Output System (Although some call it a Service instead of a System.) BIOS is often on a small chip on your motherboard, and it translates some of the most basic functions, allowing a program to show a pixel on the monitor, or to get data from a PCI card, getting keyboard commands... etc. These are usually motherboard-specific, because motherboard hardware can vary to a significant degree (Within the AT/X form factors, and more if you include the low-profile ones with riser cards and stuff.)
As for making an OS/Compiler without either... see my previous post. It's sort of founded on itself. Nowadays we use computers to design computers to design computers... It keeps going. (And happens in several other technological areas too).
Hardware transistor switches arrayed in mind-boggling complexity... Then Machine code which could make something new happen, without having to physically reprogram the machine by moving circuit components... then a compiler to let people use shortcuts to machine code... then a compiler to let people use neater shortcuts... and a new one to use even neater shortcuts to machine code... So on and so forth.
I'd just like to say thank you to Terr. Good information. It answers a question, similiar to TeKRoMaNCeR's that I have thought about.
hey TeKRoMaNCeR:
read que's dos programmer's reference. it explains all. very good book. old but very informative. it even tells you who/what MZ is. (MZ is the first 2 characters of any .exe progs in the dos realm) talks about "created by.. stuffs".
Que Programmers.... who's the author, I'll look for it... =]
Also... Terr.. you seem to be the expert in this.. Is there a class like that... very obsolete learning...? I mean.. yeah, I'm gonna take binary coding when it's available (when I meet all the prerequisites)... But.. I think more than ever, we should learn how to build a computer from scratch... let's say we had.. uh.. inexplicably a crazy emp war.. and everything was fried.... who would build the comps? Bill Gates? And what.. sell them for 100k a piece? Ha.. I'll build my own thanks.. you know... our technology doubles every 3 months.. are we gonna be the aliens visiting other planets taking over their resources? Hehe.. I don't know.. advice... sleep IS your friend... The computer is a good friend too.. but... it's like my dog, it always wants to play... and doesn't realize the value of sleep.. END POST! NOW!.. zzzzzzz
Well, the making of a motherboard aside, if your wanting to write your own OS in Assembly, and are using an Intel Processor, I have *somewhere* alot of technical documentation from Intel with heaps of assembly information.. If you want it, I'm sure I could dig through my hard drive and find it for you...
Additionally, one of my friends attempted to write his own in Assembly, and I'm sure he has some resources that would be quite helpful for you..
Hey Terr: Have you read William Gibsons book "The difference engine"???? I have just started the same.
After reading "Neuromancer" and "Mona Lisa Overdrive" just could not resist the idea of "what if" the difference engine had actually worked.
The civil war (U.S) might have been a monsterous affair, not to mention the "war to end all wars". :)
With All the binary in the Air for this thread, i thought i'd change it slightly, and say ... this is where hex comes into play.
U dont program in binary, u can however program in hex. Assemblers are very simple Compilers basicly, Assembly is the lowest form of language to people, but when u assemble it, it gets converted into hex. It is this that gets executed by the processor (after conversion into binary).
So from this i'll do a simple example .....
Using most versions of DOS comes a simple debugger ("Debug.exe") using this u can program .com files in assembly, and it will convert the whole file into hex. now with .com files they are an exact copy of the program code (no header info besides the identifyer), they are limited in size to 64k.
if u start debug up preceded by a non existant file name it just gives u a
-
Hit A to enter assemble mode.
it will display the first memory adderss and await input.
then enter your first Assembly instruction.
Hit enter, then enter next instruction...... etc
when done, leave a blank line and just hit enter.
it should look something like this:
C:\>debug blah.com
-A
0B31:0100 mov ax,4c
0B31:0102 int 21h
0B31:0104
-
back to the -
from here we need to enter the amount of bytes to save to the file.
this is stored in the CX register.
so if u type rcx , it will display the current value and prompt u for a new value.
u need to enter the the difference between your start address (in this case 100 (for all com files) ) and your finish address (in my case 104).
so the total leaving 4, so put 4 in CX.
then just hit w to write the data to the file and q if u want to quit.
the output will contain your hexadecimal equivalent to your assembly instructions.
The file will run as a normal .com file (all it does is return control to DOS, if u write anything bigger u need those 2 instructions on the end or the program will crash after execute).
all so simple ...
What the file contains in ascii : ¨YL ¨T!
The Hexadecimal reprisentation in the file each represents an Assembly instruction ... eg 2B 4C (as the first 2 bytes in the file) This is the same as mov AX,4C
u get idea.
using debug u can display the results of your program using the T and the prompt, that will trace through the code and u can see the memory addresses, hex opcodes, operands and registers. quite a powerfull tool (although not as strong as gdb :) )
And thats basicly how it works. if u know the hex opcodes your blown in (there are hundreds of thousands and very between processor platforms).
heh, sorry this post was a little big, just wanted to explain it well. (although i am drunk and tired).
:D
Underneath your C++ programming is actual Assembler (which in its self is represented by Hex code). All your compiler does is change what you wrote, using its language specific rules, into the processor specific assembler code. Remember that this is a computer doing the conversion so in no way is it perfect.
An example of a reason to want to program in assembler is sometimes you might find that a program has one specific error in it that you are unable to fix normally. In this case you would have to go underneath and manually change the Assembler representation of that code to fix the bug. Many compilers will output your code into Assembler if you're interested in taking a look or changing things.
Continuing, there are different processors and all processors are slightly different depending on their manufacturer and architecture. The MC68HC11 processor made by motorola has, for example, a built in stack. Other processors (ie. AMD and Intel) might not. Another characteristic that is specific to processors is the hex code for different commands (ie. Hex for LDAA which means load accumulator A for the 68HC is 86). Different processors will have different numbers of accumulators, different sizes of accumulators, store the program code in different spots in memory, handle interupts differently, etc etc.
As for programming an OS in Hex/Binary, my advice is DON'T. If you have the urge for programming it in assembler, go right ahead but it will take you a very long time. There is a reason that high-level languages were invented. Though they waste a lot of assembler code, your compiler is a lot better at remembering where you stored that variable in memory, etc.
On the other side of things: Programs written in Assembler are FAST! Like I said, compilers waste a good deal of commands in assembler and that means processor time. I have had prof's who swear by assembler (they all seemed a little nutz to me though). If you're interested in learning I've put up a sample program in my yahoo briefcase. It's just a vending machine, nothing special, and was written specifically for the 68HC11. Don't have a motorola processor? Don't worry, I included a compiler and simulator with the program in the zip. See the readme for info.
The link to it is here: http://briefcase.yahoo.com/grande_stronzo
As for MAKING your own mother board. Well, I don't know how up to date your circuit analysis is but... ;)
Hey, thanks for all the enlightening messages.. I think I'm gonna wait until I actually take a class on it.. I don't think it's something I'd be very good at learning on my own..
I'm hungry..
hey man enode..that is great knowledge about assembly .
i am very much interested in assembly as i am a C and unix programmer...but u see i am not getting ..basic tutorials on the net which teaches u about assembly.
u know just like "Assembly for beginners or for dummies" as i want to learn assembly language.
so can u pls tell me from where can i get this type of documents or tutorials on assembly.
i am requesting to all of u if anybody knows ..from where willl i get basic tutorials on Assembly programming.
thank u.....
intruder..... :borg:
Try here: UVic CSC 230 Lecture Slides. Like I said, your local uni is your best source of info. People have to learn it somehow...Quote:
Originally posted by intruder
i am requesting to all of u if anybody knows ..from where willl i get basic tutorials on Assembly programming.
thanks a lot friend stronzo i went to that site and got very good documents on assembly...thanks a lot once again..Quote:
Originally posted by Stronzo
Try here: UVic CSC 230 Lecture Slides. Like I said, your local uni is your best source of info. People have to learn it somehow...
intruder...
Tekro,
I am in a class where we have to design our on "computer", basically it is programing at the electical level, 1 is high voltage, 0 is low voltage. From there you have to use logic gates (NAND, AND, OR, XOR, blah,blah) and all sort of other integrated circuits (we actually had to make a NAND gate out of transistors, it took up all of our bread board, makes you realy glad that there are integrated cirtcuits.
Right now in the class, we have to design how our groups are going to make our computers, 3 people in each group, each group has their own design. At this basic level you have "hardcode" the controls into the computer, basically like the signals that the program sends to manipualtedata.
say1000000 was Move D, then you would have to figure out a way to make it so that every time that signal was sent it would move D.
The class at my college is called Digital Electronics, but at most Universities it is a part of the Electric Engineering major.
You want to know anything else, I'll tell you what I know, that is all I can do,
dhej
Dhej, thanks for the info.. one other question then... how do you build your circuits? Or.... are they pre-made 4 u? Thanks again.. everyone..
We are building everything on breadboards, but a pro would use a circuit making program and a device that would etch a circuit board. Snce we are building basically an over--glorified calculator (we are basicall replaying the history of how computers evolved into PCs, except we are only uusing an Arithmatic Logic Unit, and not a MicroProcessor).
Our task is to design and build a "computer" that stores the numbers 2,3,4, and 5 in RAM, and then adds themtogether to get 14. Seems easy, but the ALU can only add two numbers at a time, so we have to build in a looping capability, our "Programing Language" is incredibly basic, we have simple commands that are 8bit binary numbers, to distinguish from our data we are making all the commands be in the form 1000 0xxx, where the xxx represents one of our 8 commands. Then we have to devise a circuit that will interpret these commands and make them happen.
An example would be like 1000 0001 being Move to TDSA.
This would take what is stored in an address in RAM and move it to a D-Latch called Temporary Data Storage A. 1000 0001 is all the "computer" sees, and it know that is has to move the data stored in the adress in RAM that something is being looked at to TDSA.
Our grade in the class is dependant on if our computer works. A if it does everthing it is supposed to, B if it is built and parts of it work, but 14 doesn't come out, C if it is built but doesn't work at all, D if it is parrtially built, and F if nothing gets done. The prof has informed us that there has been only a 25% success rate in the class. Only 25% of the people that take the class manage to get there computer computing. It is harder than it sounds, particularly if you aren't taking it at a school that has an EE major. Basically how we have been learning is he gave us the spec shets for the chips we are using, and then we had to figure out how to make the work for certain tasks, and now we have to put them all together into a device that has to work if we want an A.
But, it is a great class, it really makes you think about all the engineering that is involved in building the latest computers.
Think of thise, one NAND gate built on a breadbord with only transistors and diodes takes up the whole breadboard, but in a modern processor there are over a million NAND gates, and NAND gates are the simplest to build XOR, and OR gates are crazy.
Ok, I babble.
dhej
Don't you just love circuit design Dhej?
[SARCASM]I know I do.[/SARCASM] :p
;) It is my favorite thing in the world.Quote:
Originally posted by Stronzo
Don't you just love circuit design Dhej?
[SARCASM]I know I do.[/SARCASM] :p
Makes me glad that I am a Philosophy Major.
(Its sad when your hobby is more likely to get you a job then what you go to school for.)
But then, when everything works the way you want it to it really is neat. It is so much more concrete than writing a program. Getting your output in binary from LEDs just has this feeling of being hardcore. Just like *nix -fiends mock people with GUIs, this makes me feel like I should mock people with command-lines. "Oh, you use a command-line, that is such a waste of RAM," lol. Also brings a new (or brings back the old) meaning for "build you own." Too bad it has less oomph than a typical calculator (and I am not even talking about scientific calculators either).
Though, I do have a feeling my brain is going to pop in about 2 weeks when we actually start building what we have designed.
dhej
Hiya Dhej. Could you teach me how to do it?. :)
As far as the computer is concerned all there is is Binary, no HEX, Decimal, octal, C, or even assembly code. Just Binary.
(All the transistors in your CPU are either ON or OFF as you know)
The first micro's to come out like the mini SC/MP had (from memory) two rows of 8 toggle switches.
One for the Address Bus and
the second row of 8 toggle switches for the data bus.
To program,
Set the ADDress toggle switches to the location of the memory you want to place an instruction or data.
Set the DATA toggles to the Binary data you want to enter
press the Write press button.
Output is two rows of 8 LEDS displaying the binary contents of
the ADDress and DATA busses.
Coding is done in assembly, converting the Mnemonics to HEX then the HEX to BINARY and coding into the micro.
Ahhh those were the days. (this is about 1977)
Regards
Frosty
bye the way
I think the Mini SC/MP used a 4 bit microprocessor
it was basically a calculator chip, it was called the
Intel 4004 the predecesor to the 8008
then the 8080 -> 80186 -> 80286 ->>>>>> the rest is history.
Your awnser:
The BIOS system chip was designed purely on mathmatics. It is the main input/output controler in your system, as it's name inplies.
imagine this, your CPU was made of thousands of light switches and depending on which ones were flicked on, you could always generate a predictible mathmatical equasion based on that. When thinking about micro computer fundementals, you should remember that one game on the "Price is Right" where the player drops the token down the slanted pin board to land in a money spot, but think of this method as being predictable such as in computer design.
Before dos or any compiled language (where dos doesn't matter in your programming question) there was assemboly which is more the less "binary" in a form humans can understand. The assemboly language for the most part is nothing more than crap written in HEX, which is just a short hand form of binary.
read several books on assemboly and take several months to digest it, and then you'll understand half of nothing that I do. puters at the machine level are so damn complicated.... The only way to ever being able to understand is to purse it always, asking us will never make you understand...
To damn hard to explain, i'm going back to my beer sluggin' now....
Can't you just wait till atomic computers are economically viable?
I mean, who cares about current/no current (1/0) anymore? Try positive electron spin, negative electron spin, multiplied by X number of electrons 'in' the atom (I know it's not in but I couldn't phrase it a different way).
Just think of how fast your dictionary attack could work if you had a couple of helium atoms in your processor working for you...
Damn I love technology and innovation!
Here is a solid source of info for those not going to school but who teach themselves. "CODE" by Charles Petzold. It is a microsoft book, but looks at code from the very early days.