Ducky ISA

Ducky ISA

  • Development
  • Running
  • Downloads
  • Contribute
  • Documentation

›DuckyISA Specification

Getting Started

  • Introduction
  • Downloads
  • Contribute

Tools

  • Toolchain
  • libducky

Implementations

  • QEMU
  • "Mallard" Board

Apps

  • Examples
  • Ducky FORTH
  • MicroPython

DuckyISA Specification

  • Terms
  • Registers
  • Memory model
  • Exception Vector Table
  • Instruction Set

Registers

General Purpose Registers

DuckyISA provides 32 32-bit registers:

  • r0 to r29 are general purpose registers
  • r30 is nicknamed fp and serves as a frame pointer
  • r31 is nicknamed sp and serves as a stack pointer

Both fp and sp can be manipulated by common instructions, but both are used by instructions implementing calls and returns and such instructions may read or write their content as well.

Flags register

Flags register is a read-only pseudo-register. It is not possible to change its value by writing into it, yet its value is modified by some instructions by reflecting their effects on the CPU core.

MaskFlagUsage
0x00PIf set, CCPU core runs in a privileged mode, and it is possible to run protected instructions.
0x01HIf set, hardware interrupts can be delivered to the CPU core.
0x02Reserved.
0x04ESet when the last two compared values were equal.
0x08ZSet when the last instruction produced zero.
0x10OSet when the last instruction produced value too large to fit into a register.
0x20SSet when the last instruction produced value with the highest bit set.

Instruction Pointer

The Instruction Pointer register (IP) is a hidden register, 32 bits wide, holding the address of the instruction that will be executed next. It is not possible to modify it directly, it is however saved to and restored from a stack during routine calls and exception handling.

Control registers

Control registers allow inspection or modification of various runtime properties of the CPU core.

Access to these registers is allowed only in privileged mode (i.e. P flag is set).

CR0

cr0 register contains so-called CPUID value which identifies location of the CPU in a global system topology when system can have multiple CPUs, each with multiple cores.

31             16 15             0
 v              v v              v
+----------------+----------------+
| CPU            | core           |
+----------------+----------------+

There is always a core whose cr0 contains 0x00000000 since there's always at least a CPU with at least one core.

This register is read-only.

CR1

Contains address of Exception Vector Table of this core.

Be aware that any address is accepted - no aligment or any other restrictions are enforced.

CR2

Contains contains Page Table address of this core.

Be aware that any address is accepted - no aligment or any other restrictions are enforced.

CR3

Contains several flags describing behavior of the core.

MaskFlagAccessUsage
0x00PTERWIf set, page tables are enabled and every memory access is affected by their configuration.
0x02EMR-If set, the core is being emulated. Hardware implementations must return zero.
0x04JITR-If set, JIT optimizations are enabled. Valid only when EM is set.
0x08VMDBGRWIf set, core will produce huge amount of debugging logs. Valid only when EM is set.
← TermsMemory model →
  • General Purpose Registers
  • Flags register
  • Instruction Pointer
  • Control registers
    • CR0
    • CR1
    • CR2
    • CR3
Ducky ISA
Docs
Getting Started (or other categories)Guides (or other categories)API Reference (or other categories)
Community
User ShowcaseStack OverflowProject ChatTwitter
More
BlogGitHub
Facebook Open Source
Copyright © 2019 Milos Prchlik <happz@happz.cz>