about summary refs log tree commit diff stats
path: root/apps/survey.subx
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-03-07 17:32:39 -0800
committerKartik Agaram <vc@akkartik.com>2020-03-07 17:40:45 -0800
commit3cf03158599472b1f6713192d9fa2b120f9f209b (patch)
tree4982565ff8b289847c1c263f4d9aeb3c2360b98b /apps/survey.subx
parent9ee4b34e068550462d440ebc522c7e8ad0c0f2e6 (diff)
downloadmu-3cf03158599472b1f6713192d9fa2b120f9f209b.tar.gz
6094 - new 'compute-offset' instruction
If indexing into a type with power-of-2-sized elements we can access them
in one instruction:

  x/reg1: (addr int) <- index A/reg2: (addr array int), idx/reg3: int

This translates to a single instruction because x86 instructions support
an addressing mode with left-shifts.

For non-powers-of-2, however, we need a multiply. To keep things type-safe,
it is performed like this:

  x/reg1: (offset T) <- compute-offset A: (addr array T), idx: int
  y/reg2: (addr T) <- index A, x

An offset is just an int that is guaranteed to be a multiple of size-of(T).
Offsets can only be used in index instructions, and the types will eventually
be required to line up.

In the process, I have to expand Input-size because mu.subx is growing
big.
Diffstat (limited to 'apps/survey.subx')
-rw-r--r--apps/survey.subx2
1 files changed, 1 insertions, 1 deletions
diff --git a/apps/survey.subx b/apps/survey.subx
index fd7b212f..db8fb08c 100644
--- a/apps/survey.subx
+++ b/apps/survey.subx
@@ -115,7 +115,7 @@ $subx-survey-main:end:
 
 subx-survey:  # infile: (addr buffered-file), out: (addr buffered-file)
     # pseudocode
-    #   var in: (stream byte 4096)
+    #   var in: (stream byte Input-size)
     #   slurp(infile, in)
     #   var segments: (stream segment-info)
     #   var labels: (stream label-info Max-labels)