Assembly Language

Cards (21)

  • Assembly Language

    Uses mnemonics which are short abbreviated codes that represent Opcodes, making them easier to remember for a human being
  • Example Assembly Language codes
    • Provided by AQA in their exams
  • Operand 2
    There are two possible ways of referencing the operand: immediate referencing or direct referencing
  • Immediate addressing

    If there's a hash before a number, the actual value should be used
  • Direct addressing

    If there's an R before a number, the value in that register number should be used
  • Load and store commands

    1. Values in memory that are going to be used in calculations need to be loaded into the registers - LDR
    2. Results of calculations may need to be stored back to memory locations - STR
  • Add and subtract commands

    1. The first value is held in the second register
    2. The value to add or subtract can be an actual value or value stored in the third register
    3. The output of the operation is stored in the first register
  • MOV command

    Copies the value of <operand2> into a specified register
  • Compare command

    Compares the value in a specified register with an actual value or the value of another register
  • Branching
    A command specifies a non-sequential line to move the execution to next, either a branch or a conditional branch based on the result of a comparison, marked with a label.
  • Labels
    Inserted into the code at the point where the program will recommence after a branch (subheading)
  • Values stored in registers are stored in binary
  • Logical AND and OR operations

    Can be performed between:
  • Exclusive OR (EOR)

    Only outputs a 1 where the two input values are different
  • NOT command (MVN)

    Reverses the ones and zeros in a value and stores it in the specified register
  • Logical Shift Left (LSL)

    Shifts the bits left by the specified number of places
  • Logical Shift Right (LSR)

    Shifts the bits right by the specified number of places
  • Halt command
    Used to terminate an assembly code program
  • Example assembly code program
    1. Load value from memory location 101 into register 0
    2. Load value from memory location 102 into register 1
    3. Use register 2 as a count to keep track of how many times register 1 can be subtracted from register 0 before it becomes negative
    4. Output the value in register 2 as the result of the floor division
  • It's not possible to perform division or floor division in assembly code directly
  • The example program assumes the registers can work with two's complement binary