Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Geek Culture / Binary.

Author
Message
Osiris
20
Years of Service
User Offline
Joined: 6th Aug 2004
Location: Robbinsdale, MN
Posted: 2nd Sep 2006 09:26
How do you go about writing programs with it? Are there commands, do you need something special to write in it? Im jut curious about how to make programs with it, just even a hello world program. Anyone know how to write in binary, even just a little, or can point me to a website?

Kevin Picone
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 2nd Sep 2006 10:01 Edited at: 2nd Sep 2006 10:01
HandK
18
Years of Service
User Offline
Joined: 24th Jun 2006
Location:
Posted: 2nd Sep 2006 15:48
Quote: "How do you go about writing programs with it?"


You dont, its a number system, not a programing language.

H&K
EddieB
20
Years of Service
User Offline
Joined: 29th Sep 2004
Location: United Kingdom
Posted: 2nd Sep 2006 16:39
You could write machine code in a hex editor, add a boot loader like grub, and load it up at boot time.. that would be the easy way.. but as for binary its just on and off.. when you see converters for like ascii to binary its just a binary representation.

Binary is pretty simple when you get used to it, then performing bitwise operations to it

0110 = 6

so ~6 = 1001 = 9

Do it depends on how many bits your using.
Osiris
20
Years of Service
User Offline
Joined: 6th Aug 2004
Location: Robbinsdale, MN
Posted: 3rd Sep 2006 01:01
Well, I know its just on and off, but then how do you make a programing language in the first place, you would have to make something out of machine code in the first place right?

Kevin Picone
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 3rd Sep 2006 01:29 Edited at: 3rd Sep 2006 01:37
You could, or you'd do what sensible programmers do and use a cross compiler of some flavor.

If you really wanted to learn a bit about the theory, you could fire up an emulator of a 8bit/16bit machines. The C64 is an easy one that comes to mind. Easy, as It comes with built in basic which can execute poke/peeks via the common line, this allows you to peek/poke (read/write bytes) from memory directly. So you can poke(write) machine code sequences into memory, then execute them. While you'll most prolly cause it crash and die initially, you'll learn some of the instruction set (opcode) mnemonics sooner or later!

You could almost do this from PlayBasic/DBpro etc. The only thing missing, is a call address operation. So you couldn't execute the code at a particular starting address.

I.e. The process could be

* Allocate/Create a memory bank
* Poke the opcodes directly into that memory (make sure it returns ! )
* Then Call the starting address of the routine.


It's important to realize that Machine code is Cpu & generally Architecture dependant. So different chips use a different instruction set, making code not transferable. But the process is not rocket science.

Killswitch
22
Years of Service
User Offline
Joined: 2nd Oct 2002
Location: School damnit!! Let me go!! PLEASE!!!
Posted: 3rd Sep 2006 01:30 Edited at: 3rd Sep 2006 01:31
@Osiris

You're right. With the very first computers people had to program them using Binary (with punch cards or flicking switches on and off a lot). Certian binary values tell the computer to perform a specific action (like adding, or subtracting).

Then someone (who was probally fed up with 1's and 0's) came up with the idea of Assembly - which uses mnemonics (such as ADD and SUB) instead of the actual binary values to represent commands. A program called an Assembler (and yes, the first one had to be interially written in binary) converts these to something a computer can actually understand.

~Heed my word hobags: Jism~
Seppuku Arts
Moderator
20
Years of Service
User Offline
Joined: 18th Aug 2004
Location: Cambridgeshire, England
Posted: 3rd Sep 2006 01:56 Edited at: 3rd Sep 2006 01:57
Actually wasn't it Hex before assembly?

That involve more numbers and letters.
Like "A=4 B=6 C=A+B" is this bit of code;

C7 05 00 00 00 00 04 00 00 00 C7 05 00 00 00 00 06 00 00 00 A1 00 00 00 00 03 05 00 00 00 00 A3 00 00 00 00

Then assembly which makes much more sense.

HandK
18
Years of Service
User Offline
Joined: 24th Jun 2006
Location:
Posted: 3rd Sep 2006 03:31
Right.

Assembly was the language

Binary and Hex, and Oct are just ways to write it down

H&K
Aaron Miller
18
Years of Service
User Offline
Joined: 25th Feb 2006
Playing: osu!
Posted: 3rd Sep 2006 03:33
Um,
i beleive that that would be
A=10
B=11
C=12
D=13
E=14
F=15

And by the way, if you go back to the link mentioned above, i showed a bit of information on binary2hex.

Jeku
Moderator
21
Years of Service
User Offline
Joined: 4th Jul 2003
Location: Vancouver, British Columbia, Canada
Posted: 3rd Sep 2006 04:40
Hex is just base 16 numbering, like binary is base 2, pretty much what HandK said. Binary and hex numbering doesn't necessarily have to have anything to do with computers. Hell, I learned about them formally in a math class.


