assembly language

Cards (32)

  • Machine code is binary 0 and 1, the only language the CPU recognizes, consisting of a sequence of instructions
  • Instruction
    Consists of an opcode (operational code) and operands
  • Opcode defines the action, operands define the data or address
  • Machine code instruction has a fixed number of bits, with some used for opcode and some for operands
  • Assembly language is a low-level programming language that uses symbolic instructions to represent opcodes and operands
  • Assembly language
    • Allows human-readable commands and mnemonics
    • Closely linked to the hardware
    • Needs an assembler to translate to machine code
  • Special features of assembly language
    • Commands (not run by computer)
    • Symbolic names for constants
    • Labels for addresses
    • Macros
    • Directives
  • Symbolic addressing
    Memory locations referred to by labels or symbols
  • Absolute addressing
    Memory locations referred to by exact addresses
  • Relative addressing
    Memory locations referred to relative to a base address
  • Two-pass assembler

    1. First pass gathers information about labels and addresses
    2. Second pass generates machine code
  • Addressing modes
    • Immediate
    • Direct
    • Indirect
    • Indexed
  • Immediate addressing
    Instruction utilizes the value directly
  • Direct addressing
    Instruction uses the value stored at the specified address
  • Indirect addressing
    Instruction uses the address stored at the specified address to find the value
  • Indexed addressing
    Instruction uses the value in an index register plus an offset to find the address
  • Indirect addressing
    An addressing technique in computer programming where an index or offset is added to a base address to access a specific memory location
  • Indirect addressing
    1. Look into what is inside the index register
    2. Add it with the offset
    3. Go to the resulting address to find the value
  • Data movement instructions
    Instructions that move data, including ldm, ldr, ldd, ldi
  • Data movement instructions
    • ldm
    • ldr
    • ldd
    • ldi
  • ldd (direct addressing)

    Load the contents at the given address into the accumulator
  • ldi (indirect addressing)

    Look into the address specified, then use that as the address to load the value into the accumulator
  • sto
    Store the content of the accumulator into the specified address
  • mov
    Move the contents of the accumulator into another register
  • ldx (index addressing)

    Look up the value in the index register, add it to the operand, then load the value at that address into the accumulator
  • Input/Output instructions
    in takes a value from the keyboard and stores it in the accumulator, out displays the character corresponding to the ASCII code in the accumulator
  • Comparison and jump instructions
    cmp compares the accumulator to a value, sets flags in the status register, then jmp and jpn instructions can jump to a new address based on the comparison result
  • Arithmetic instructions
    add, sub, inc, dec allow performing arithmetic operations on values in the accumulator
  • Shift operations
    Logical shifts (lsl, lsr) can be used for fast multiplication and division by powers of 2
  • Bitwise logic operations
    and, or, xor perform bitwise logical operations on values in the accumulator
  • Status register
    Stores flags indicating conditions like carry, negative, overflow, etc. to track the results of arithmetic and comparison operations
  • Tracing program execution
    Use a trace table to track the values stored in registers and memory locations at each step of the program