5410 - 4 examples passing
Clean up other examples as well to satisfy the requirements in commit 5404.
This commit is contained in:
parent
4d37fb5213
commit
294a152063
|
@ -337,7 +337,28 @@ runnable on a Linux system running on Intel x86 processors, either 32- or
|
|||
|
||||
## Roadmap and status
|
||||
|
||||
* Bootstrapping a SubX-\>ELF translator in SubX (90% complete; now in testing)
|
||||
* Bootstrapping a SubX-\>ELF translator in SubX
|
||||
- examples/ex1 ✓
|
||||
- examples/ex2 ✓
|
||||
- examples/ex3
|
||||
- examples/ex4 ✓
|
||||
- examples/ex5
|
||||
- examples/ex6
|
||||
- examples/ex7 ✓
|
||||
- examples/ex8
|
||||
- examples/ex9
|
||||
- examples/ex10
|
||||
- examples/ex11
|
||||
- examples/ex12
|
||||
- apps/factorial.subx
|
||||
- apps/crenshaw2-1.subx
|
||||
- apps/crenshaw2-1b.subx
|
||||
- apps/handle.subx
|
||||
- apps/hex.subx
|
||||
- apps/survey.subx
|
||||
- apps/pack.subx
|
||||
- apps/assort.subx
|
||||
- apps/dquotes.subx
|
||||
|
||||
* Testable, dependency-injected vocabulary of primitives
|
||||
- Streams: `read()`, `write()`. (✓)
|
||||
|
|
Binary file not shown.
|
@ -67,4 +67,6 @@ $argv-equal:false:
|
|||
b8/copy-to-EAX 0/imm32
|
||||
c3/return
|
||||
|
||||
== data 0x0a000000
|
||||
|
||||
# . . vim:nowrap:textwidth=0
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
# . 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
|
||||
|
||||
Entry:
|
||||
# syscall(mmap, 0x1000)
|
||||
bb/copy-to-EBX Mmap-new-segment/imm32
|
||||
b8/copy-to-EAX 0x5a/imm32/mmap
|
||||
|
|
Binary file not shown.
|
@ -9,6 +9,7 @@
|
|||
|
||||
== code 0x09000000
|
||||
|
||||
Entry:
|
||||
# EBX = 1
|
||||
bb/copy-to-EBX 1/imm32
|
||||
# increment EBX
|
||||
|
@ -17,4 +18,6 @@ bb/copy-to-EBX 1/imm32
|
|||
b8/copy-to-EAX 1/imm32/exit
|
||||
cd/syscall 0x80/imm8
|
||||
|
||||
== data 0x0a000000
|
||||
|
||||
# . . vim:nowrap:textwidth=0
|
||||
|
|
Binary file not shown.
|
@ -12,6 +12,7 @@
|
|||
# . 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
|
||||
|
||||
Entry:
|
||||
# result: EBX = 0
|
||||
bb/copy-to-EBX 0/imm32
|
||||
# counter: ECX = 1
|
||||
|
@ -33,4 +34,6 @@ $exit:
|
|||
b8/copy-to-EAX 1/imm32/exit
|
||||
cd/syscall 0x80/imm8
|
||||
|
||||
== data 0x0a000000
|
||||
|
||||
# . . vim:nowrap:textwidth=0
|
||||
|
|
|
@ -12,6 +12,7 @@ X:
|
|||
|
||||
== code 0x09000000
|
||||
|
||||
Entry:
|
||||
# syscall(read, stdin, X, 1)
|
||||
# . fd = 0 (stdin)
|
||||
bb/copy-to-EBX 0/imm32
|
||||
|
|
Binary file not shown.
|
@ -40,4 +40,6 @@ Entry:
|
|||
b8/copy-to-EAX 1/imm32/exit
|
||||
cd/syscall 0x80/imm8
|
||||
|
||||
== data 0x0a000000
|
||||
|
||||
# . . vim:nowrap:textwidth=0
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
# . 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
|
||||
|
||||
Entry:
|
||||
# syscall(write, stdout, X, Size)
|
||||
# . fd = 1 (stdout)
|
||||
bb/copy-to-EBX 1/imm32
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
# . 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
|
||||
|
||||
Entry:
|
||||
# syscall(creat, Filename)
|
||||
bb/copy-to-EBX Filename/imm32
|
||||
b9/copy-to-ECX 0x180/imm32/fixed-perms
|
||||
|
|
Binary file not shown.
|
@ -19,6 +19,7 @@
|
|||
# . 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
|
||||
|
||||
Entry:
|
||||
# . prolog
|
||||
89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP
|
||||
# EAX = ascii-length(argv[1])
|
||||
|
@ -55,4 +56,6 @@ $ascii-length:end:
|
|||
# return EAX
|
||||
c3/return
|
||||
|
||||
== data 0x0a000000
|
||||
|
||||
# . . vim:nowrap:textwidth=0
|
||||
|
|
Binary file not shown.
|
@ -22,6 +22,7 @@
|
|||
# . 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
|
||||
|
||||
Entry:
|
||||
# . prolog
|
||||
89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP
|
||||
# ascii-difference(argv[1], argv[2])
|
||||
|
@ -49,4 +50,6 @@ ascii-difference: # (s1, s2) : null-terminated ascii strings
|
|||
29/subtract 3/mod/direct 0/rm32/EAX . . . 1/r32/ECX . . # subtract ECX from EAX
|
||||
c3/return
|
||||
|
||||
== data 0x0a000000
|
||||
|
||||
# . . vim:nowrap:textwidth=0
|
||||
|
|
|
@ -130,18 +130,6 @@ echo ex12
|
|||
./subx run examples/ex12 # final byte of mmap'd address is well-nigh guaranteed to be 0
|
||||
test `uname` = 'Linux' && examples/ex12
|
||||
|
||||
echo handle
|
||||
./subx translate 0*.subx apps/handle.subx -o apps/handle
|
||||
[ "$1" != record ] && git diff --exit-code apps/handle
|
||||
./subx run apps/handle > handle.out 2>&1 || true
|
||||
grep -q 'lookup succeeded' handle.out || { echo "missing success test"; exit 1; }
|
||||
grep -q 'lookup failed' handle.out || { echo "missing failure test"; exit 1; }
|
||||
test `uname` = 'Linux' && {
|
||||
apps/handle > handle.out 2>&1 || true
|
||||
grep -q 'lookup succeeded' handle.out || { echo "missing success test"; exit 1; }
|
||||
grep -q 'lookup failed' handle.out || { echo "missing failure test"; exit 1; }
|
||||
}
|
||||
|
||||
echo factorial
|
||||
./subx translate 0*.subx apps/factorial.subx -o apps/factorial
|
||||
[ "$1" != record ] && git diff --exit-code apps/factorial
|
||||
|
@ -176,6 +164,18 @@ test `uname` = 'Linux' && {
|
|||
echo
|
||||
}
|
||||
|
||||
echo handle
|
||||
./subx translate 0*.subx apps/handle.subx -o apps/handle
|
||||
[ "$1" != record ] && git diff --exit-code apps/handle
|
||||
./subx run apps/handle > handle.out 2>&1 || true
|
||||
grep -q 'lookup succeeded' handle.out || { echo "missing success test"; exit 1; }
|
||||
grep -q 'lookup failed' handle.out || { echo "missing failure test"; exit 1; }
|
||||
test `uname` = 'Linux' && {
|
||||
apps/handle > handle.out 2>&1 || true
|
||||
grep -q 'lookup succeeded' handle.out || { echo "missing success test"; exit 1; }
|
||||
grep -q 'lookup failed' handle.out || { echo "missing failure test"; exit 1; }
|
||||
}
|
||||
|
||||
echo hex
|
||||
./subx translate 0*.subx apps/hex.subx -o apps/hex
|
||||
[ "$1" != record ] && git diff --exit-code apps/hex
|
||||
|
@ -234,4 +234,22 @@ test `uname` = 'Linux' && {
|
|||
cat examples/ex1.subx |apps/dquotes |apps/assort |apps/pack |apps/survey |apps/hex |diff examples/ex1 -
|
||||
}
|
||||
|
||||
echo ex2
|
||||
cat examples/ex2.subx |subx_bin run apps/dquotes |subx_bin run apps/assort |subx_bin run apps/pack |subx_bin run apps/survey |subx_bin run apps/hex |diff examples/ex2 -
|
||||
test `uname` = 'Linux' && {
|
||||
cat examples/ex2.subx |apps/dquotes |apps/assort |apps/pack |apps/survey |apps/hex |diff examples/ex2 -
|
||||
}
|
||||
|
||||
echo ex4
|
||||
cat examples/ex4.subx |subx_bin run apps/dquotes |subx_bin run apps/assort |subx_bin run apps/pack |subx_bin run apps/survey |subx_bin run apps/hex |diff examples/ex4 -
|
||||
test `uname` = 'Linux' && {
|
||||
cat examples/ex4.subx |apps/dquotes |apps/assort |apps/pack |apps/survey |apps/hex |diff examples/ex4 -
|
||||
}
|
||||
|
||||
echo ex7
|
||||
cat examples/ex7.subx |subx_bin run apps/dquotes |subx_bin run apps/assort |subx_bin run apps/pack |subx_bin run apps/survey |subx_bin run apps/hex |diff examples/ex7 -
|
||||
test `uname` = 'Linux' && {
|
||||
cat examples/ex7.subx |apps/dquotes |apps/assort |apps/pack |apps/survey |apps/hex |diff examples/ex7 -
|
||||
}
|
||||
|
||||
exit 0
|
||||
|
|
Loading…
Reference in New Issue