Assembly Language

?

Instruction Set

  • Mnemonics that are used for instructions depend on the processor being used - each processor has its own instruction set
  • These are either RISC or CISC
  • An instruction set is the pattern of 0s and 1s that a particular processor recognises as commands along with their associated meaning
1 of 8

Assembly Language Statement

  • CMP r1, #10 compares the value in register 1 with the value 10

This consists of 4 parts:

  • Operation Code- Uses letters to hekp explain what the command does (aka Opcode)
  • Operands- The number of operands following an opcode depends on what the code is/does. Operands can be values, memory locations, general purpose registers.
  • Addressing Mode- In the example above the # indicates that the data following is an actual value
  • Comment- Optional but recommended as assembly language is much more difficult to follow.
2 of 8

Immediate and Direct Addressing

  • Direct Addressing- This mode tells the CPU which address contains the data contains the data you want to access.

Example: LDR R1, 100 <- Would copy the datain memory location 100 into register 1

  • Immediate Addressing- This loads the data directly. The operand contains the actual number

Example: MOV R1, #10 <- Would move the value 10 into register 1

3 of 8

Types of Operation Code

4 types of Operation Code:

  • Arthimetic Operations
  • Data Transfer Operations
  • Logical Operations
  • Branch Operations
4 of 8

Arthimetic Operations

  • Add, Subtract, Multiply, Divide, Increment, Decrement
  • ADD R0, R1, #03 <- Add 3 to R1 and store in R0
  • SUB R0, R1, #03 <- Subtract 3 from R1 and store in R0
  • Compare- two values for less than, greater than etc. (CMP)
  • Negate- Reverse the sign

Shift- left and right binary positions

  • Logical Shift- Moves One e.g. [10010] -> [00100] (with carry)
  • Rotate =Shift- Flips (LSB becomes MSB) e.g. [10010] -> [01101]
  • Status Register is udes to record certain features of a calculation (has it generated an overflow, is result negative/zero etc.)
5 of 8

Data Transfer Operations

  • Moves data between registers and main memory
  • MOV (Move), STR (Store), LDR (Load)
6 of 8

Logical Operations

  • Bitwise AND, OR, NOT and XOR
  • Each bit in a bit string is compared with the corresponding bit in another bit string of the same length
  • Can be used to compare and calculate values as well as mask out values
7 of 8

Branch Operations

  • This allows programs to not be linear
  • BNE = Branch if not equal
  • BEQ = Branch if equal
  • BGT = Branch if greater than
  • BLT = Branch if less than
  • The results of the last comparison will be used to determine whether you will jump or not
  • You will need a label to tell the program where to jump to
  • Using a high level language hides the complexity of assembly langauge
8 of 8

Comments

No comments have yet been made

Similar Computing resources:

See all Computing resources »See all Assembly Language resources »