Thursday, 8 December 2011

Difference between instructions, pseudo-instructions and assembly directives

Instruction: 
No need to say more. It is a kind of mnemonic which can be mapped into binary code directly by translating opcode and operand.

Pseudo-instruction: 
Pseudo-instruction is not a real instruction related to ISA(Instruction Set Architecture). It exists in assembler which can produce corresponding real instructions after assembling. For example, LDR R0, = immediate is a pseudo-instruction. It may produce one MOV or several instructions which depends on the size of the immediate.
PS: LDR R0, [indirect address] is not a pseudo-instruction. It is a real instruction in ISA of ARM.
Pseudo instructions are essentially pre-defined macros, so you can implement your own pseudo instructions if you want.

Directive: 
Also not a real instruction, and only exists in assembler. But after assembling, it does not produce any code. It just indicates the assembler how to configure the processor, for example: changing modes(ARM or Thumb-2), code location (AREA NAME, CODE(DATA), READONLY(READWRITE))
So in 8051, DB, DS, EQU, DSEG, CSEG and others similar are all direcitives

Reference:http://www.embeddedrelated.com/usenet/embedded/show/25889-1.php, accessed on Dec 8th, 2011

2 comments:

  1. yeah, thanks for explanation but, I want to ask that, Are they assembled before the actual instructions? for example:
    ```
    LEA R0 , DAYS
    ADD R3 , R3 , x0
    LOOP
    BRz DISPLAY
    ADD R0 , R0 , #10
    ADD R3 , R3 , #−1
    BR LOOP
    DISPLAY PUTS
    ...
    HALT
    ...
    DAYS
    .STRINGZ ” Sunday

    .STRINGZ ” Monday

    .STRINGZ ” T u e s d a y ”
    .STRINGZ ” Wednesday ”
    .STRINGZ ” T h u r s d a y ”
    .STRINGZ ” F r i d a y ”
    .STRINGZ ” S a t u r d a y ”
    ```

    in this example we had to know
    where is the address of 'DAYS' to run LEA R0, DAYS
    So there are so much work for the assembler right?

    ReplyDelete

Difference between "docker stop" and "docker kill"

 To stop a running container, you can use either "docker stop" or "docker kill" command to do so. Although it seems doin...