"I understand creative people. After all, I worked with towel designers." - Ray Kassar, former head of Atari
Osiris
20
Years of Service
User Offline
Joined: 6th Aug 2004
Location: Robbinsdale, MN
Posted: 3rd Sep 2006 06:04
So pretty much, there is no way anymore to learn binary, to say write a simple litle program, you have to use assembely, or Hex, no one has nswered this, how do you go about writing with binary, do you write commands with the binary alphabet. If so, what are the commands, are there commands?

Jeku
Moderator
21
Years of Service
User Offline
Joined: 4th Jul 2003
Location: Vancouver, British Columbia, Canada
Posted: 3rd Sep 2006 06:25
Seriously, use Google to learn binary. There is no language called binary, but early computers used on/off switches to program--- but it's not like you can whip up VS.NET nowadays and type a bunch of 100101010101's to get "Hello, World"


"I understand creative people. After all, I worked with towel designers." - Ray Kassar, former head of Atari
Kenjar
19
Years of Service
User Offline
Joined: 17th Jun 2005
Location: TGC
Posted: 3rd Sep 2006 07:01 Edited at: 3rd Sep 2006 07:08
There seems to be some mix up between HEX and Binary here, and how programming works at it's most basic level.

Binary is a mathematical system where you simply count up to 1 from zero. Because a CPU is basically a few million (Or is it billion yet?) switches, with two states, on and off, this is represented mathematically as 0 for off, and 1 for on. Data is stored in exactly the same way.

Hexadeciamal on the other hand is just another way of representing a value of up to sixteen. As humans, we have 10 fingers, so we count up to ten, then twenty, then thirty etc. Imagine the computer has 16 fingers, so it counts from 0 up to 9 (remember 0 is counted as a number in computing, that is why dispite there being 256 colours, they are represented as 255 for 256 because 0 is represente as 1) then A B C D E F, when it gets to F, just as we do with 10, we count the next number as 20, then 21, 22, 23, 24, 25, 26, 27, 28, 29, 2A, 2B, 2C, 2D, 2E, 2F, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 3A, 3B, 3C, 3D, 3F. The reason that we use this system for counting, is because 16-bit processors can shove the number sixteen as 1111, thus maniuplating up to sixteen switches in one go to generate that value, in the smallest unit of processing time. We stuck with Hexadeciamal because CPU's went from 16 to 32 bit, then 32 to 64 bit processing. And rather than writing software that read single 32 or 64 bit Bases, we remained with the 16-bit hex, as tread 2 hex's as a single peice of base32 data or four as a single peice of base64 data.

Machine code, as someone else pointed out, is the usage of base2, or binary and is the most fundermental state of data in a digital computer system. Hexidecimal is used in assembly language, a somewhat outmoded form of programming where hexidecimal codes were entered in as numbers because it's quicker and more efficant to enter in the letter F then to type in 1111 for sixteen, or FFFF rather than 1111111111111111 for 65535.

So in essance, to program in binary, you would have to understand how every single switch is triggered, and want value at any given point in time, is required to trigger a specific result.

I lay upon my bed one bright clear night, and gazed upon the distant stars far above, then I thought... where the hell is my roof?
Osiris
20
Years of Service
User Offline
Joined: 6th Aug 2004
Location: Robbinsdale, MN
Posted: 3rd Sep 2006 07:18
Thank you for the clarity, so, lets say, I wanted to make a program that computer boots to, what language would I write it in and what do I need to inclued for it to run it?

Aaron Miller
18
Years of Service
User Offline
Joined: 25th Feb 2006
Playing: osu!
Posted: 3rd Sep 2006 07:41
ASM for bootloader
C/C++ for kernel

goto www.osdever.net (or is it www.osdever.com?)

There are quite a bit of tutorials there.

btw, put effort into it if your trying to make an OS.

Three Score
20
Years of Service
User Offline
Joined: 18th Jun 2004
Location: behind you
Posted: 3rd Sep 2006 10:29
its .net

if your just wanting to try to do some machine code in a hex editor though you might want to just write a your bootloader as the tester htingy


but if you want to make an OS then osdever is good, also their is osdev.org and mega-tokyo.com/forum/index.php


though it is very very useful to know C and asm for OS deving

Osiris
20
Years of Service
User Offline
Joined: 6th Aug 2004
Location: Robbinsdale, MN
Posted: 3rd Sep 2006 10:33
Nah, wasnt thinking about making an OS, would finish it...just wanted to make the computer do what I wanted on startup, just say some things. Im gonna try to find an ASM compiler, know any good ones...that are free?

Les Horribres
18
Years of Service
User Offline
Joined: 20th Nov 2005
Location: My Name is... Merry
Posted: 3rd Sep 2006 10:39
Quote: "0110 = 6

so ~6 = 1001 = 9"


