Understanding Assembly Code Assembly Language An instruction has
Understanding Assembly Code
Assembly Language ¡ An instruction has the following format: LABEL OPCODE OPERANDS COMMENTS
OPCODES AND OPERANDS Opcodes are reserved words that correspond to machine instructions ¡ They’ll be given to you in a table (in the exam) with an explanation as to what they do: eg. ADD, AND, NOT, LD, LDR, etc ¡
OPERANDS –the patient! ¡ ¡ ¡ Registers – specified by Rn, where n is the number of the register(0 -7) Numbers – indicated by # (decimal) or x(hexadeciamal) (or suffix h –hex) Label – symbolic name of the memory location (think of it like a goto) Operands are separated by commas Number, type, and order correspond to the machine instruction
SPOT THE OPCODES (the doctor) ¡ ADD R 1, R 3 ADD R 1, #3 LD R 6, NUMBER BRz LOOP
Labels and Comments Labels are placed at the beginning of the line ¡ Assigns a symbolic name to the memory location ¡ Example: ¡ LOOP ADD R 1, #-1 BRp LOOP ¡
Instruction Set ¡ Data Transfer ¡ Arithmetic Operations ¡ Logical operations ¡ Test and Branch Instructions
Instruction set Data Arithmetic Transfer Operations Logical Operations Test and branch instructions MOVE LOAD STORE AND OR NOT EOR Uncondition al Conditional Subroutine calls Returns ADD SUBTRACT MULTIPLY DIVIDE SHIFT (MUL/DIVIDE to shift bits left or right)an arithmetic shift
- Slides: 9