I want to write some binary code

  • (3 Pages)
  • +
  • 1
  • 2
  • 3

40 Replies - 3194 Views - Last Post: 05 May 2014 - 01:50 PM

#31 BBeck  Icon User is online

  • Here to help.
  • member icon


Reputation: 560
  • View blog
  • Posts: 1,258
  • Joined: 24-April 12

Re: I want to write some binary code

Posted 05 May 2014 - 12:50 PM

Unless you get an ancient machine that actually lets you flip switches and has less than 1 kilobyte of memory, you can't program in binary.

If you "really" wanted to get to that level you need to study digital electronics and learn to build digital circuits. You still won't be programming them in binary though.

The computer's memory is binary because it's made up of switches. The switches only have two positions: on and off. On and off are represented by 1 and 0. Viola! Binary.

8 switches is called a "byte of memory" and that's the smallest unit you actually work with. The 8 switches can be set to 256 unique combinations of positions. So, the way you actually "set" the switches is to electronically pass a number between 0 and 255 to the byte and the machine sets the eight binary switches according to the number you sent. 0 for example means all the switches are off and 255 means all 8 switches are on. Likewise, you can read the switches which will cause a number between 0 and 255 to be sent back to you so that you can determine how the switches are currently set.

So, no one does binary really. We do what's called "hexadecimal". Hexidecimal is base 16 math. Our normal math is base 10. In other words there are 10 digits that we use from 0 to 9 and then each increment after that uses another digit. Hexidecimal has 16 digits from 0 to F. After 9 it uses the alphabet from A to F. (Binary is actualy base 2 math.)

The reason we use hexadecimal is because it fits the size of an 8 bit byte very well. Using two hexadecimal digits we can perfectly represent all 256 possible numeric combinations of a byte. 00 hex equals 0. FF hex equals 255, or the highest possible value. 0F equals 16 and 10 is the number after that and represents 17.

In one of the examples above you can see hexadecimal numbers being used.

If you program in "machine language" you won't program in binary, you'll program in hexadecimal. By passing in a hexadecimal number you will set the 8 switches. You can "think" of them in binary; there's a binary number that equals any hexadecimal number you come up with. In fact, if you convert the hexadecimal number to a binary number using math you can actually see which switches will be set and which won't within the byte.

But people who actually do this don't use binary, they use hexadecimal.

The way that machine language works is that one or more byte values may give the processor a command. Let's say we want the computer to add two numbers in memory together and then store the value.

If we were writting that in "normal" numbers it might be that the binary value "1111 1111" means add together the values of the next two bytes and store them in a register. But instead of writing it in binary you could write it as the normal value of 255. 255 and "11111111" in binary are the same value. FF hexadecimal also equals both numbers.

So, then the "command" FF means add the next two byte values together and store them in such and such register. (A register is like a very super fast but incredibly tiny piece of memory where you store values.)

So, in machine language it might look like "FF 01 0F" and the FF means "add the next two byte values together". 01 + 0F in hex equals 10 hex. So this machine language command would cause the hex value 10 to be stored in such and such register since that's the answer to the addition problem.

So, if you were to write machine language code (the language we "imagine" the computer "speaking") you would do it in hex like that, not binary. You could write it in binary as "1111 1111 0000 0001 0000 1111" = "0001 0000". But the hex numbers are just much easier for humans to read. So, any program that allows you to write machine code is probably going to want you to do it in hex rather than binary. It's the exact same thing but the hex version is just easier for humans to understand.

If you want to get technical, the machine doesn't actually understand binary either. Even binary is an "imagination" of what's actually going on. What's actually going on is electrical impulses are setting switches in the circuit which gets into digital circuits and voltages. The 1's and 0's of binary are just the way we typically think of the switches either being on or off. And hex just makes it easier to deal with a byte (smallest actual unit of memory that can be worked with consisting of 8 switches).

Assembly language takes this concept of "readability" up one level. Instead of the statement "FF 01 0F" that we had before, Assembler would make the addition command of "1111 1111" or "FF" into the mnemonic "Add". So in Assembler, the exact same code is written something like "Add 01, 0F". That still just means "add the next two byte values together and store the answer in such and such register.