And 7 is also "not 6", don't forget 7. (which when turned on it's side is roman numeral 5, which looks like an S for september and then you get 9.

Your Mod was deleted by the Government.
Three Score
20
Years of Service
User Offline
Joined: 18th Jun 2004
Location: behind you
Posted: 3rd Sep 2006 11:07
nasm is very popular, but I have heard that fasm is better
thing in nasm is I have to try to make a work around for the lower level stuff, where in fasm you dont

Killswitch
22
Years of Service
User Offline
Joined: 2nd Oct 2002
Location: School damnit!! Let me go!! PLEASE!!!
Posted: 3rd Sep 2006 15:25
I'd recommend FASM, but it's the only asembler I've ever used.

~Heed my word hobags: Jism~
EddieB
20
Years of Service
User Offline
Joined: 29th Sep 2004
Location: United Kingdom
Posted: 3rd Sep 2006 15:53
MASM is the only one ive got to work well..

I believe it goes, Binary->Machine Code->ASM->Other high and low level languages..
Kenjar
19
Years of Service
User Offline
Joined: 17th Jun 2005
Location: TGC
Posted: 3rd Sep 2006 16:27
Well, the languaged used for older BIOS's, and this was a big issue around 2000 due to the y2k bug scare, was COBAL. Which I beleive to be an assembily language. But basically, if you are looking to write your own operating system, you need to install a set of instructions into the boot sector of the primary Hard Disk Drive. The BIOS automatically looks at the boot sector for instructions on how to proceed, think of it as a header for an exe file, defining it as the exe. Once you've told the system how to start up, it's a matter of programming. But this is all very overkill. With Linux, freeDOS and of cause Windows out there, hardly anyone builds their own OS now, it's easier to grab a free linux kernal and do the rest in C.

I lay upon my bed one bright clear night, and gazed upon the distant stars far above, then I thought... where the hell is my roof?
Richard Davey
Retired Moderator
22
Years of Service
User Offline
Joined: 30th Apr 2002
Location: On the Jupiter Probe
Posted: 4th Sep 2006 13:42
Quote: "Well, the languaged used for older BIOS's, and this was a big issue around 2000 due to the y2k bug scare, was COBAL. Which I beleive to be an assembily language."


You're having a laugh, right?

COBOL is about as far removed from coding in assembler as riding a skateboard is to driving a 4x4.

It used to be an industry standard, used extensively in creating banking, financial, and government mainframe programs. I remember spending 2 years coding in it at University on a VAX VMS mainframe via a CRT terminal. Oh the joy. The syntax is, well.. an 'acquired' taste for sure.

If anyone ever created a PC BIOS boot code in COBOL I'd be astonished, truly.

"Bite my shiny metal ass" - Bender, Futurama
No pixels were harmed in the making of this post
"Don't ping my cheese with your bandwidth"
Kentaree
22
Years of Service
User Offline
Joined: 5th Oct 2002
Location: Clonmel, Ireland
Posted: 4th Sep 2006 13:52
Look into x86 opcodes, which are the actual commands assembly is turned into. These are numbers and parameters which perform all the machine code instructions, each assembly instruction has a corresponding opcode.

And no, I agree with Rich, Cobol has never even been poweful enough for writing bios'es or os'es.

Zappo
Valued Member
20
Years of Service
User Offline
Joined: 27th Oct 2004
Location: In the post
Posted: 4th Sep 2006 17:41
I too did COBOL for two years. I seem to remember you having to get everything into the correct columns (although I appear to have repressed most of my COBOL memories ). A friend of mine once wrote Space Invaders in COBOL, but seeing as there was no 'inkey$' type input you had to hit enter after each move. Very funny and pointless.
Osiris: I think you need to clarify what you really want to do, and when you want it to run. I have a feeling you won't need to learn ASM or anything low level if all you want to do it display something when the machine boots.
Three Score
20
Years of Service
User Offline
Joined: 18th Jun 2004
Location: behind you
Posted: 4th Sep 2006 17:57
and if your wanting to know how to make stuff in a hex editor then you can goto this site for like a "summary" of what the intel manuals tell you: http://www.ousob.com/ng/iapx86/ and then look at opcodes and you can use those instruction set matricies(multiple matrixes) and the intel manuals are at http://www.x86.org/intel.doc/386manuals.htm

monotonic
18
Years of Service
User Offline
Joined: 24th Mar 2006
Location: Nottinghamshire, England
Posted: 4th Sep 2006 18:58
I once started writing my own OS, using nasm under linux, I got as far as writing a simple graphics/text driver for protected mode, then I quit for the simple fact I realised how much work was involved at the early stages let alone implementing multi-threading, exception handling etc.

I know the voices aren't real, but they have good ideas!

Login to post a reply

Server time is: 2024-11-17 13:36:33
Your offset time is: 2024-11-17 13:36:33