aboutsummaryrefslogtreecommitdiffstats
path: root/atk16_schasm/note.md
diff options
context:
space:
mode:
Diffstat (limited to 'atk16_schasm/note.md')
-rw-r--r--atk16_schasm/note.md35
1 files changed, 35 insertions, 0 deletions
diff --git a/atk16_schasm/note.md b/atk16_schasm/note.md
new file mode 100644
index 0000000..e48e7a5
--- /dev/null
+++ b/atk16_schasm/note.md
@@ -0,0 +1,35 @@
+# note about loads & stores
+
+the indirection count tells the CPU how many times to dereference the address before reading or writing the value. in loads, the value can range from 0 to 3, and in stores, the value can range from 1 to 3. the indirection count is 0-indexed, so a value of 0 means no indirection, 1 means one level of indirection, and so on.
+
+ ;; asm
+ (ld R0 (u16 #x1234) indirect: 0)
+ ;; equivalent pseudocode
+ R0 := 0x1234
+
+ ;; asm
+ (ld R0 (u16 #x1234) indirect: 2)
+ ;; equivalent pseudocode
+ R0 := **(0x1234)
+
+ ;; asm
+ (ld R0 R1)
+ ;; equivalent pseudocode
+ R0 := R1
+
+ ;; asm
+ (ld R0 R1 indirect: 3)
+ ;; equivalent pseudocode
+ R0 := ***R1
+
+ ;; asm
+ (st R0 (u16 #x1234) indirect: 2)
+ ;; equivalent pseudocode
+ **(0x1234) := R0
+
+ ;; asm
+ (st R0 R1 indirect: 1)
+ ;; equivalent pseudocode
+ *R1 := R0
+
+a load with an indirection count of 0 in reg mode is a `mov`.