Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Assembly laguage

  1. Aug 23, 2014 #1
    hello friends

    look at this old post by mr. job
    its very great explanation by mr. job


    I have little doubt
    I understood how machine code generate but I did not understand how does assembly code make from machine code

    I tried to understand with below example
    machine language is hard to understand so we developed assembly language
    Mov (1000)
    6 (0110)
    mov A, # 6 ( assembly language )
    1000 0110 ( machine language )
    another
    Mov (1000)
    2 (0010)
    mov R1#2 ( assembly language )
    1000 0010 ( machine language )
    8=6+2
    Add A, R1
    0100 0110 0010

    machine language

    1000 0110
    1000 0010
    0100 0110 0010

    assembly language
    mov A, #6
    mov R1,#2
    add A,R1

    I know assembly code convert into machine code but for low level understanding how we developed assembly language to understand machine language
     
  2. jcsd
  3. Aug 23, 2014 #2

    Mark44

    Staff: Mentor

    Are you asking a question here? It's hard to tell without punctuation such as a '?' at the end. If you're asking 'how [did] we develop assembly language to understand machine language?', the answer is, we didn't develop assembly language to understand machine language - we developed assembly language to make programming simpler. Each assembly language instruction is converted by the assembler into the corresponding machine code.

    Assembly language is somewhat easier for humans to comprehend, because the instructions (such as MOV, ADD, and so on) are reasonably close to words in English.
     
  4. Aug 23, 2014 #3
    I know assembler convert assembly code into machine code
    I think you are talking i this way

    suppose we want to add two 8 bit number

    example 6+ 2 =8


    suppose we have binary sequence
    Mov (1000)
    Add (0100)
    6(00000110)
    2(00000010)
    8(00001000)

    we write assembly program
    assembly language
    mov A, #6
    mov R1,#2
    add A,R1

    assembler convert assembly code into machine code
    machine language
    1000 0110
    1000 0010
    0100 0110 0010

    we can burn this machine code into the memory of micro controller where control unit tell the cpu what to do. and cpu perform arithmetic and logic operation

    instruction

    Mov
    shift
    add
    multiply
    subtract

    registers
    accumulator
    R1,R2.....
    address register
    data register


    assembly statement
    mov A, # 6 ( assembly language )
    1000 0110 ( machine language )
    6(0110) indicate data value that will be store in data register
    (1000) indicate the mov operation
    but how does assembler know that the value 0110 is need to store in A register
    assemble convert symbol A into machine code
    A101 and # 10

    just for example
    mov A, # 6
    1000 101 10 0110
    here assembly statement is converted into machine language
     
    Last edited: Aug 23, 2014
  5. Aug 23, 2014 #4

    FactChecker

    User Avatar
    Science Advisor
    Gold Member

    I think you are missing a step in converting assembly code to machine code. Most assembly languages allow variable names like 'A'. So 'A' might be a symbolic name for a register that is not yet assigned. That makes writing assembly code much easier. The assembler does a step where it replaces the variable names with some physical register numbers or memory locations. Then the machine code will use the actual register numbers.
     
  6. Aug 23, 2014 #5
    which step are you talking

    In my example A indicate accumulator

    can you tell me example where we write instruction for data and address
     
  7. Aug 23, 2014 #6

    Mark44

    Staff: Mentor

    I think that what you're missing is that the destination register is usually encoded in the machine code itself. I don't know what CPU you're using, so can't say for sure in your case. For the Intel CPUs, for which I'm more familiar, the machine code for a move to AL is 0xA0 and for a move to AX, it is 0xA1. Moves to different registers or to memory have different machine code.

    In your example, the machine code 1000 probably means "move to accumulator". Hope that helps.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Assembly laguage
  1. Assembly code (Replies: 4)

  2. Help in assembly (Replies: 6)

  3. C++ to Assembly (Replies: 4)

  4. Assembly help (Replies: 2)

  5. Assembly language (Replies: 5)

Loading...