ZLA
AST

modulo-operation

Assembly Crash Course
Post Image
February 1, 2026
Read Time: 1 min

Problem

This problem comes from pwn.college: Assembly Crash Course ⤴.

In this level, you will be working with registers. You will be asked to modify or read from registers.

We will set some values in memory dynamically before each run. On each run, the values will change. This means you will need to perform a formulaic operation with registers. We will tell you which registers are set beforehand and where you should put the result. In most cases, it’s rax.

Modulo in assembly is another interesting concept!

x86 allows you to get the remainder after a div operation.

For instance: 10 / 3 results in a remainder of 1.

The remainder is the same as modulo, which is also called the “mod” operator.

In most programming languages, we refer to mod with the symbol %.

Please compute the following: rdi % rsi

Place the value in rax.

Solution

A modulo operation obtains the remainder of a division. In assembly, a division is performed and the remainder is stored in rdx.

For this challenge, to calculate rdi % rsi, we must perform rdi / rsi and then check rdx for the remainder. We’ll then place the remainder in rax.

.intel_syntax noprefix
.global _start

_start:
  mov rax, rdi
  div rsi
  mov rax, rdx