So assembly language is the exact same thing as machine language except that you subsitute human readable mnemonics for command codes and such.

If you get reasonably good at assembler, you should be able to write code in machine language using all hexadecimal (or theoretically even binary if you could find an assembler that can convert the binary code into hex that the machine can work with). But the bottom line is that at that point you will likely understand there's no point in writing code in machine language or binary because Assembler is the exact same thing, just much easier to actually work with.

So, unless you want to learn the electronics of constructing digital circuits (how to build a computer with a soldering iron), the next closest thing is Assembly language. That will definately teach you how the machine actually "thinks".

If you really want to know how the computer "thinks". I recommend this book. It is extremely dated having been written in 1992. However, it's one of the most approachable books on the subject of assembler (how the computer thinks) I've ever read.

He has a more modern book, but I've never read it. I can't imagine he's gotten worse at writing over the past 20 years, but since I've never read it, I can't recommend it. Still, it might be a more up to date book considering things have changed a lot in the compute world in the past 20 years.

None the less. His 1992 book may not technically apply to today's computers but it's probably going to give you just as good an understanding of how assembler works from an academic perspective. (If you just want to read about it rather than actually do it.)

I can highly recommend Kip Irvine's book. It's not quite as approachable as Duntemann's books, but it's still extremely good and applies to modern Windows computer except for "maybe" not Windows 8. I'm certain it's good for Windows 7 at least. And Duntemann's 1992 book was written for DOS and his more recent book is for Linux.

If you really want to know "how the computer thinks". Learn assembly language. Just be prepared to have the "curtain thrown back and the wizard revealed". You will learn kind of the computer equivilent of "photographs are just chemicals that are light sensitive and capture an image by reflecting tiny fragments of color in the exact shape of an image cast on the negative and not a way of capturing peoples' souls". And that may be greatly disappointing for some who hope to see the world in a romantic sort of way. The world's a much less exciting and mysterious place when you actually understand how it works.

This post has been edited by BBeck: 05 May 2014 - 01:00 PM

Was This Post Helpful? 2
  • +
  • -

#32 leibniz76  Icon User is offline

  • New D.I.C Head

Reputation: -5
  • View blog
  • Posts: 18
  • Joined: 02-May 14

Re: I want to write some binary code

Posted 05 May 2014 - 01:13 PM

View Postjon.kiparsky, on 05 May 2014 - 06:37 AM, said:

View Postleibniz76, on 05 May 2014 - 07:58 AM, said:

Nagel proved p is an argument from authority and hence a fallacy.


If I were making the argument that NN proves p, then I would be committing a fallacy. I'm not doing that, though. I'm asserting that there is a good book which will help you understand what you're trying to argue about so that you can either understand where your reasoning is going astray, or else argue about it more convincingly.

You're just assuming I'm wrong, which is a fallacy. You have to prove that I'm wrong. I'm still waiting from you about whether or not you believe 'Red is true' is grammatical.

Quote

Right now, you're not even arguing about Gödel, you're arguing about a parody of Gödel. And I agree with you on one thing - I don't like your parody of Gödel either. I do think that the real thing is much more interesting, and more convincing.

So you think David Papineau misunderstood Godel? I've read about 4 encapsulations on Godel and they all say the same thing. I'm not creating a strawman. Besides, since you're so knowledgeable about G's theorems then why don't you go ahead and encapsulate them yourself?
Was This Post Helpful? 0
  • +
  • -

#33 BBeck  Icon User is online

  • Here to help.
  • member icon


Reputation: 560
  • View blog
  • Posts: 1,258
  • Joined: 24-April 12

Re: I want to write some binary code

Posted 05 May 2014 - 01:16 PM

You also may want to consider studying "artificial intelligence". There are a couple problems with that though.

First, most of the AI stuff I've actually seen is about game programming and it's very high level compared to Assembler.

No one actually uses Assembler anymore. Actualy, that's not entirely true, but it is true to say it is very rarely used with computers. Assembler is exactly the same thing as machine language, just easier for humans to read.

