From ef845524e90c736b6cbab9320bc41114d421ff63 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Sat, 13 Jun 2020 20:23:51 -0700 Subject: 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'. --- mu_summary | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'mu_summary') 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`. -- cgit 1.4.1-2-gfad0