about summary refs log tree commit diff stats
path: root/subx/examples/ex1.2.subx
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2018-09-01 09:39:36 -0700
committerKartik Agaram <vc@akkartik.com>2018-09-01 09:39:36 -0700
commitea7f869856a614d14de31c680c8dd290de1cc113 (patch)
tree6cbbf70db886032a807bcc9e64d27412fbbe9cc3 /subx/examples/ex1.2.subx
parenta413105a5dc4741ccd1c364cc82609d2aa25f6c5 (diff)
downloadmu-ea7f869856a614d14de31c680c8dd290de1cc113.tar.gz
4529 - move examples to a sub-directory
Diffstat (limited to 'subx/examples/ex1.2.subx')
-rw-r--r--subx/examples/ex1.2.subx20
1 files changed, 20 insertions, 0 deletions
diff --git a/subx/examples/ex1.2.subx b/subx/examples/ex1.2.subx
new file mode 100644
index 00000000..2652037a
--- /dev/null
+++ b/subx/examples/ex1.2.subx
@@ -0,0 +1,20 @@
+## first program: same as https://www.muppetlabs.com/~breadbox/software/tiny/teensy.html
+# Just return 42.
+#
+# To run:
+#   $ subx translate ex1.2.subx ex1
+#   $ subx run ex1
+# Expected result:
+#   $ echo $?
+#   42
+
+== 0x08048054  # code segment, after leaving room for ELF header
+# instruction                     effective address                                                   operand     displacement    immediate
+# op          subop               mod             rm32          base        index         scale       r32
+# 1-3 bytes   3 bits              2 bits          3 bits        3 bits      3 bits        2 bits      2 bits      0/1/2/4 bytes   0/1/2/4 bytes
+  bb/copy                                                                                                                         2a/imm32          # copy 42 to EBX
+  # exit(EBX)
+  b8/copy                                                                                                                         1/imm32           # copy 1 to EAX
+  cd/syscall                                                                                                                      0x80/imm8         # int 80h
+
+# vim:ft=subx
santi/profani-tty/commit/src/contact.h?id=8c9f91624646d22121166446f3c16edbcd7026b6'>8c9f9162 ^
b5e06a07 ^
6e46e8fe ^
facb2a65 ^
8e90f7a4 ^
c5f76721 ^
8e90f7a4 ^
a84e4ade ^
8e90f7a4 ^
a84e4ade ^
8e90f7a4 ^
2f2fa8de ^
b5e06a07 ^
a0eda420 ^
d300e8e7 ^
a061b0d4 ^

8e90f7a4 ^
6794fb81 ^
a84e4ade ^
e955df88 ^
d017999a ^

9dd5456f ^
581c1e8b ^
383d91ec ^
6e46e8fe ^

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72