Other computer languages either convert the computer code into machine language (which again is the same thing as Assembler, in fact you can dis-assemble the machine code and see it written out in Assembler), or they have a program that was converted into machine code that acts as an interpreter to carry out the tasks the language specifies.

So, these high level languages are much easier to use than assembler but much easier to learn as well. It's not as educational as learning Assembler, especially if you want to know what's really going on inside the machine. It's a whole lot easier to get actual work done with these high level languages.

If you get into the subject of Artificial Intelligence, you may need to know at least one of these high level languages to really understand it. But you could take a stab at it.

When you talk about computers thinking like people, rather than thinking like machines you're really going to be talking high level languages and AI which is a much higher level concept than machine code.

I assure you that the machine is not going to have an epiphany and start thinking on it's own any more than a rock will. If it's ever going to think it will require a significant algorithm and that's the sort of thing AI studies try to address. Although, most AI work is actually at a much more simple level dealing with state machines, path finding, and flocking and such. That's more about machines finding complex answers than it is about truely thinking.

What you probably want is more on the level of IBM's Watson or their new computer. And I'd bet my next 10 paychecks they've got an unimaginable amount of high level code involved in making that hunk of tin "think".
Was This Post Helpful? 0
  • +
  • -

#34 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 8927
  • View blog
  • Posts: 33,453
  • Joined: 12-June 08

Re: I want to write some binary code

Posted 05 May 2014 - 01:17 PM

View Postleibniz76, on 05 May 2014 - 03:13 PM, said:

...
You're just assuming I'm wrong, which is a fallacy. You have to prove that I'm wrong.
...


Typical decorum would suggest, that, since you are the one running contrary to the status quo (asserting a positive action) the burden of proof is on you.
Was This Post Helpful? 1
  • +
  • -

#35 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10370
  • View blog
  • Posts: 38,409
  • Joined: 27-December 08

Re: I want to write some binary code

Posted 05 May 2014 - 01:21 PM

Quote

You're just assuming I'm wrong, which is a fallacy. You have to prove that I'm wrong. I'm still waiting from you about whether or not you believe 'Red is true' is grammatical.

Modi, Jon, and I all echo the same sentiments that you have to prove your own case. Stop with the strawman and put on the mathematician hat. It's the same thing as me claiming that the construction of the real numbers through limits of converging Cauchy sequences of rationals is incorrect. I can claim it, but until I prove it, it doesn't mean anything.

Quote

Besides, since you're so knowledgeable about G's theorems then why don't you go ahead and encapsulate them yourself?

I think Jon explained this pretty well. He feels that there are texts giving the material treatment better than he feels he could. I tend to concur on my end, and Jon has a better grasp on Godel's works than I do.
Was This Post Helpful? 1
  • +
  • -

#36 jon.kiparsky  Icon User is offline

  • Pancakes!
  • member icon


Reputation: 7564
  • View blog
  • Posts: 12,686
  • Joined: 19-March 11

Re: I want to write some binary code

Posted 05 May 2014 - 01:23 PM

View Postleibniz76, on 05 May 2014 - 03:13 PM, said:

You're just assuming I'm wrong, which is a fallacy. You have to prove that I'm wrong.


I don't have to prove anything. Gödel took care of that. And if you're under 40 and can show him wrong, there's a Fields medal waiting for you. But to convince anyone that your proof is any good, you're going to have to show that you understand Gödel first, and you haven't done that yet.


Quote

I'm still waiting from you about whether or not you believe 'Red is true' is grammatical.


Answered above.

Quote

So you think David Papineau misunderstood Godel? I've read about 4 encapsulations on Godel and they all say the same thing. I'm not creating a strawman.


I think it's more likely you misunderstood Papineau, frankly.


Quote

Besides, since you're so knowledgeable about G's theorems then why don't you go ahead and encapsulate them yourself?


Because as I say, it's already been done quite effectively by better writers than me, and in any case my boss would prefer I spend time solving problems that matter to him. He doesn't care much about your misconceptions regarding fundamental concepts of modern mathematics.
Was This Post Helpful? 0
  • +
  • -

