1.1--- a/draft/a-bit-of-risc.org Mon Aug 12 18:31:37 2024 -0400
1.2+++ b/draft/a-bit-of-risc.org Sun Aug 18 22:16:12 2024 -0400
1.3@@ -1,6 +1,7 @@
1.4 #+title: A Bit of RISC
1.5 #+date: [2024-03-11 Mon]
1.6 #+setupfile: ../../clean.theme
1.7+#+property: header-args :eval no-export
1.8 I recently picked up [[https://dl.acm.org/doi/10.5555/2462741][Hacker's Delight]] and having a lot of fun with
1.9 it. It's a collection of bit-manipulation tricks collected by hackers
1.10 over many years. You can flip open pretty much anywhere in the book
1.11@@ -21,7 +22,13 @@
1.12 You can find most of the code from the book [[https://github.com/hcs0/Hackers-Delight][here]].
1.13
1.14 * Design
1.15+:PROPERTIES:
1.16+:ID: c030566f-1ede-4edc-b393-d2c6c1c2d19f
1.17+:END:
1.18 ** Data Representation
1.19+:PROPERTIES:
1.20+:ID: 6d93e084-1047-4a33-adb3-5c90af96ead0
1.21+:END:
1.22 We'll be sticking with a 32-bit word length as recommended in the
1.23 Preface. We will also represent registers as integers whenever
1.24 possible, instead of say a bit-vector. Without going into too much
1.25@@ -36,6 +43,9 @@
1.26 Floating-point support and special purpose registers are not required.
1.27
1.28 ** Instructions
1.29+:PROPERTIES:
1.30+:ID: fb86a212-b49a-44ff-b30b-32c789ca55e2
1.31+:END:
1.32 The Hacker's Delight RISC architecture is described in two tables,
1.33 denoted =basic RISC= and =full RISC= respectively.
1.34
1.35@@ -103,6 +113,9 @@
1.36 instructions directly to Lisp functions using macros.
1.37
1.38 ** Execution Model
1.39+:PROPERTIES:
1.40+:ID: f84fcd3d-86ad-4b9b-a330-4572d6120559
1.41+:END:
1.42 We'll build this machine in Lisp and use plenty intrinsics from
1.43 SBCL. As a starting point I followed Paul Khuong's excellent blog
1.44 post: [[https://pvk.ca/Blog/2014/03/15/sbcl-the-ultimate-assembly-code-breadboard/][SBCL: The ultimate assembly code breadboard]].
1.45@@ -116,6 +129,7 @@
1.46 * The HAKMEM VM
1.47 :properties:
1.48 :header-args: :session t :results none :noeval t
1.49+:ID: 43484c58-ab29-481c-b2b9-17ab4d91e22f
1.50 :end:
1.51 #+name: defpackage
1.52 #+begin_src lisp