Binary Help

This is a discussion on Binary Help within the Windows Programming forums, part of the Platform Specific Boards category; I've been learning the architecture of computers, from the software to the hardware, and practically everything else that is used ...

  1. #1
    Registered User
    Join Date
    Nov 2011
    Posts
    67

    Binary Help

    I've been learning the architecture of computers, from the software to the hardware, and practically everything else that is used by a computer. So ofcourse, I quickly came across "Binary" numbers. I learned how to convert binary, add it, subtract, divide it, convert binary to decimal, and decimal to binary. But my question is... what can I do with this on today's computers??? From just being able to say "I know how to change the letter A, into "01000001", I feel like a pro, haha. But just knowing how to convert text and numbers into binary, and vice versa, isn't enough, I know that. I want to know what I can do with it? Is assembly language, binary? Or something very similiar? Is there some sort of "compilier" that I can send commands to my computer, using binary?

    Sorry if my question seems dumb... I'm just still really new to this stuff.

  2. #2
    - - - - - - - - oogabooga's Avatar
    Join Date
    Jan 2008
    Posts
    2,808
    This is not a Windows-specific question. If I was you I'd post it on the C forum where more people will see it.
    The cost of software maintenance increases with the square of the programmer's creativity. - Robert D. Bliss

  3. #3
    Registered User
    Join Date
    Nov 2011
    Posts
    67
    Quote Originally Posted by oogabooga View Post
    This is not a Windows-specific question. If I was you I'd post it on the C forum where more people will see it.
    Oh okay, thank you!

  4. #4
    Registered User
    Join Date
    Dec 2011
    Posts
    795
    Well, since you haven't posted in the right place yet, why not answer some questions before mods move this?

    > Is assembly language, binary?
    Sort of. Assembly instructions get translated directly to machine code (which is a long series of unreadable hex octets), and this gets converted to binary for the CPU/FPU/whatever else to process.

    > Is there some sort of "compilier" that I can send commands to my computer, using binary?
    Again, sort of. You do this by passing the commands with inline assembly. From there, it's converted down to binary and sent to process. If you want to know what actual binary commands are being sent, here's an (extensive) opcode reference chart: geek64-abc edition | X86 Opcode and Instruction Reference 1.11

    And if you want to do this in C, here's how (an example of swapping two ints without xchgq):

    Code:
    int v1 = 1;
    int v2 = 3;
    
    asm volatile (
                       "movq %%rax, %%rcx\n"
                       "movq %%rbx, %%rax\n"
                       "movq %%rcx, %%rbx\n"
                       : "=a" (v1), "=b" (v2)
                       : "a" (v1), "b" (v2)
                       : "rcx"
                       );

  5. #5
    - - - - - - - - oogabooga's Avatar
    Join Date
    Jan 2008
    Posts
    2,808
    Everything in a computer is "binary" at the lowest level, including the machine language instructions, but that's just a consequence of the underlying hardware. Computers would be essentially the same if they were at bottom trinary.

    Programmers try to work at a higher level, using decimal most of the time, hexadecimal when necessary, and allowing the computer to translate back and forth to the underlying representation. But sometimes they do work with bits -- see the cprogramming Bitwise Operators tutorial.

    And the fact that 'A' is actually the decimal number 65, or the hexadecimal number 0x41, or the octal number 0101, or the binary number 0b01000001 is really rather arbitrary. Since you can always represent it in a programming language (including assembly language) as 'A', it doesn't much matter what its exact "code" is. What does matter is that 'B' > 'A' and so on, which allows you to sort strings of letters, although the fact that 'a' > 'A', or 'A' > '0' is arbitrary.

    As for talking to your computer in binary, I think you'd grow tired of that in a very short time! But learning some assembly language is probably a good idea. Here's a couple of sites I found with google.

    x86 Assembly - Wikibooks, open books for an open world
    The Art of Assembly Language Programming
    The cost of software maintenance increases with the square of the programmer's creativity. - Robert D. Bliss

  6. #6
    Registered User
    Join Date
    Nov 2011
    Posts
    67
    Thanks guys for the informative information! I really appreciate it! And sorry about not moving this yesterday, I was on the computer for like 5 minutes before I had to go. I'll go post this question where it should!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Read binary, change a value, write to binary
    By mammoth in forum C Programming
    Replies: 16
    Last Post: 05-12-2011, 10:56 AM
  2. Converting From Binary Tree to Threaded Binary Trees
    By elton_fan in forum C Programming
    Replies: 15
    Last Post: 11-08-2007, 10:41 PM
  3. Replies: 3
    Last Post: 11-25-2006, 03:14 PM
  4. Replies: 0
    Last Post: 11-04-2006, 10:07 AM
  5. Characters to binary... hexadecimal to binary
    By Trauts in forum C++ Programming
    Replies: 48
    Last Post: 10-27-2002, 04:03 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21