#37 leibniz76  Icon User is offline

  • New D.I.C Head

Reputation: -5
  • View blog
  • Posts: 18
  • Joined: 02-May 14

Re: I want to write some binary code

Posted 05 May 2014 - 01:30 PM

Thank you for taking the time to explain this matter. I really appreciate your work. Would you be willing to discuss this on skype? If so my skype ID is <Removed>.

View PostBBeck, on 05 May 2014 - 12:50 PM, said:

Unless you get an ancient machine that actually lets you flip switches and has less than 1 kilobyte of memory, you can't program in binary.

If you "really" wanted to get to that level you need to study digital electronics and learn to build digital circuits. You still won't be programming them in binary though.

The computer's memory is binary because it's made up of switches. The switches only have two positions: on and off. On and off are represented by 1 and 0. Viola! Binary.

8 switches is called a "byte of memory" and that's the smallest unit you actually work with. The 8 switches can be set to 256 unique combinations of positions. So, the way you actually "set" the switches is to electronically pass a number between 0 and 255 to the byte and the machine sets the eight binary switches according to the number you sent. 0 for example means all the switches are off and 255 means all 8 switches are on.

I don't really understand the words in bold. How does the computer know what 255 means?

Quote

Likewise, you can read the switches which will cause a number between 0 and 255 to be sent back to you so that you can determine how the switches are currently set.

So, no one does binary really. We do what's called "hexadecimal". Hexidecimal is base 16 math. Our normal math is base 10. In other words there are 10 digits that we use from 0 to 9 and then each increment after that uses another digit. Hexidecimal has 16 digits from 0 to F. After 9 it uses the alphabet from A to F. (Binary is actualy base 2 math.)

The reason we use hexadecimal is because it fits the size of an 8 bit byte very well. Using two hexadecimal digits we can perfectly represent all 256 possible numeric combinations of a byte. 00 hex equals 0. FF hex equals 255, or the highest possible value. 0F equals 16 and 10 is the number after that and represents 17.

In one of the examples above you can see hexadecimal numbers being used.

If you program in "machine language" you won't program in binary, you'll program in hexadecimal. By passing in a hexadecimal number you will set the 8 switches.

I don't understand the words in bold.

Quote

You can "think" of them in binary; there's a binary number that equals any hexadecimal number you come up with. In fact, if you convert the hexadecimal number to a binary number using math you can actually see which switches will be set and which won't within the byte.

But people who actually do this don't use binary, they use hexadecimal.

The way that machine language works is that one or more byte values may give the processor a command. Let's say we want the computer to add two numbers in memory together and then store the value.

If we were writting that in "normal" numbers it might be that the binary value "1111 1111" means add together the values of the next two bytes and store them in a register.

But I don't understand how the computer executes a command.

Quote

But instead of writing it in binary you could write it as the normal value of 255. 255 and "11111111" in binary are the same value. FF hexadecimal also equals both numbers.

So, then the "command" FF means add the next two byte values together and store them in such and such register. (A register is like a very super fast but incredibly tiny piece of memory where you store values.)

So, in machine language it might look like "FF 01 0F" and the FF means "add the next two byte values together". 01 + 0F in hex equals 10 hex. So this machine language command would cause the hex value 10 to be stored in such and such register since that's the answer to the addition problem.

So, if you were to write machine language code (the language we "imagine" the computer "speaking") you would do it in hex like that, not binary. You could write it in binary as "1111 1111 0000 0001 0000 1111" = "0001 0000". But the hex numbers are just much easier for humans to read. So, any program that allows you to write machine code is probably going to want you to do it in hex rather than binary. It's the exact same thing but the hex version is just easier for humans to understand.


If you want to get technical, the machine doesn't actually understand binary either. Even binary is an "imagination" of what's actually going on.

I agree with you.

Quote

What's actually going on is electrical impulses are setting switches in the circuit which gets into digital circuits and voltages. The 1's and 0's of binary are just the way we typically think of the switches either being on or off. And hex just makes it easier to deal with a byte (smallest actual unit of memory that can be worked with consisting of 8 switches).

