From 78357b8852626b510527f3b8d770a7dd8956fcc7 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Fri, 16 Jul 2021 08:38:43 -0700 Subject: . --- html/linux/apps/ex4.subx.html | 99 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 html/linux/apps/ex4.subx.html (limited to 'html/linux/apps/ex4.subx.html') diff --git a/html/linux/apps/ex4.subx.html b/html/linux/apps/ex4.subx.html new file mode 100644 index 00000000..1b3bd941 --- /dev/null +++ b/html/linux/apps/ex4.subx.html @@ -0,0 +1,99 @@ + + + + +Mu - linux/apps/ex4.subx + + + + + + + + + + +https://github.com/akkartik/mu/blob/main/linux/apps/ex4.subx +
+ 1 # Read a character from stdin, save it to a global, write it to stdout.
+ 2 #
+ 3 # To run:
+ 4 #   $ bootstrap/bootstrap translate apps/ex4.subx -o ex4
+ 5 #   $ bootstrap/bootstrap run ex4
+ 6 
+ 7 == data
+ 8 
+ 9 # the global variable we save to
+10 X:
+11     0/imm32  # space for read() to write to
+12 
+13 == code
+14 
+15 Entry:
+16 # read(stdin, X, 1)
+17 # . fd = 0 (stdin)
+18 bb/copy-to-ebx  0/imm32
+19 # . data = X (location to write result to)
+20 b9/copy-to-ecx  X/imm32
+21 # . size = 1 character
+22 ba/copy-to-edx  1/imm32
+23 # . syscall
+24 e8/call  syscall_read/disp32
+25 
+26 # write(stdout, X, 1)
+27 # . fd = 1 (stdout)
+28 bb/copy-to-ebx  1/imm32
+29 # . initialize X (location to read from)
+30 b9/copy-to-ecx  X/imm32
+31 # . size = 1 character
+32 ba/copy-to-edx  1/imm32
+33 # . syscall
+34 e8/call  syscall_write/disp32
+35 
+36 # exit(ebx)
+37 e8/call  syscall_exit/disp32
+38 
+39 # . . vim:nowrap:textwidth=0
+
+ + + -- cgit 1.4.1-2-gfad0