From 5030d67c85f63fc09ee506a90394c50f2db4f3be Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Wed, 17 Jul 2019 23:04:45 -0700 Subject: 5415 Bugfix thirteen: displacement calculations were wrong because current offset was not being updated properly as words were being read and emitted. Now 10/12 example programs are translated correctly. --- subx/Readme.md | 12 ++++++------ subx/apps/survey | Bin 41174 -> 41174 bytes subx/apps/survey.subx | 4 ++-- subx/test_apps | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 56 insertions(+), 8 deletions(-) (limited to 'subx') diff --git a/subx/Readme.md b/subx/Readme.md index 171e04b5..f505d9ce 100644 --- a/subx/Readme.md +++ b/subx/Readme.md @@ -340,16 +340,16 @@ runnable on a Linux system running on Intel x86 processors, either 32- or * Bootstrapping a SubX-\>ELF translator in SubX ✓ examples/ex1 ✓ examples/ex2 - - examples/ex3 + ✓ examples/ex3 ✓ examples/ex4 - - examples/ex5 + ✓ examples/ex5 - examples/ex6 ✓ examples/ex7 - - examples/ex8 - - examples/ex9 - - examples/ex10 + ✓ examples/ex8 + ✓ examples/ex9 + ✓ examples/ex10 - examples/ex11 - - examples/ex12 + ✓ examples/ex12 - apps/factorial.subx - apps/crenshaw2-1.subx - apps/crenshaw2-1b.subx diff --git a/subx/apps/survey b/subx/apps/survey index 6971e511..61e2f974 100755 Binary files a/subx/apps/survey and b/subx/apps/survey differ diff --git a/subx/apps/survey.subx b/subx/apps/survey.subx index bc96fe14..d868132a 100644 --- a/subx/apps/survey.subx +++ b/subx/apps/survey.subx @@ -1884,8 +1884,8 @@ $emit-segments:check0: e8/call num-bytes/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP - # . EBX = EAX - 89/copy 3/mod/direct 3/rm32/EBX . . . 0/r32/EAX . . # copy EAX to EBX + # . EBX += EAX + 01/add 3/mod/direct 3/rm32/EBX . . . 0/r32/EAX . . # add EAX to EBX $emit-segments:word-loop: # next-word(line, word-slice) # . . push args diff --git a/subx/test_apps b/subx/test_apps index ff75ce89..cc0f301f 100755 --- a/subx/test_apps +++ b/subx/test_apps @@ -240,16 +240,64 @@ test `uname` = 'Linux' && { cat examples/ex2.subx |apps/dquotes |apps/assort |apps/pack |apps/survey |apps/hex |diff examples/ex2 - } +echo ex3 +cat examples/ex3.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/ex3 - +test `uname` = 'Linux' && { + cat examples/ex3.subx |apps/dquotes |apps/assort |apps/pack |apps/survey |apps/hex |diff examples/ex3 - +} + 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 ex5 +cat examples/ex5.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/ex5 - +test `uname` = 'Linux' && { + cat examples/ex5.subx |apps/dquotes |apps/assort |apps/pack |apps/survey |apps/hex |diff examples/ex5 - +} + +#? echo ex6 +#? cat examples/ex6.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/ex6 - +#? test `uname` = 'Linux' && { +#? cat examples/ex6.subx |apps/dquotes |apps/assort |apps/pack |apps/survey |apps/hex |diff examples/ex6 - +#? } + 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 - } +echo ex8 +cat examples/ex8.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/ex8 - +test `uname` = 'Linux' && { + cat examples/ex8.subx |apps/dquotes |apps/assort |apps/pack |apps/survey |apps/hex |diff examples/ex8 - +} + +echo ex9 +cat examples/ex9.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/ex9 - +test `uname` = 'Linux' && { + cat examples/ex9.subx |apps/dquotes |apps/assort |apps/pack |apps/survey |apps/hex |diff examples/ex9 - +} + +echo ex10 +cat examples/ex10.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/ex10 - +test `uname` = 'Linux' && { + cat examples/ex10.subx |apps/dquotes |apps/assort |apps/pack |apps/survey |apps/hex |diff examples/ex10 - +} + +#? echo ex11 +#? cat examples/ex11.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/ex11 - +#? test `uname` = 'Linux' && { +#? cat examples/ex11.subx |apps/dquotes |apps/assort |apps/pack |apps/survey |apps/hex |diff examples/ex11 - +#? } + +echo ex12 +cat examples/ex12.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/ex12 - +test `uname` = 'Linux' && { + cat examples/ex12.subx |apps/dquotes |apps/assort |apps/pack |apps/survey |apps/hex |diff examples/ex12 - +} + exit 0 -- cgit 1.4.1-2-gfad0 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246