diff options
author | Kartik Agaram <vc@akkartik.com> | 2020-06-13 20:23:51 -0700 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2020-06-13 20:23:51 -0700 |
commit | ef845524e90c736b6cbab9320bc41114d421ff63 (patch) | |
tree | cd9d0e11b1cba8fa035340e697ee0fa9ca0ae0e2 /mu_summary | |
parent | 7e55a20ff4c9bdb64b55daddd551f19cd7a51bcb (diff) | |
download | mu-ef845524e90c736b6cbab9320bc41114d421ff63.tar.gz |
6516 - operations on bytes
Byte-oriented addressing is only supported in a couple of instructions in SubX. As a result, variables of type 'byte' can't live on the stack, or in registers 'esi' and 'edi'.
Diffstat (limited to 'mu_summary')
-rw-r--r-- | mu_summary | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/mu_summary b/mu_summary index f97e1bd6..286f8286 100644 --- a/mu_summary +++ b/mu_summary @@ -98,7 +98,7 @@ register): var/reg <- xor n xor-with var, n - var1/reg1 <- copy var2/reg2 + var/reg <- copy var2/reg2 copy-to var1, var2/reg var/reg <- copy var2 var/reg <- copy n @@ -118,6 +118,23 @@ Any instruction above that takes a variable in memory can be replaced with a dereference (`*`) of an address variable in a register. But you can't dereference variables in memory. +## Byte operations + +A special-case is variables of type 'byte'. Mu is a 32-bit platform so for the +most part only supports types that are multiples of 32 bits. However, we do +want to support strings in ASCII and UTF-8, which will be arrays of bytes. + +Since most x86 instructions implicitly load 32 bits at a time from memory, +variables of type 'byte' are only allowed in registers, not on the stack. Here +are the possible instructions for reading bytes to/from memory: + + var/reg <- copy-byte var2/reg2 # var: byte, var2: byte + var/reg <- copy-byte *var2/reg2 # var: byte, var2: (addr byte) + copy-byte-to *var1/reg1, var2/reg2 # var1: (addr byte), var2: byte + +In addition, variables of type 'byte' are restricted to (the lowest bytes of) +just 4 registers: eax, ecx, edx and ebx. + ## Primitive jump instructions There are two kinds of jumps, both with many variations: `break` and `loop`. |