From 0307e57fdc0c570842c84c69b93d23f13f717f31 Mon Sep 17 00:00:00 2001 From: crc Date: Tue, 1 Jun 2021 19:00:48 +0000 Subject: [PATCH] add test images for each instruction excluding i/o the tests now include a small muri assembly file for each instruction. if your vm runs these successfully and supports basic i/o, it should be sufficient to run a full retro system. FossilOrigin-Name: b80eaeb75ee2b4476f5b5a4aa62adf76da3ed11ac3b2f493f77d9bd4366f8ea9 --- RELEASE-NOTES | 9 +++++++++ tests/Instructions.md | 40 ++++++++++++++++++++++++++++++++++++++++ tests/ad.muri | 10 ++++++++++ tests/an.muri | 14 ++++++++++++++ tests/ca.muri | 12 ++++++++++++ tests/cc.muri | 23 +++++++++++++++++++++++ tests/di.muri | 14 ++++++++++++++ tests/dr.muri | 7 +++++++ tests/du.muri | 6 ++++++ tests/eq.muri | 10 ++++++++++ tests/fe.muri | 19 +++++++++++++++++++ tests/gt.muri | 12 ++++++++++++ tests/ha.muri | 3 +++ tests/instructions.sh | 29 +++++++++++++++++++++++++++++ tests/ju.muri | 10 ++++++++++ tests/li.muri | 8 ++++++++ tests/lt.muri | 12 ++++++++++++ tests/mu.muri | 9 +++++++++ tests/ne.muri | 9 +++++++++ tests/no.muri | 4 ++++ tests/or.muri | 12 ++++++++++++ tests/po.muri | 8 ++++++++ tests/pu.muri | 8 ++++++++ tests/re.muri | 9 +++++++++ tests/sh.muri | 9 +++++++++ tests/st.muri | 20 ++++++++++++++++++++ tests/su.muri | 10 ++++++++++ tests/sw.muri | 9 +++++++++ tests/xo.muri | 14 ++++++++++++++ tests/zr.muri | 18 ++++++++++++++++++ vm/nga-c/image.c | 30 +++++------------------------- 31 files changed, 382 insertions(+), 25 deletions(-) create mode 100644 tests/Instructions.md create mode 100644 tests/ad.muri create mode 100644 tests/an.muri create mode 100644 tests/ca.muri create mode 100644 tests/cc.muri create mode 100644 tests/di.muri create mode 100644 tests/dr.muri create mode 100644 tests/du.muri create mode 100644 tests/eq.muri create mode 100644 tests/fe.muri create mode 100644 tests/gt.muri create mode 100644 tests/ha.muri create mode 100755 tests/instructions.sh create mode 100644 tests/ju.muri create mode 100644 tests/li.muri create mode 100644 tests/lt.muri create mode 100644 tests/mu.muri create mode 100644 tests/ne.muri create mode 100644 tests/no.muri create mode 100644 tests/or.muri create mode 100644 tests/po.muri create mode 100644 tests/pu.muri create mode 100644 tests/re.muri create mode 100644 tests/sh.muri create mode 100644 tests/st.muri create mode 100644 tests/su.muri create mode 100644 tests/sw.muri create mode 100644 tests/xo.muri create mode 100644 tests/zr.muri diff --git a/RELEASE-NOTES b/RELEASE-NOTES index d326e48..8a74221 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -34,6 +34,10 @@ ## I/O +- floating point + + - increased precision of `f:E` and `f:PI` (Kiyoshi) + ## Toolchain ## VM @@ -51,6 +55,7 @@ - retro-repl.c now uses an external image - removed barebones.c (overlaps w/new retro-repl.c) - retro-runtime.c now based on standard retro.c + - changed behavior of -t command line argument (Rick) - nga-nim @@ -69,3 +74,7 @@ - removed references to old command line arguments - removed reference to the no longer existing "ok" prompt - add a note that mentions that Retro does not display a prompt + +## Testing + +- add small test images for each instruction diff --git a/tests/Instructions.md b/tests/Instructions.md new file mode 100644 index 0000000..2268ba2 --- /dev/null +++ b/tests/Instructions.md @@ -0,0 +1,40 @@ +# Testing Instructions + +Build & install Retro. + +Run: + + sh instructions.sh + +Compare resulting stacks to the table below. + +| Opcode | Expected | +| ------ | ------------------------ | +| 0 | | +| 1 | 1 -1 99 -99 | +| 2 | 100 100 200 200 | +| 3 | 100 200 | +| 4 | 200 300 100 | +| 5 | 100 300 200 | +| 6 | 100 300 200 | +| 7 | 10 | +| 8 | 10 | +| 9 | 100 | +| 10 | 10 | +| 11 | 0 -1 | +| 12 | -1 0 | +| 13 | -1 0 0 | +| 14 | 0 0 -1 | +| 15 | 97 98 99 | +| 16 | 97 98 48 | +| 17 | 300 1 | +| 18 | -100 199 | +| 19 | 20000 -9900 | +| 20 | 100 0 1 -1 89 2 | +| 21 | -1 0 0 | +| 22 | -1 -1 0 | +| 23 | 0 -1 0 | +| 24 | 3640 455 | +| 25 | 2 | +| 26 | | + diff --git a/tests/ad.muri b/tests/ad.muri new file mode 100644 index 0000000..859baf2 --- /dev/null +++ b/tests/ad.muri @@ -0,0 +1,10 @@ +~~~ +: main +i liliadli +d 100 +d 200 +d 100 +i liadha.. +d -99 +~~~ + diff --git a/tests/an.muri b/tests/an.muri new file mode 100644 index 0000000..1416817 --- /dev/null +++ b/tests/an.muri @@ -0,0 +1,14 @@ +~~~ +: main +i lilian.. +d -1 +d -1 +i lilian.. +d 0 +d -1 +i lilian.. +d 0 +d 0 +i ha...... +~~~ + diff --git a/tests/ca.muri b/tests/ca.muri new file mode 100644 index 0000000..648575e --- /dev/null +++ b/tests/ca.muri @@ -0,0 +1,12 @@ +~~~ +i liju.... +r main +: subr +i lire.... +d 10 +: main +i lica.... +r subr +i ha...... +~~~ + diff --git a/tests/cc.muri b/tests/cc.muri new file mode 100644 index 0000000..43dad10 --- /dev/null +++ b/tests/cc.muri @@ -0,0 +1,23 @@ +~~~ +: c1 +i lire.... +d 100 + +: c2 +i lire.... +d 200 + +: main +i lilieqli +d 100 +d 100 +r c1 +i cc...... +i lilieqli +d 100 +d 200 +r c2 +i cc...... +i ha...... +~~~ + diff --git a/tests/di.muri b/tests/di.muri new file mode 100644 index 0000000..1f1e91f --- /dev/null +++ b/tests/di.muri @@ -0,0 +1,14 @@ +~~~ +: main +i lilidi.. +d 100 +d 200 +i lilidi.. +d 100 +d -99 +i lilidi.. +d 355 +d 133 +i ha...... +~~~ + diff --git a/tests/dr.muri b/tests/dr.muri new file mode 100644 index 0000000..9da0211 --- /dev/null +++ b/tests/dr.muri @@ -0,0 +1,7 @@ +~~~ +i lililidr +d 100 +d 200 +d 300 +i ha...... +~~~ diff --git a/tests/du.muri b/tests/du.muri new file mode 100644 index 0000000..5f4b677 --- /dev/null +++ b/tests/du.muri @@ -0,0 +1,6 @@ +~~~ +i lidulidu +d 100 +d 200 +i ha...... +~~~ diff --git a/tests/eq.muri b/tests/eq.muri new file mode 100644 index 0000000..fe7e57f --- /dev/null +++ b/tests/eq.muri @@ -0,0 +1,10 @@ +~~~ +i lilieq.. +d 100 +d 200 +i lilieq.. +d 100 +d 100 +i ha...... +~~~ + diff --git a/tests/fe.muri b/tests/fe.muri new file mode 100644 index 0000000..8597c28 --- /dev/null +++ b/tests/fe.muri @@ -0,0 +1,19 @@ +~~~ +i liju.... +r main + +: abc +s abc + +: main +i lifelili +r abc +r abc +d 1 +i adfelili +r abc +d 2 +i adfe.... +i ha...... +~~~ + diff --git a/tests/gt.muri b/tests/gt.muri new file mode 100644 index 0000000..6dea6cd --- /dev/null +++ b/tests/gt.muri @@ -0,0 +1,12 @@ +~~~ +i liligt.. +d 100 +d 200 +i liligt.. +d 100 +d 100 +i liligt.. +d 200 +d 100 +i ha...... +~~~ diff --git a/tests/ha.muri b/tests/ha.muri new file mode 100644 index 0000000..402b388 --- /dev/null +++ b/tests/ha.muri @@ -0,0 +1,3 @@ +~~~ +i ha...... +~~~ diff --git a/tests/instructions.sh b/tests/instructions.sh new file mode 100755 index 0000000..211dab7 --- /dev/null +++ b/tests/instructions.sh @@ -0,0 +1,29 @@ +#!/bin/sh + +echo "no"; retro-muri no.muri >/dev/null; retro -r ngaImage; rm -f ngaImage +echo "li"; retro-muri li.muri >/dev/null; retro -r ngaImage; rm -f ngaImage +echo "du"; retro-muri du.muri >/dev/null; retro -r ngaImage; rm -f ngaImage +echo "dr"; retro-muri dr.muri >/dev/null; retro -r ngaImage; rm -f ngaImage +echo "sw"; retro-muri sw.muri >/dev/null; retro -r ngaImage; rm -f ngaImage +echo "pu"; retro-muri pu.muri >/dev/null; retro -r ngaImage; rm -f ngaImage +echo "po"; retro-muri po.muri >/dev/null; retro -r ngaImage; rm -f ngaImage +echo "ju"; retro-muri ju.muri >/dev/null; retro -r ngaImage; rm -f ngaImage +echo "ca"; retro-muri ca.muri >/dev/null; retro -r ngaImage; rm -f ngaImage +echo "cc"; retro-muri cc.muri >/dev/null; retro -r ngaImage; rm -f ngaImage +echo "re"; retro-muri re.muri >/dev/null; retro -r ngaImage; rm -f ngaImage +echo "eq"; retro-muri eq.muri >/dev/null; retro -r ngaImage; rm -f ngaImage +echo "ne"; retro-muri ne.muri >/dev/null; retro -r ngaImage; rm -f ngaImage +echo "lt"; retro-muri lt.muri >/dev/null; retro -r ngaImage; rm -f ngaImage +echo "gt"; retro-muri gt.muri >/dev/null; retro -r ngaImage; rm -f ngaImage +echo "fe"; retro-muri fe.muri >/dev/null; retro -r ngaImage; rm -f ngaImage +echo "st"; retro-muri st.muri >/dev/null; retro -r ngaImage; rm -f ngaImage +echo "ad"; retro-muri ad.muri >/dev/null; retro -r ngaImage; rm -f ngaImage +echo "su"; retro-muri su.muri >/dev/null; retro -r ngaImage; rm -f ngaImage +echo "mu"; retro-muri mu.muri >/dev/null; retro -r ngaImage; rm -f ngaImage +echo "di"; retro-muri di.muri >/dev/null; retro -r ngaImage; rm -f ngaImage +echo "an"; retro-muri an.muri >/dev/null; retro -r ngaImage; rm -f ngaImage +echo "or"; retro-muri or.muri >/dev/null; retro -r ngaImage; rm -f ngaImage +echo "xo"; retro-muri xo.muri >/dev/null; retro -r ngaImage; rm -f ngaImage +echo "sh"; retro-muri sh.muri >/dev/null; retro -r ngaImage; rm -f ngaImage +echo "zr"; retro-muri zr.muri >/dev/null; retro -r ngaImage; rm -f ngaImage +echo "ha"; retro-muri ha.muri >/dev/null; retro -r ngaImage; rm -f ngaImage diff --git a/tests/ju.muri b/tests/ju.muri new file mode 100644 index 0000000..8603e4f --- /dev/null +++ b/tests/ju.muri @@ -0,0 +1,10 @@ +~~~ +i liju.... +r subr +i liha.... +d 89 + +: subr +i liha.... +d 10 +~~~ diff --git a/tests/li.muri b/tests/li.muri new file mode 100644 index 0000000..a2d843f --- /dev/null +++ b/tests/li.muri @@ -0,0 +1,8 @@ +~~~ +i lililili +d 1 +d -1 +d 99 +d -99 +i ha...... +~~~ diff --git a/tests/lt.muri b/tests/lt.muri new file mode 100644 index 0000000..be4651f --- /dev/null +++ b/tests/lt.muri @@ -0,0 +1,12 @@ +~~~ +i lililt.. +d 100 +d 200 +i lililt.. +d 100 +d 100 +i lililt.. +d 200 +d 100 +i ha...... +~~~ diff --git a/tests/mu.muri b/tests/mu.muri new file mode 100644 index 0000000..0dbb2eb --- /dev/null +++ b/tests/mu.muri @@ -0,0 +1,9 @@ +~~~ +i lilimu.. +d 100 +d 200 +i lilimu.. +d 100 +d -99 +i ha...... +~~~ diff --git a/tests/ne.muri b/tests/ne.muri new file mode 100644 index 0000000..bba70fb --- /dev/null +++ b/tests/ne.muri @@ -0,0 +1,9 @@ +~~~ +i liline.. +d 100 +d 200 +i liline.. +d 100 +d 100 +i ha...... +~~~ diff --git a/tests/no.muri b/tests/no.muri new file mode 100644 index 0000000..9f599cc --- /dev/null +++ b/tests/no.muri @@ -0,0 +1,4 @@ +~~~ +i ........ +i ha...... +~~~ diff --git a/tests/or.muri b/tests/or.muri new file mode 100644 index 0000000..8df5554 --- /dev/null +++ b/tests/or.muri @@ -0,0 +1,12 @@ +~~~ +i lilior.. +d -1 +d -1 +i lilior.. +d 0 +d -1 +i lilior.. +d 0 +d 0 +i ha...... +~~~ diff --git a/tests/po.muri b/tests/po.muri new file mode 100644 index 0000000..71c25c9 --- /dev/null +++ b/tests/po.muri @@ -0,0 +1,8 @@ +~~~ +i lilipuli +d 100 +d 200 +d 300 +i po...... +i ha...... +~~~ diff --git a/tests/pu.muri b/tests/pu.muri new file mode 100644 index 0000000..71c25c9 --- /dev/null +++ b/tests/pu.muri @@ -0,0 +1,8 @@ +~~~ +i lilipuli +d 100 +d 200 +d 300 +i po...... +i ha...... +~~~ diff --git a/tests/re.muri b/tests/re.muri new file mode 100644 index 0000000..925c353 --- /dev/null +++ b/tests/re.muri @@ -0,0 +1,9 @@ +~~~ +i lica.... +r subr +i ha...... + +: subr +i lire.... +d 10 +~~~ diff --git a/tests/sh.muri b/tests/sh.muri new file mode 100644 index 0000000..ead8829 --- /dev/null +++ b/tests/sh.muri @@ -0,0 +1,9 @@ +~~~ +i lilish.. +d 455 +d -3 +i lilish.. +d 3640 +d 3 +i ha...... +~~~ diff --git a/tests/st.muri b/tests/st.muri new file mode 100644 index 0000000..e2b2d91 --- /dev/null +++ b/tests/st.muri @@ -0,0 +1,20 @@ +~~~ +i liju.... +r main + +: abc +s abc + +: main +i lifelili +r abc +r abc +d 1 +i adfelili +d 48 +r abc +i stlife.. +r abc +i ha...... +~~~ + diff --git a/tests/su.muri b/tests/su.muri new file mode 100644 index 0000000..664d32d --- /dev/null +++ b/tests/su.muri @@ -0,0 +1,10 @@ +~~~ +: main +i lilisuli +d 100 +d 200 +d 100 +i lisuha.. +d -99 +~~~ + diff --git a/tests/sw.muri b/tests/sw.muri new file mode 100644 index 0000000..0664066 --- /dev/null +++ b/tests/sw.muri @@ -0,0 +1,9 @@ +~~~ +: main +i liliswli +d 100 +d 200 +d 300 +i swha.... +~~~ + diff --git a/tests/xo.muri b/tests/xo.muri new file mode 100644 index 0000000..ba457bd --- /dev/null +++ b/tests/xo.muri @@ -0,0 +1,14 @@ +~~~ +: main +i lilixo.. +d -1 +d -1 +i lilixo.. +d 0 +d -1 +i lilixo.. +d 0 +d 0 +i ha...... +~~~ + diff --git a/tests/zr.muri b/tests/zr.muri new file mode 100644 index 0000000..1a2d919 --- /dev/null +++ b/tests/zr.muri @@ -0,0 +1,18 @@ +~~~ +i liju.... +r main + +: c1 +i zr...... +i drlire.. +d 2 + +: main +i lilica.. +d 100 +r c1 +i lilica.. +d 0 +r c1 +i ha...... +~~~ diff --git a/vm/nga-c/image.c b/vm/nga-c/image.c index 6538bb7..2e0a1e1 100644 --- a/vm/nga-c/image.c +++ b/vm/nga-c/image.c @@ -10,8 +10,8 @@ #define CELL_MAX LLONG_MAX - 1 #endif #endif -CELL ngaImageCells = 15347; -CELL ngaImage[] = { 1793,14730,15322,15346,202107,372,344,1023,1535,0,10,1,10,2,10,3,10,4,10, +CELL ngaImageCells = 14949; +CELL ngaImage[] = { 1793,14730,14924,14948,202107,372,344,1023,1535,0,10,1,10,2,10,3,10,4,10, 5,10,6,10,7,10,8,10,11,10,12,10,13,10,14,10,15,10,16,10, 17,10,18,10,19,10,20,10,21,10,22,10,23,10,24,10,25,68223234,1,2575, 85000450,1,656912,140,157,268505089,63,62,285281281,0,63,2063,10,101384453,0,9,10,2049,56,25, @@ -170,7 +170,7 @@ CELL ngaImage[] = { 1793,14730,15322,15346,202107,372,344,1023,1535,0,10,1,10,2, 3113,2049,2095,4100,10,3096,3136,145,118,58,117,112,100,97,116,101,0,4,1793,3143, 15,4,8,10,1,3139,2049,2105,16,10,3124,3157,145,99,111,112,121,0,1793,3166, 285278725,1,33951492,268767489,1,6,10,1,3159,2049,2270,771,10,3149,3185,145,83,99,111,112, - 101,76,105,115,116,0,15172,15224,10,3172,3194,145,123,123,0,2049,1570,2,1,3185, + 101,76,105,115,116,0,14774,14826,10,3172,3194,145,123,123,0,2049,1570,2,1,3185, 2049,59,16,10,3188,3219,145,45,45,45,114,101,118,101,97,108,45,45,45,0, 2049,1570,1,3185,2049,2921,16,10,3203,3233,145,125,125,0,1,3185,2049,56,4,15, 11,1793,3247,3841,3185,4097,2,10,1,3242,1793,3273,3841,3185,1793,3268,1,2,983567,1, @@ -189,7 +189,7 @@ CELL ngaImage[] = { 1793,14730,15322,15346,202107,372,344,1023,1535,0,10,1,10,2, 2095,4097,3296,10,3464,3518,133,84,101,109,112,83,116,114,105,110,103,115,0,32, 3503,3536,133,84,101,109,112,83,116,114,105,110,103,77,97,120,0,512,3519,3548, 145,83,84,82,73,78,71,83,0,2049,1543,3841,3518,3841,3536,19,18,10,3537,3568, - 133,67,117,114,114,101,110,116,0,20,10,3557,3583,145,115,58,112,111,105,110, + 133,67,117,114,114,101,110,116,0,0,10,3557,3583,145,115,58,112,111,105,110, 116,101,114,0,3841,3568,3841,3536,19,2049,3548,17,10,3570,3602,145,115,58,110,101, 120,116,0,1,3568,2049,3019,3841,3568,3841,3518,11,1793,3618,1,0,4097,3568,10,1, 3613,9,10,3537,3632,145,115,58,116,101,109,112,0,2,2049,81,2049,2921,2049,3583, @@ -758,24 +758,4 @@ CELL ngaImage[] = { 1793,14730,15322,15346,202107,372,344,1023,1535,0,10,1,10,2, 98,101,103,105,110,110,105,110,103,45,119,105,116,104,0,2049,1871,2049,4678,1793, 14905,2049,163,2049,14845,10,1,14900,2049,7528,10,14868,14921,145,115,58,115,112,108,105, 116,0,2049,6143,10,14910,14945,145,115,58,115,112,108,105,116,45,111,110,45,115, - 116,114,105,110,103,0,2049,6175,10,14924,14959,145,100,58,119,111,114,100,115,0, - 1793,14968,2049,163,2049,9379,2049,9353,10,1,14961,2049,7528,10,14948,14989,145,100,58,119, - 111,114,100,115,45,119,105,116,104,0,2049,1871,2049,4678,1793,15020,2049,163,2,2049, - 1871,2049,4192,1793,15009,2049,9379,2049,9353,10,1,15004,1793,15015,3,10,1,15013,2049,64, - 10,1,14995,2049,7528,10,14973,15044,145,100,105,115,112,108,97,121,45,105,102,45, - 108,101,102,116,0,2,2049,1871,2049,4628,1793,15056,2049,9379,2049,9353,10,1,15051,1793, - 15062,3,10,1,15060,2049,64,10,14973,15093,145,100,58,119,111,114,100,115,45,98, - 101,103,105,110,110,105,110,103,45,119,105,116,104,0,2049,1871,2049,4678,1793,15104, - 2049,163,2049,15044,10,1,15099,2049,7528,10,15067,15120,145,115,58,115,112,108,105,116, - 0,2049,6143,10,15109,15144,145,115,58,115,112,108,105,116,45,111,110,45,115,116, - 114,105,110,103,0,2049,6175,10,15123,15158,145,100,58,119,111,114,100,115,0,1793, - 15167,2049,163,2049,9379,2049,9353,10,1,15160,2049,7528,10,15147,15188,145,100,58,119,111, - 114,100,115,45,119,105,116,104,0,2049,1871,2049,4678,1793,15219,2049,163,2,2049,1871, - 2049,4192,1793,15208,2049,9379,2049,9353,10,1,15203,1793,15214,3,10,1,15212,2049,64,10, - 1,15194,2049,7528,10,15172,15243,145,100,105,115,112,108,97,121,45,105,102,45,108, - 101,102,116,0,2,2049,1871,2049,4628,1793,15255,2049,9379,2049,9353,10,1,15250,1793,15261, - 3,10,1,15259,2049,64,10,15172,15292,145,100,58,119,111,114,100,115,45,98,101, - 103,105,110,110,105,110,103,45,119,105,116,104,0,2049,1871,2049,4678,1793,15303,2049, - 163,2049,15243,10,1,15298,2049,7528,10,15266,15319,145,115,58,115,112,108,105,116,0, - 2049,6143,10,15308,15343,145,115,58,115,112,108,105,116,45,111,110,45,115,116,114, - 105,110,103,0,2049,6175,10,0 }; + 116,114,105,110,103,0,2049,6175,10,0 };