Like Tree1Likes
  • 1 Post By anduril462

Convert Machine code instruction (hex) into op code (binary)

This is a discussion on Convert Machine code instruction (hex) into op code (binary) within the Tech Board forums, part of the Community Boards category; Hi all sorry my first post was not about an problems in C, question will come relatively soon. I understand ...

  1. #1
    Registered User
    Join Date
    Sep 2012
    Posts
    23

    Red face Convert Machine code instruction (hex) into op code (binary)

    Hi all sorry my first post was not about an problems in C, question will come relatively soon. I understand the mis categorized post and i apologize however i am stuck on this concept and thought i might see if anyone would be willing to help me understand

    How would i convert Machine code instruction (hex) into a op code (binary)
    ex. EBFFA -> op code (binary)
    also how would i tell if it uses a register, and if it does which one, lastly how would i know if it includes an addressing mode (if it does which one?).

    Any help would be so much appreciated, thanks for you time

  2. #2
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,425
    Quote Originally Posted by AlexTank853 View Post
    Hi all sorry my first post was not about an problems in C, question will come relatively soon. I understand the mis categorized post and i apologize however i am stuck on this concept and thought i might see if anyone would be willing to help me understand
    We have a sub-forum for technical stuff that doesn't already have a specific home. Maybe a mod will move this to the Tech Board.

    How would i convert Machine code instruction (hex) into a op code (binary)
    ex. EBFFA -> op code (binary)
    Do you understand hex and binary conceptually? I mean, do you know that A(hex) = 10(decimal) = 1010(binary)? If you know the mapping of every hex digit to it's binary representation, then you're halfway there. You also should understand the difference between a number and it's representation. That is, if you say int x = 10;, x has the value ten. It exists in the computer in binary, due to the way hardware is, but from your point of view, it has no specific representation, it is just a value. It always has a value of 10, and you can print it out in any base (decimal, hex, octal) without changing it's value or the underlying representation in hardware.

    Next, we need to understand what you mean by "hex", "binary" and convert? Where is the "hex" coming from? Where is the "binary" going? Are "hex" or "binary" actually text input/output from/to a user, and you need to convert "EBFFA" -> "11101011111111111010"? Or are you supposed to store the binary format in some number so you can write a binary file for the machine to execute? Or something else all together?

    EDIT: I'm a little confused on your use of terms. "Machine code" usually refers to binary data that is the actual sequence of bits that comprise instructions for a given processor. The op-code is a part of each machine code instruction that tells the processor what to do (add, multiply, shift, compare, load, store, jump, etc).
    also how would i tell if it uses a register, and if it does which one, lastly how would i know if it includes an addressing mode (if it does which one?).
    Depends on the architecture. What architecture is this for? Intel architectures are different from Motorola, ARM, etc. And no two Intel, etc. architectures are exactly the same either (though many architecture "families" are very similar, such as all x86 archs). You need to get your hands on the technical documentation for that architecture and look at all the op codes and instruction formats.
    Last edited by anduril462; 09-19-2012 at 01:55 PM.
    Salem likes this.

  3. #3
    Registered User
    Join Date
    Jan 2009
    Posts
    1,485
    A machine code instruction is an opcode, if your example ABFFA is a valid opcode if will run on the target architecture. Unless this is for educational/experimental purposes there is no need to convert it to binary as it will be stored in binary anyway, even if you are looking at a hexadecimal representation.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Convert assembly>machine code, machine code>assembly
    By wenxinleong in forum C Programming
    Replies: 12
    Last Post: 06-23-2011, 10:42 PM
  2. Replies: 14
    Last Post: 04-01-2008, 02:23 AM
  3. Replies: 4
    Last Post: 01-18-2008, 06:05 PM
  4. Giving instruction to an executing C code
    By darkwalk in forum C Programming
    Replies: 2
    Last Post: 10-24-2006, 12:01 PM
  5. ASM 'Out Instruction' crashes, code included.
    By Xei in forum C Programming
    Replies: 5
    Last Post: 03-03-2003, 04:42 PM

Tags for this Thread


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