Jumps, loops, multiplication and bits

Comparing and jumping, signed and unsigned conditions, counting loops, MUL and DIV, printing numbers, and the logic and shift instructions.

About 10 hours of study

Learning objectives

Lessons

  1. 1

    Comparing and jumping

    CMP and the conditional jumps that read its flags, signed and unsigned comparisons, and how if and if-else are written with labels.

  2. 2

    Loops

    Counting loops with LOOP and CX, while-loops built from CMP and jumps, guarding against CX = 0, and nested loops that save CX on the stack.

  3. 3

    Multiplication and division Intermediate

    MUL and DIV with their fixed registers (AX, and DX:AX for words), IMUL and IDIV for signed numbers, the divide overflow, and printing a number of any size by dividing by 10.

  4. 4

    Bits: logic, shifts and rotates Intermediate

    AND, OR, XOR, NOT and TEST with masks, turning letters to upper or lower case, SHL and SHR as fast multiply and divide by 2, rotates, and printing a number in binary.

Module practice

Module quiz

1. Which jump is taken when the first operand of CMP is greater than the second, as unsigned numbers?
2. CX = 5 when a LOOP loop starts. How many times does its body run?
3. AX = 200 and BL = 9. What are AL and AH after DIV BL?
4. Which instruction turns the letter q (71h) into Q (51h)?
5. AX = 3. What is AX after two instructions SHL AX, 1?
6. DX = 1, AX = 0 and BX = 1. What happens on DIV BX?

‹ Arithmetic, flags and input and outputArrays, the stack, procedures and strings ›