Assembly language takes this concept of "readability" up one level. Instead of the statement "FF 01 0F" that we had before, Assembler would make the addition command of "1111 1111" or "FF" into the mnemonic "Add". So in Assembler, the exact same code is written something like "Add 01, 0F". That still just means "add the next two byte values together and store the answer in such and such register.

So assembly language is the exact same thing as machine language except that you subsitute human readable mnemonics for command codes and such.

If you get reasonably good at assembler, you should be able to write code in machine language using all hexadecimal (or theoretically even binary if you could find an assembler that can convert the binary code into hex that the machine can work with). But the bottom line is that at that point you will likely understand there's no point in writing code in machine language or binary because Assembler is the exact same thing, just much easier to actually work with.

So, unless you want to learn the electronics of constructing digital circuits (how to build a computer with a soldering iron), the next closest thing is Assembly language. That will definately teach you how the machine actually "thinks".

If you really want to know how the computer "thinks". I recommend this book. It is extremely dated having been written in 1992. However, it's one of the most approachable books on the subject of assembler (how the computer thinks) I've ever read.

He has a more modern book, but I've never read it. I can't imagine he's gotten worse at writing over the past 20 years, but since I've never read it, I can't recommend it. Still, it might be a more up to date book considering things have changed a lot in the compute world in the past 20 years.



None the less. His 1992 book may not technically apply to today's computers but it's probably going to give you just as good an understanding of how assembler works from an academic perspective. (If you just want to read about it rather than actually do it.)

I can highly recommend Kip Irvine's book. It's not quite as approachable as Duntemann's books, but it's still extremely good and applies to modern Windows computer except for "maybe" not Windows 8. I'm certain it's good for Windows 7 at least. And Duntemann's 1992 book was written for DOS and his more recent book is for Linux.

If you really want to know "how the computer thinks". Learn assembly language. Just be prepared to have the "curtain thrown back and the wizard revealed". You will learn kind of the computer equivilent of "photographs are just chemicals that are light sensitive and capture an image by reflecting tiny fragments of color in the exact shape of an image cast on the negative and not a way of capturing peoples' souls". And that may be greatly disappointing for some who hope to see the world in a romantic sort of way. The world's a much less exciting and mysterious place when you actually understand how it works.

Thanks for the book recommendation.

View Postmacosxnerd101, on 05 May 2014 - 01:21 PM, said:

Quote

You're just assuming I'm wrong, which is a fallacy. You have to prove that I'm wrong. I'm still waiting from you about whether or not you believe 'Red is true' is grammatical.

Modi, Jon, and I all echo the same sentiments that you have to prove your own case.

I already did prove my case and you have yet to respond. I pointed out that Godel has a fallacious understanding of what a sentence is and based on his reasoning 'red is true' is a sentence. I want to hear from you whether or not you believe 'red is true' is a sentence.

Quote

Stop with the strawman and put on the mathematician hat.

You can't just call an argument a strawman. You have to point to text, show why it doesn't match what G said and then state what he really said and why what he really said is true and what I'm responding to doesn't match what G said. You haven't done that.



Quote

Besides, since you're so knowledgeable about G's theorems then why don't you go ahead and encapsulate them yourself?

I think Jon explained this pretty well. He feels that there are texts giving the material treatment better than he feels he could. I tend to concur on my end, and Jon has a better grasp on Godel's works than I do.
[/quote]

'There are texts that prove p' is not a proof of p. The fact that you don't understand that demonstrates your inability to reason correctly.

View Postmodi123_1, on 05 May 2014 - 01:17 PM, said:

View Postleibniz76, on 05 May 2014 - 03:13 PM, said:

...
You're just assuming I'm wrong, which is a fallacy. You have to prove that I'm wrong.
...


Typical decorum would suggest, that, since you are the one running contrary to the status quo (asserting a positive action) the burden of proof is on you.



When I put forth an argument you can't just say: "you have to put forth an argument," what you have to do is show why my argument fails. Since you're not even able of quoting what I write, it's safe to say that you're not capable of understanding what I'm talking about.

