id: 4
title: Multiply and Divide
subtitle: Stronger arithmetic
description: Learn the MUL and XDIV instructions

tutorial:
  - title: MUL — multiplication
    text: >
      MUL is also three operands:
    code: |
      MOV R0, #6
      MOV R1, #7
      MUL R2, R0, R1    ; R2 = 6 × 7 = 42
  - title: XDIV — integer division
    text: >
      XDIV does integer division (the fractional part is discarded):
    code: |
      MOV R0, #100
      MOV R1, #4
      XDIV R2, R0, R1    ; R2 = 100 ÷ 4 = 25

goal: Compute **6 × 7** into R0 and **100 ÷ 4** into R1

initialState: {}

testCases:
  - init: {}
    expected:
      registers:
        R0: 42
        R1: 25

hints:
  - "MOV the numbers into registers first, then MUL/XDIV"
  - "MUL R0, R2, R3 puts R2×R3 into R0"
  - "Answer: MOV R2, #6 / MOV R3, #7 / MUL R0, R2, R3 / MOV R2, #100 / MOV R3, #4 / XDIV R1, R2, R3 / XHLT"

starThresholds: [7, 9, 12]

starterCode: |
  ; Compute 6×7 into R0
  ; Compute 100÷4 into R1


  XHLT

showMemory: false