This post has been edited by macosxnerd101: 05 May 2014 - 01:25 PM
Reason for edit:: Removed Skype ID per site policies.Let's keep discussion in the forums

Was This Post Helpful? -2
  • +
  • -

#38 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 8927
  • View blog
  • Posts: 33,453
  • Joined: 12-June 08

Re: I want to write some binary code

Posted 05 May 2014 - 01:34 PM

Okely dokely.. I am amused by intellectual peackockery as the next, but you are starting to become a bit bitter in your presentation as well as insulting. I would suggest slowing your roll on that one chief.

Spoiler




View Postleibniz76, on 05 May 2014 - 03:30 PM, said:

...
The fact that you don't understand that demonstrates your inability to reason correctly.
...


View Postleibniz76, on 05 May 2014 - 03:30 PM, said:

...
When I put forth an argument you can't just say: "you have to put forth an argument," what you have to do is show why my argument fails. Since you're not even able of quoting what I write, it's safe to say that you're not capable of understanding what I'm talking about.




Quote

When I put forth an argument you can't just say: "you have to put forth an argument," what you have to do is show why my argument fails

Typically if you are presenting a contrary opinion on some work you would have the burden to prove you are true, and not assume folks have the burden to prove you wrong.
Was This Post Helpful? 0
  • +
  • -

#39 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10370
  • View blog
  • Posts: 38,409
  • Joined: 27-December 08

Re: I want to write some binary code

Posted 05 May 2014 - 01:38 PM

Quote

I already did prove my case and you have yet to respond. I pointed out that Godel has a fallacious understanding of what a sentence is and based on his reasoning 'red is true' is a sentence. I want to hear from you whether or not you believe 'red is true' is a sentence.

I defer to Jon's explanation as sufficient. He is the resident linguistics expert, here:

Quote

It is syntactically grammatical, in that it applies a predicate to a subject. Semantically, it is meaningless unless I know how Red can be true - but there are several ways this could come about. Possibly you're asserting the faithfulness of your ginger-haired friend, or telling me that you've labelled certain statements with color codes to indicate their veracity. "You see those labels? Green is false, blue is uncertain, and red is true".


Quote

'There are texts that prove p' is not a proof of p. The fact that you don't understand that demonstrates your inability to reason correctly.

I understand that quite well. But I've yet to see a proof from you as to why it's false. I've seen statements that you don't understand Godel's works and that you don't agree with them. If you can refute them, you deserve a Fields medal. I'm fairly well-versed in Turing's work, though, so I can discuss works relevant to Godel in terms of Turing Machines. I'd also like to add that as a mathematician by training, I'm quite capable of recognizing a proof. ;)


Quote

Typically if you are presenting a contrary opinion on some work you would have the burden to prove you are true, and not assume folks have the burden to prove you wrong.

I third this (again). If you don't like something about a theory, it's not our job to rederive the entire theory for you. It's up to you to read up more on said theory.
Was This Post Helpful? 0
  • +
  • -

#40 leibniz76  Icon User is offline

  • New D.I.C Head

Reputation: -5
  • View blog
  • Posts: 18
  • Joined: 02-May 14

Re: I want to write some binary code

Posted 05 May 2014 - 01:44 PM

View Postmacosxnerd101, on 05 May 2014 - 01:38 PM, said:

I've yet to see a proof from you as to why it's false.


Let's say I were to assert: 'nothing proves p' and then you ask me what p stands for and I refuse to tell you. Would you think that I had proven that anything? If that's not what Godel's arguing and you don't know what he actually is arguing, then you have business participating in this debate.
Was This Post Helpful? -2
  • +
  • -

#41 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 8927
  • View blog
  • Posts: 33,453
  • Joined: 12-June 08

Re: I want to write some binary code

Posted 05 May 2014 - 01:50 PM

Ah.. yes.. that was the last exclusionary slam to close this thread. I warned ya, but some times folks don't listen.

Feel free to utilize the PM system if you are at a loss on 'why' the thread was closed.
(I'll probably regret saying that)

Spoiler

Was This Post Helpful? 1
  • +
  • -

  • (3 Pages)
  • +
  • 1
  • 2
  • 3