| 64 | 64 |
deleted file mode 100644 |
| ... | ... |
@@ -1,389 +0,0 @@ |
| 1 |
-local generate_labels = false |
|
| 2 |
-local replacements = {
|
|
| 3 |
- op_and16 = '{ Uint8 a = pop8(u->src), b = pop8(u->src), c = pop8(u->src), d = pop8(u->src); push8(u->src, d & b); push8(u->src, c & a); }',
|
|
| 4 |
- op_ora16 = '{ Uint8 a = pop8(u->src), b = pop8(u->src), c = pop8(u->src), d = pop8(u->src); push8(u->src, d | b); push8(u->src, c | a); }',
|
|
| 5 |
- op_eor16 = '{ Uint8 a = pop8(u->src), b = pop8(u->src), c = pop8(u->src), d = pop8(u->src); push8(u->src, d ^ b); push8(u->src, c ^ a); }',
|
|
| 6 |
- op_lit16 = '{ push8(u->src, peek8(u->ram.dat, u->ram.ptr++)); push8(u->src, peek8(u->ram.dat, u->ram.ptr++)); }',
|
|
| 7 |
- op_swp16 = '{ Uint8 a = pop8(u->src), b = pop8(u->src), c = pop8(u->src), d = pop8(u->src); push8(u->src, b); push8(u->src, a); push8(u->src, d); push8(u->src, c); }',
|
|
| 8 |
- op_ovr16 = '{ Uint8 a = pop8(u->src), b = pop8(u->src), c = pop8(u->src), d = pop8(u->src); push8(u->src, d); push8(u->src, c); push8(u->src, b); push8(u->src, a); push8(u->src, d); push8(u->src, c); }',
|
|
| 9 |
- op_dup16 = '{ Uint8 a = pop8(u->src), b = pop8(u->src); push8(u->src, b); push8(u->src, a); push8(u->src, b); push8(u->src, a); }',
|
|
| 10 |
- op_rot16 = '{ Uint8 a = pop8(u->src), b = pop8(u->src), c = pop8(u->src), d = pop8(u->src), e = pop8(u->src), f = pop8(u->src); push8(u->src, d); push8(u->src, c); push8(u->src, b); push8(u->src, a); push8(u->src, f); push8(u->src, e); }',
|
|
| 11 |
- op_sth16 = '{ Uint8 a = pop8(u->src), b = pop8(u->src); push8(u->dst, b); push8(u->dst, a); }'
|
|
| 12 |
-} |
|
| 13 |
-local top, bottom, pushtop |
|
| 14 |
-local offset |
|
| 15 |
-offset = function(n, s) |
|
| 16 |
- if s == nil then |
|
| 17 |
- s = '' |
|
| 18 |
- end |
|
| 19 |
- if n < 0 then |
|
| 20 |
- return (' -%s %d'):format(s, -n)
|
|
| 21 |
- elseif n > 0 then |
|
| 22 |
- return (' +%s %d'):format(s, n)
|
|
| 23 |
- elseif s ~= '' then |
|
| 24 |
- return (' +%s 0'):format(s)
|
|
| 25 |
- else |
|
| 26 |
- return '' |
|
| 27 |
- end |
|
| 28 |
-end |
|
| 29 |
-local pop_push |
|
| 30 |
-pop_push = function(k, n, s) |
|
| 31 |
- local _exp_0 = k |
|
| 32 |
- if 'pop' == _exp_0 then |
|
| 33 |
- s = s:match('^%((%S+)%)$')
|
|
| 34 |
- assert(s == 'src') |
|
| 35 |
- local _exp_1 = n |
|
| 36 |
- if '8' == _exp_1 then |
|
| 37 |
- top[s] = top[s] - 1 |
|
| 38 |
- if bottom[s] > top[s] then |
|
| 39 |
- bottom[s] = top[s] |
|
| 40 |
- end |
|
| 41 |
- return ('%s.dat[%s.ptr%s]'):format(s, s, offset(top[s]))
|
|
| 42 |
- elseif '16' == _exp_1 then |
|
| 43 |
- top[s] = top[s] - 2 |
|
| 44 |
- if bottom[s] > top[s] then |
|
| 45 |
- bottom[s] = top[s] |
|
| 46 |
- end |
|
| 47 |
- return ('(%s.dat[%s.ptr%s] | (%s.dat[%s.ptr%s] << 8))'):format(s, s, offset(top[s] + 1), s, s, offset(top[s]))
|
|
| 48 |
- end |
|
| 49 |
- elseif 'push' == _exp_0 then |
|
| 50 |
- local v |
|
| 51 |
- s, v = s:match('^%((%S+), (.*)%)$')
|
|
| 52 |
- assert(s == 'src' or s == 'dst', s) |
|
| 53 |
- local _exp_1 = n |
|
| 54 |
- if '8' == _exp_1 then |
|
| 55 |
- pushtop[s] = pushtop[s] + 1 |
|
| 56 |
- return ('%s.dat[%s.ptr%s] = %s'):format(s, s, offset(pushtop[s] - 1), v)
|
|
| 57 |
- elseif '16' == _exp_1 then |
|
| 58 |
- if v:match('%+%+') or v:match('%-%-') then
|
|
| 59 |
- error('push16 has side effects: ' .. v)
|
|
| 60 |
- end |
|
| 61 |
- local peek, args = v:match('^([md]e[mv]peek)16(%b())$')
|
|
| 62 |
- if peek then |
|
| 63 |
- args = args:sub(2, -2) |
|
| 64 |
- return pop_push('push', '8', ('(%s, %s8(%s))'):format(s, peek, args)) .. ';\n' .. pop_push('push', '8', ('(%s, %s8(%s + 1))'):format(s, peek, args))
|
|
| 65 |
- end |
|
| 66 |
- pushtop[s] = pushtop[s] + 2 |
|
| 67 |
- if v:match(' ') then
|
|
| 68 |
- v = '(' .. v .. ')'
|
|
| 69 |
- end |
|
| 70 |
- return ('%s.dat[%s.ptr%s] = %s >> 8;\n%s.dat[%s.ptr%s] = %s & 0xff'):format(s, s, offset(pushtop[s] - 2), v, s, s, offset(pushtop[s] - 1), v)
|
|
| 71 |
- end |
|
| 72 |
- else |
|
| 73 |
- return nil |
|
| 74 |
- end |
|
| 75 |
-end |
|
| 76 |
-local indented_block |
|
| 77 |
-indented_block = function(s) |
|
| 78 |
- s = s:gsub('^%{ *', '{\n'):gsub('\n', '\n\t'):gsub('\t%} *$', '}\n')
|
|
| 79 |
- s = s:gsub('\n[^\n]+%.error = [^\n]+', '%0\n#ifndef NO_STACK_CHECKS\n\tgoto error;\n#endif')
|
|
| 80 |
- return s |
|
| 81 |
-end |
|
| 82 |
-local process |
|
| 83 |
-process = function(body) |
|
| 84 |
- local out_body = body:gsub('^%{ *', ''):gsub(' *%}$', ''):gsub('; ', ';\n'):gsub('%b{} *', indented_block):gsub('(%a+)(%d+)(%b())', pop_push)
|
|
| 85 |
- local in_ifdef = false |
|
| 86 |
- local _list_0 = {
|
|
| 87 |
- 'src', |
|
| 88 |
- 'dst' |
|
| 89 |
- } |
|
| 90 |
- for _index_0 = 1, #_list_0 do |
|
| 91 |
- local k = _list_0[_index_0] |
|
| 92 |
- if bottom[k] ~= 0 then |
|
| 93 |
- if not in_ifdef then |
|
| 94 |
- out_body = out_body .. '\n#ifndef NO_STACK_CHECKS' |
|
| 95 |
- in_ifdef = true |
|
| 96 |
- end |
|
| 97 |
- out_body = out_body .. ('\nif(__builtin_expect(%s.ptr < %d, 0)) {\n\t%s.error = 1;\n\tgoto error;\n}'):format(k, -bottom[k], k)
|
|
| 98 |
- end |
|
| 99 |
- if pushtop[k] ~= 0 then |
|
| 100 |
- if pushtop[k] > 0 then |
|
| 101 |
- if not in_ifdef then |
|
| 102 |
- out_body = out_body .. '\n#ifndef NO_STACK_CHECKS' |
|
| 103 |
- in_ifdef = true |
|
| 104 |
- end |
|
| 105 |
- out_body = out_body .. ('\nif(__builtin_expect(%s.ptr > %d, 0)) {\n\t%s.error = 2;\n\tgoto error;\n}'):format(k, 255 - pushtop[k], k)
|
|
| 106 |
- end |
|
| 107 |
- if in_ifdef then |
|
| 108 |
- out_body = out_body .. '\n#endif' |
|
| 109 |
- in_ifdef = false |
|
| 110 |
- end |
|
| 111 |
- out_body = out_body .. ('\n%s.ptr %s= %d;'):format(k, pushtop[k] < 0 and '-' or '+', math.abs(pushtop[k]))
|
|
| 112 |
- end |
|
| 113 |
- end |
|
| 114 |
- if in_ifdef then |
|
| 115 |
- out_body = out_body .. '\n#endif' |
|
| 116 |
- in_ifdef = false |
|
| 117 |
- end |
|
| 118 |
- local t = { }
|
|
| 119 |
- out_body:gsub('[^%w_]([a-f]) = (src%.dat%[[^]]+%])[,;]', function(v, k)
|
|
| 120 |
- t[k] = v |
|
| 121 |
- end) |
|
| 122 |
- out_body = out_body:gsub('(src%.dat%[[^]]+%]) = ([a-f]);\n', function(k, v)
|
|
| 123 |
- if t[k] and t[k] == v then |
|
| 124 |
- return '' |
|
| 125 |
- end |
|
| 126 |
- return nil |
|
| 127 |
- end) |
|
| 128 |
- return out_body |
|
| 129 |
-end |
|
| 130 |
-local ops = { }
|
|
| 131 |
-for l in assert(io.lines('src/uxn.c')) do
|
|
| 132 |
- local _continue_0 = false |
|
| 133 |
- repeat |
|
| 134 |
- local name, body = l:match('void (op_%S*)%(Uxn %*u%) (%b{})')
|
|
| 135 |
- if not name then |
|
| 136 |
- _continue_0 = true |
|
| 137 |
- break |
|
| 138 |
- end |
|
| 139 |
- if replacements[name] then |
|
| 140 |
- body = replacements[name] |
|
| 141 |
- end |
|
| 142 |
- body = body:gsub('u%-%>src%-%>', 'src.')
|
|
| 143 |
- body = body:gsub('u%-%>dst%-%>', 'dst.')
|
|
| 144 |
- body = body:gsub('u%-%>src', 'src')
|
|
| 145 |
- body = body:gsub('u%-%>dst', 'dst')
|
|
| 146 |
- top = {
|
|
| 147 |
- src = 0, |
|
| 148 |
- dst = 0 |
|
| 149 |
- } |
|
| 150 |
- bottom = {
|
|
| 151 |
- src = 0, |
|
| 152 |
- dst = 0 |
|
| 153 |
- } |
|
| 154 |
- pushtop = top |
|
| 155 |
- ops[name] = process(body) |
|
| 156 |
- top = {
|
|
| 157 |
- src = 0, |
|
| 158 |
- dst = 0 |
|
| 159 |
- } |
|
| 160 |
- bottom = {
|
|
| 161 |
- src = 0, |
|
| 162 |
- dst = 0 |
|
| 163 |
- } |
|
| 164 |
- pushtop = {
|
|
| 165 |
- src = 0, |
|
| 166 |
- dst = 0 |
|
| 167 |
- } |
|
| 168 |
- ops['keep_' .. name] = process(body) |
|
| 169 |
- _continue_0 = true |
|
| 170 |
- until true |
|
| 171 |
- if not _continue_0 then |
|
| 172 |
- break |
|
| 173 |
- end |
|
| 174 |
-end |
|
| 175 |
-local dump |
|
| 176 |
-dump = function(s, src, dst) |
|
| 177 |
- local ret = '\t\t\t{\n'
|
|
| 178 |
- for l in s:gmatch('[^\n]+') do
|
|
| 179 |
- if not l:match('^%#') then
|
|
| 180 |
- ret = ret .. '\t\t\t\t' |
|
| 181 |
- end |
|
| 182 |
- ret = ret .. ('%s\n'):format(l)
|
|
| 183 |
- end |
|
| 184 |
- ret = ret .. '\t\t\t}\n\t\t\tbreak;\n' |
|
| 185 |
- return (ret:gsub('src', src):gsub('dst', dst))
|
|
| 186 |
-end |
|
| 187 |
-local i = 0 |
|
| 188 |
-local allops = { }
|
|
| 189 |
-local wanted = false |
|
| 190 |
-for l in assert(io.lines('src/uxn.c')) do
|
|
| 191 |
- if l == 'static void (*ops[])(Uxn *u) = {' then
|
|
| 192 |
- wanted = true |
|
| 193 |
- elseif l == '};' then |
|
| 194 |
- wanted = false |
|
| 195 |
- elseif wanted then |
|
| 196 |
- l = l:gsub('%/%b**%/', '')
|
|
| 197 |
- for op in l:gmatch('[%w_]+') do
|
|
| 198 |
- if not ops[op] then |
|
| 199 |
- error('missing ' .. op)
|
|
| 200 |
- end |
|
| 201 |
- allops[i + 0x00 + 1] = {
|
|
| 202 |
- n = {
|
|
| 203 |
- i + 0x00 |
|
| 204 |
- }, |
|
| 205 |
- body = dump(ops[op], 'u->wst', 'u->rst') |
|
| 206 |
- } |
|
| 207 |
- allops[i + 0x20 + 1] = {
|
|
| 208 |
- n = {
|
|
| 209 |
- i + 0x20 |
|
| 210 |
- }, |
|
| 211 |
- body = dump(ops[op], 'u->rst', 'u->wst') |
|
| 212 |
- } |
|
| 213 |
- allops[i + 0x80 + 1] = {
|
|
| 214 |
- n = {
|
|
| 215 |
- i + 0x80 |
|
| 216 |
- }, |
|
| 217 |
- body = dump(ops['keep_' .. op], 'u->wst', 'u->rst') |
|
| 218 |
- } |
|
| 219 |
- allops[i + 0xa0 + 1] = {
|
|
| 220 |
- n = {
|
|
| 221 |
- i + 0xa0 |
|
| 222 |
- }, |
|
| 223 |
- body = dump(ops['keep_' .. op], 'u->rst', 'u->wst') |
|
| 224 |
- } |
|
| 225 |
- i = i + 1 |
|
| 226 |
- if i == 0x20 then |
|
| 227 |
- i = i + 0x20 |
|
| 228 |
- end |
|
| 229 |
- end |
|
| 230 |
- end |
|
| 231 |
-end |
|
| 232 |
-i = 0 |
|
| 233 |
-wanted = false |
|
| 234 |
-for l in assert(io.lines('src/uxnasm.c')) do
|
|
| 235 |
- if l == 'static char ops[][4] = {' then
|
|
| 236 |
- wanted = true |
|
| 237 |
- elseif l == '};' then |
|
| 238 |
- wanted = false |
|
| 239 |
- elseif wanted then |
|
| 240 |
- for op in l:gmatch('"(...)"') do
|
|
| 241 |
- i = i + 1 |
|
| 242 |
- allops[i + 0x00].name = op |
|
| 243 |
- allops[i + 0x20].name = op .. 'r' |
|
| 244 |
- allops[i + 0x40].name = op .. '2' |
|
| 245 |
- allops[i + 0x60].name = op .. '2r' |
|
| 246 |
- allops[i + 0x80].name = op .. 'k' |
|
| 247 |
- allops[i + 0xa0].name = op .. 'kr' |
|
| 248 |
- allops[i + 0xc0].name = op .. '2k' |
|
| 249 |
- allops[i + 0xe0].name = op .. '2kr' |
|
| 250 |
- end |
|
| 251 |
- end |
|
| 252 |
-end |
|
| 253 |
-for i = 1, 256 do |
|
| 254 |
- local _continue_0 = false |
|
| 255 |
- repeat |
|
| 256 |
- if not allops[i] then |
|
| 257 |
- _continue_0 = true |
|
| 258 |
- break |
|
| 259 |
- end |
|
| 260 |
- for j = i + 1, 256 do |
|
| 261 |
- if allops[i].body == allops[j].body then |
|
| 262 |
- table.insert(allops[i].n, (table.remove(allops[j].n))) |
|
| 263 |
- allops[j].body = nil |
|
| 264 |
- end |
|
| 265 |
- end |
|
| 266 |
- _continue_0 = true |
|
| 267 |
- until true |
|
| 268 |
- if not _continue_0 then |
|
| 269 |
- break |
|
| 270 |
- end |
|
| 271 |
-end |
|
| 272 |
-do |
|
| 273 |
- local _with_0 = assert(io.open('src/uxn-fast.c', 'w'))
|
|
| 274 |
- local f = assert(io.open('src/uxn.c'))
|
|
| 275 |
- while true do |
|
| 276 |
- local l = f:read('*l')
|
|
| 277 |
- _with_0:write(('%s\n'):format(l))
|
|
| 278 |
- if l == '*/' then |
|
| 279 |
- break |
|
| 280 |
- end |
|
| 281 |
- end |
|
| 282 |
- _with_0:write('\n')
|
|
| 283 |
- _with_0:write([[/* |
|
| 284 |
- ^ |
|
| 285 |
-/!\ THIS FILE IS AUTOMATICALLY GENERATED |
|
| 286 |
- |
|
| 287 |
-Its contents can get overwritten with the processed contents of src/uxn.c. |
|
| 288 |
-See etc/mkuxn-fast.moon for instructions. |
|
| 289 |
- |
|
| 290 |
-*/ |
|
| 291 |
-]]) |
|
| 292 |
- wanted = true |
|
| 293 |
- while true do |
|
| 294 |
- local _continue_0 = false |
|
| 295 |
- repeat |
|
| 296 |
- local l = f:read('*l')
|
|
| 297 |
- if l:match(' push') or l:match('[ *]pop') or l:match('devr16') then
|
|
| 298 |
- _continue_0 = true |
|
| 299 |
- break |
|
| 300 |
- end |
|
| 301 |
- if l == '/* Stack */' then |
|
| 302 |
- wanted = false |
|
| 303 |
- end |
|
| 304 |
- if wanted then |
|
| 305 |
- _with_0:write(('%s\n'):format(l))
|
|
| 306 |
- end |
|
| 307 |
- if l == '}' then |
|
| 308 |
- _with_0:write('\n')
|
|
| 309 |
- break |
|
| 310 |
- end |
|
| 311 |
- _continue_0 = true |
|
| 312 |
- until true |
|
| 313 |
- if not _continue_0 then |
|
| 314 |
- break |
|
| 315 |
- end |
|
| 316 |
- end |
|
| 317 |
- _with_0:write([[/* clang-format on */ |
|
| 318 |
- |
|
| 319 |
-#pragma mark - Core |
|
| 320 |
- |
|
| 321 |
-int |
|
| 322 |
-uxn_eval(Uxn *u, Uint16 vec) |
|
| 323 |
-{
|
|
| 324 |
- Uint8 instr; |
|
| 325 |
- if(!vec || u->dev[0].dat[0xf]) |
|
| 326 |
- return 0; |
|
| 327 |
- u->ram.ptr = vec; |
|
| 328 |
- if(u->wst.ptr > 0xf8) u->wst.ptr = 0xf8; |
|
| 329 |
- while((instr = u->ram.dat[u->ram.ptr++])) {
|
|
| 330 |
- switch(instr) {
|
|
| 331 |
-#pragma GCC diagnostic push |
|
| 332 |
-#pragma GCC diagnostic ignored "-Wunused-value" |
|
| 333 |
-#pragma GCC diagnostic ignored "-Wunused-variable" |
|
| 334 |
-]]) |
|
| 335 |
- for i = 1, 256 do |
|
| 336 |
- local _continue_0 = false |
|
| 337 |
- repeat |
|
| 338 |
- if not allops[i].body then |
|
| 339 |
- _continue_0 = true |
|
| 340 |
- break |
|
| 341 |
- end |
|
| 342 |
- local _list_0 = allops[i].n |
|
| 343 |
- for _index_0 = 1, #_list_0 do |
|
| 344 |
- local n = _list_0[_index_0] |
|
| 345 |
- _with_0:write(('\t\tcase 0x%02x: /* %s */\n'):format(n, allops[n + 1].name))
|
|
| 346 |
- end |
|
| 347 |
- if generate_labels then |
|
| 348 |
- _with_0:write(('\t\t\t__asm__("evaluxn_%02x_%s:");\n'):format(allops[i].n[1], allops[i].name))
|
|
| 349 |
- end |
|
| 350 |
- _with_0:write(allops[i].body) |
|
| 351 |
- _continue_0 = true |
|
| 352 |
- until true |
|
| 353 |
- if not _continue_0 then |
|
| 354 |
- break |
|
| 355 |
- end |
|
| 356 |
- end |
|
| 357 |
- _with_0:write([[#pragma GCC diagnostic pop |
|
| 358 |
- } |
|
| 359 |
- } |
|
| 360 |
- return 1; |
|
| 361 |
-#ifndef NO_STACK_CHECKS |
|
| 362 |
-error: |
|
| 363 |
- if(u->wst.error) |
|
| 364 |
- return uxn_halt(u, u->wst.error, "Working-stack", instr); |
|
| 365 |
- else |
|
| 366 |
- return uxn_halt(u, u->rst.error, "Return-stack", instr); |
|
| 367 |
-#endif |
|
| 368 |
-} |
|
| 369 |
- |
|
| 370 |
-int |
|
| 371 |
-]]) |
|
| 372 |
- wanted = false |
|
| 373 |
- while true do |
|
| 374 |
- local l = f:read('*l')
|
|
| 375 |
- if not l then |
|
| 376 |
- break |
|
| 377 |
- end |
|
| 378 |
- if l:match('^uxn_boot') then
|
|
| 379 |
- wanted = true |
|
| 380 |
- end |
|
| 381 |
- if wanted then |
|
| 382 |
- _with_0:write(('%s\n'):format(l))
|
|
| 383 |
- end |
|
| 384 |
- end |
|
| 385 |
- f:close() |
|
| 386 |
- _with_0:close() |
|
| 387 |
- return _with_0 |
|
| 388 |
-end |
| 389 | 0 |
deleted file mode 100644 |
| ... | ... |
@@ -1,280 +0,0 @@ |
| 1 |
- |
|
| 2 |
-generate_labels = false -- add labels to each opcode to inspect disassembled code |
|
| 3 |
- |
|
| 4 |
-replacements = |
|
| 5 |
- op_and16: '{ Uint8 a = pop8(u->src), b = pop8(u->src), c = pop8(u->src), d = pop8(u->src); push8(u->src, d & b); push8(u->src, c & a); }'
|
|
| 6 |
- op_ora16: '{ Uint8 a = pop8(u->src), b = pop8(u->src), c = pop8(u->src), d = pop8(u->src); push8(u->src, d | b); push8(u->src, c | a); }'
|
|
| 7 |
- op_eor16: '{ Uint8 a = pop8(u->src), b = pop8(u->src), c = pop8(u->src), d = pop8(u->src); push8(u->src, d ^ b); push8(u->src, c ^ a); }'
|
|
| 8 |
- op_lit16: '{ push8(u->src, peek8(u->ram.dat, u->ram.ptr++)); push8(u->src, peek8(u->ram.dat, u->ram.ptr++)); }'
|
|
| 9 |
- op_swp16: '{ Uint8 a = pop8(u->src), b = pop8(u->src), c = pop8(u->src), d = pop8(u->src); push8(u->src, b); push8(u->src, a); push8(u->src, d); push8(u->src, c); }'
|
|
| 10 |
- op_ovr16: '{ Uint8 a = pop8(u->src), b = pop8(u->src), c = pop8(u->src), d = pop8(u->src); push8(u->src, d); push8(u->src, c); push8(u->src, b); push8(u->src, a); push8(u->src, d); push8(u->src, c); }'
|
|
| 11 |
- op_dup16: '{ Uint8 a = pop8(u->src), b = pop8(u->src); push8(u->src, b); push8(u->src, a); push8(u->src, b); push8(u->src, a); }'
|
|
| 12 |
- op_rot16: '{ Uint8 a = pop8(u->src), b = pop8(u->src), c = pop8(u->src), d = pop8(u->src), e = pop8(u->src), f = pop8(u->src); push8(u->src, d); push8(u->src, c); push8(u->src, b); push8(u->src, a); push8(u->src, f); push8(u->src, e); }'
|
|
| 13 |
- op_sth16: '{ Uint8 a = pop8(u->src), b = pop8(u->src); push8(u->dst, b); push8(u->dst, a); }'
|
|
| 14 |
- |
|
| 15 |
-local top, bottom, pushtop |
|
| 16 |
- |
|
| 17 |
-offset = (n, s = '') -> |
|
| 18 |
- if n < 0 |
|
| 19 |
- ' -%s %d'\format s, -n |
|
| 20 |
- elseif n > 0 |
|
| 21 |
- ' +%s %d'\format s, n |
|
| 22 |
- elseif s != '' |
|
| 23 |
- ' +%s 0'\format s |
|
| 24 |
- else |
|
| 25 |
- '' |
|
| 26 |
- |
|
| 27 |
-pop_push = (k, n, s) -> |
|
| 28 |
- switch k |
|
| 29 |
- when 'pop' |
|
| 30 |
- s = s\match '^%((%S+)%)$' |
|
| 31 |
- assert s == 'src' |
|
| 32 |
- switch n |
|
| 33 |
- when '8' |
|
| 34 |
- top[s] -= 1 |
|
| 35 |
- if bottom[s] > top[s] |
|
| 36 |
- bottom[s] = top[s] |
|
| 37 |
- '%s.dat[%s.ptr%s]'\format s, s, offset(top[s]) |
|
| 38 |
- when '16' |
|
| 39 |
- top[s] -= 2 |
|
| 40 |
- if bottom[s] > top[s] |
|
| 41 |
- bottom[s] = top[s] |
|
| 42 |
- '(%s.dat[%s.ptr%s] | (%s.dat[%s.ptr%s] << 8))'\format s, s, offset(top[s] + 1), s, s, offset(top[s]) |
|
| 43 |
- when 'push' |
|
| 44 |
- s, v = s\match '^%((%S+), (.*)%)$' |
|
| 45 |
- assert s == 'src' or s == 'dst', s |
|
| 46 |
- switch n |
|
| 47 |
- when '8' |
|
| 48 |
- pushtop[s] += 1 |
|
| 49 |
- '%s.dat[%s.ptr%s] = %s'\format s, s, offset(pushtop[s] - 1), v |
|
| 50 |
- when '16' |
|
| 51 |
- if v\match'%+%+' or v\match'%-%-' |
|
| 52 |
- error 'push16 has side effects: ' .. v |
|
| 53 |
- peek, args = v\match '^([md]e[mv]peek)16(%b())$' |
|
| 54 |
- if peek |
|
| 55 |
- args = args\sub 2, -2 |
|
| 56 |
- return pop_push('push', '8', '(%s, %s8(%s))'\format s, peek, args) .. ';\n' .. pop_push('push', '8', '(%s, %s8(%s + 1))'\format s, peek, args)
|
|
| 57 |
- pushtop[s] += 2 |
|
| 58 |
- if v\match ' ' |
|
| 59 |
- v = '(' .. v .. ')'
|
|
| 60 |
- '%s.dat[%s.ptr%s] = %s >> 8;\n%s.dat[%s.ptr%s] = %s & 0xff'\format s, s, offset(pushtop[s] - 2), v, s, s, offset(pushtop[s] - 1), v |
|
| 61 |
- else |
|
| 62 |
- nil |
|
| 63 |
- |
|
| 64 |
-indented_block = (s) -> |
|
| 65 |
- s = s\gsub('^%{ *', '{\n')\gsub('\n', '\n\t')\gsub('\t%} *$', '}\n')
|
|
| 66 |
- s = s\gsub('\n[^\n]+%.error = [^\n]+', '%0\n#ifndef NO_STACK_CHECKS\n\tgoto error;\n#endif')
|
|
| 67 |
- s |
|
| 68 |
- |
|
| 69 |
-process = (body) -> |
|
| 70 |
- out_body = body\gsub('^%{ *', '')\gsub(' *%}$', '')\gsub('; ', ';\n')\gsub('%b{} *', indented_block)\gsub '(%a+)(%d+)(%b())', pop_push
|
|
| 71 |
- in_ifdef = false |
|
| 72 |
- for k in *{'src', 'dst'}
|
|
| 73 |
- if bottom[k] != 0 |
|
| 74 |
- if not in_ifdef |
|
| 75 |
- out_body ..= '\n#ifndef NO_STACK_CHECKS' |
|
| 76 |
- in_ifdef = true |
|
| 77 |
- out_body ..= '\nif(__builtin_expect(%s.ptr < %d, 0)) {\n\t%s.error = 1;\n\tgoto error;\n}'\format k, -bottom[k], k
|
|
| 78 |
- if pushtop[k] != 0 |
|
| 79 |
- if pushtop[k] > 0 |
|
| 80 |
- if not in_ifdef |
|
| 81 |
- out_body ..= '\n#ifndef NO_STACK_CHECKS' |
|
| 82 |
- in_ifdef = true |
|
| 83 |
- out_body ..= '\nif(__builtin_expect(%s.ptr > %d, 0)) {\n\t%s.error = 2;\n\tgoto error;\n}'\format k, 255 - pushtop[k], k
|
|
| 84 |
- if in_ifdef |
|
| 85 |
- out_body ..= '\n#endif' |
|
| 86 |
- in_ifdef = false |
|
| 87 |
- out_body ..= '\n%s.ptr %s= %d;'\format k, pushtop[k] < 0 and '-' or '+', math.abs pushtop[k] |
|
| 88 |
- if in_ifdef |
|
| 89 |
- out_body ..= '\n#endif' |
|
| 90 |
- in_ifdef = false |
|
| 91 |
- t = {}
|
|
| 92 |
- out_body\gsub '[^%w_]([a-f]) = (src%.dat%[[^]]+%])[,;]', (v, k) -> t[k] = v |
|
| 93 |
- out_body = out_body\gsub '(src%.dat%[[^]]+%]) = ([a-f]);\n', (k, v) -> |
|
| 94 |
- if t[k] and t[k] == v |
|
| 95 |
- return '' |
|
| 96 |
- return nil |
|
| 97 |
- out_body |
|
| 98 |
- |
|
| 99 |
-ops = {}
|
|
| 100 |
- |
|
| 101 |
-for l in assert io.lines 'src/uxn.c' |
|
| 102 |
- name, body = l\match 'void (op_%S*)%(Uxn %*u%) (%b{})'
|
|
| 103 |
- if not name |
|
| 104 |
- continue |
|
| 105 |
- if replacements[name] |
|
| 106 |
- body = replacements[name] |
|
| 107 |
- body = body\gsub 'u%-%>src%-%>', 'src.' |
|
| 108 |
- body = body\gsub 'u%-%>dst%-%>', 'dst.' |
|
| 109 |
- body = body\gsub 'u%-%>src', 'src' |
|
| 110 |
- body = body\gsub 'u%-%>dst', 'dst' |
|
| 111 |
- top = { src: 0, dst: 0 }
|
|
| 112 |
- bottom = { src: 0, dst: 0 }
|
|
| 113 |
- pushtop = top |
|
| 114 |
- ops[name] = process body |
|
| 115 |
- top = { src: 0, dst: 0 }
|
|
| 116 |
- bottom = { src: 0, dst: 0 }
|
|
| 117 |
- pushtop = { src: 0, dst: 0 }
|
|
| 118 |
- ops['keep_' .. name] = process body |
|
| 119 |
- |
|
| 120 |
-dump = (s, src, dst) -> |
|
| 121 |
- ret = '\t\t\t{\n'
|
|
| 122 |
- for l in s\gmatch '[^\n]+' |
|
| 123 |
- if not l\match '^%#' |
|
| 124 |
- ret ..= '\t\t\t\t' |
|
| 125 |
- ret ..= '%s\n'\format l |
|
| 126 |
- ret ..= '\t\t\t}\n\t\t\tbreak;\n' |
|
| 127 |
- (ret\gsub('src', src)\gsub('dst', dst))
|
|
| 128 |
- |
|
| 129 |
-i = 0 |
|
| 130 |
-allops = {}
|
|
| 131 |
-wanted = false |
|
| 132 |
-for l in assert io.lines 'src/uxn.c' |
|
| 133 |
- if l == 'static void (*ops[])(Uxn *u) = {'
|
|
| 134 |
- wanted = true |
|
| 135 |
- elseif l == '};' |
|
| 136 |
- wanted = false |
|
| 137 |
- elseif wanted |
|
| 138 |
- l = l\gsub '%/%b**%/', '' |
|
| 139 |
- for op in l\gmatch '[%w_]+' |
|
| 140 |
- if not ops[op] |
|
| 141 |
- error 'missing ' .. op |
|
| 142 |
- allops[i + 0x00 + 1] = { n: { i + 0x00 }, body: dump ops[op], 'u->wst', 'u->rst' }
|
|
| 143 |
- allops[i + 0x20 + 1] = { n: { i + 0x20 }, body: dump ops[op], 'u->rst', 'u->wst' }
|
|
| 144 |
- allops[i + 0x80 + 1] = { n: { i + 0x80 }, body: dump ops['keep_' .. op], 'u->wst', 'u->rst' }
|
|
| 145 |
- allops[i + 0xa0 + 1] = { n: { i + 0xa0 }, body: dump ops['keep_' .. op], 'u->rst', 'u->wst' }
|
|
| 146 |
- i += 1 |
|
| 147 |
- if i == 0x20 |
|
| 148 |
- i += 0x20 |
|
| 149 |
- |
|
| 150 |
-i = 0 |
|
| 151 |
-wanted = false |
|
| 152 |
-for l in assert io.lines 'src/uxnasm.c' |
|
| 153 |
- if l == 'static char ops[][4] = {'
|
|
| 154 |
- wanted = true |
|
| 155 |
- elseif l == '};' |
|
| 156 |
- wanted = false |
|
| 157 |
- elseif wanted |
|
| 158 |
- for op in l\gmatch '"(...)"' |
|
| 159 |
- i += 1 |
|
| 160 |
- allops[i + 0x00].name = op |
|
| 161 |
- allops[i + 0x20].name = op .. 'r' |
|
| 162 |
- allops[i + 0x40].name = op .. '2' |
|
| 163 |
- allops[i + 0x60].name = op .. '2r' |
|
| 164 |
- allops[i + 0x80].name = op .. 'k' |
|
| 165 |
- allops[i + 0xa0].name = op .. 'kr' |
|
| 166 |
- allops[i + 0xc0].name = op .. '2k' |
|
| 167 |
- allops[i + 0xe0].name = op .. '2kr' |
|
| 168 |
- |
|
| 169 |
-for i = 1, 256 |
|
| 170 |
- if not allops[i] |
|
| 171 |
- continue |
|
| 172 |
- for j = i + 1, 256 |
|
| 173 |
- if allops[i].body == allops[j].body |
|
| 174 |
- table.insert allops[i].n, (table.remove allops[j].n) |
|
| 175 |
- allops[j].body = nil |
|
| 176 |
- |
|
| 177 |
-with assert io.open 'src/uxn-fast.c', 'w' |
|
| 178 |
- f = assert io.open 'src/uxn.c' |
|
| 179 |
- while true |
|
| 180 |
- l = f\read '*l' |
|
| 181 |
- \write '%s\n'\format l |
|
| 182 |
- if l == '*/' |
|
| 183 |
- break |
|
| 184 |
- \write '\n' |
|
| 185 |
- \write [[ |
|
| 186 |
-/* |
|
| 187 |
- ^ |
|
| 188 |
-/!\ THIS FILE IS AUTOMATICALLY GENERATED |
|
| 189 |
- |
|
| 190 |
-Its contents can get overwritten with the processed contents of src/uxn.c. |
|
| 191 |
-See etc/mkuxn-fast.moon for instructions. |
|
| 192 |
- |
|
| 193 |
-*/ |
|
| 194 |
-]] |
|
| 195 |
- wanted = true |
|
| 196 |
- while true |
|
| 197 |
- l = f\read '*l' |
|
| 198 |
- if l\match' push' or l\match'[ *]pop' or l\match'devr16' |
|
| 199 |
- continue |
|
| 200 |
- if l == '/* Stack */' |
|
| 201 |
- wanted = false |
|
| 202 |
- if wanted |
|
| 203 |
- \write '%s\n'\format l |
|
| 204 |
- if l == '}' |
|
| 205 |
- \write '\n' |
|
| 206 |
- break |
|
| 207 |
- \write [[ |
|
| 208 |
-/* clang-format on */ |
|
| 209 |
- |
|
| 210 |
-#pragma mark - Core |
|
| 211 |
- |
|
| 212 |
-int |
|
| 213 |
-uxn_eval(Uxn *u, Uint16 vec) |
|
| 214 |
-{
|
|
| 215 |
- Uint8 instr; |
|
| 216 |
- if(!vec || u->dev[0].dat[0xf]) |
|
| 217 |
- return 0; |
|
| 218 |
- u->ram.ptr = vec; |
|
| 219 |
- if(u->wst.ptr > 0xf8) u->wst.ptr = 0xf8; |
|
| 220 |
- while((instr = u->ram.dat[u->ram.ptr++])) {
|
|
| 221 |
- switch(instr) {
|
|
| 222 |
-#pragma GCC diagnostic push |
|
| 223 |
-#pragma GCC diagnostic ignored "-Wunused-value" |
|
| 224 |
-#pragma GCC diagnostic ignored "-Wunused-variable" |
|
| 225 |
-]] |
|
| 226 |
- for i = 1, 256 |
|
| 227 |
- if not allops[i].body |
|
| 228 |
- continue |
|
| 229 |
- for n in *allops[i].n |
|
| 230 |
- \write '\t\tcase 0x%02x: /* %s */\n'\format n, allops[n + 1].name |
|
| 231 |
- if generate_labels |
|
| 232 |
- \write '\t\t\t__asm__("evaluxn_%02x_%s:");\n'\format allops[i].n[1], allops[i].name
|
|
| 233 |
- \write allops[i].body |
|
| 234 |
- \write [[ |
|
| 235 |
-#pragma GCC diagnostic pop |
|
| 236 |
- } |
|
| 237 |
- } |
|
| 238 |
- return 1; |
|
| 239 |
-#ifndef NO_STACK_CHECKS |
|
| 240 |
-error: |
|
| 241 |
- if(u->wst.error) |
|
| 242 |
- return uxn_halt(u, u->wst.error, "Working-stack", instr); |
|
| 243 |
- else |
|
| 244 |
- return uxn_halt(u, u->rst.error, "Return-stack", instr); |
|
| 245 |
-#endif |
|
| 246 |
-} |
|
| 247 |
- |
|
| 248 |
-int |
|
| 249 |
-]] |
|
| 250 |
- wanted = false |
|
| 251 |
- while true |
|
| 252 |
- l = f\read '*l' |
|
| 253 |
- if not l |
|
| 254 |
- break |
|
| 255 |
- if l\match '^uxn_boot' |
|
| 256 |
- wanted = true |
|
| 257 |
- if wanted |
|
| 258 |
- \write '%s\n'\format l |
|
| 259 |
- f\close! |
|
| 260 |
- \close! |
|
| 261 |
- |
| 262 | 0 |
deleted file mode 100644 |
| ... | ... |
@@ -1,4041 +0,0 @@ |
| 1 |
-#include "uxn.h" |
|
| 2 |
- |
|
| 3 |
-/* |
|
| 4 |
-Copyright (u) 2021 Devine Lu Linvega |
|
| 5 |
-Copyright (u) 2021 Andrew Alderwick |
|
| 6 |
- |
|
| 7 |
-Permission to use, copy, modify, and distribute this software for any |
|
| 8 |
-purpose with or without fee is hereby granted, provided that the above |
|
| 9 |
-copyright notice and this permission notice appear in all copies. |
|
| 10 |
- |
|
| 11 |
-THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
|
| 12 |
-WITH REGARD TO THIS SOFTWARE. |
|
| 13 |
-*/ |
|
| 14 |
- |
|
| 15 |
-/* |
|
| 16 |
- ^ |
|
| 17 |
-/!\ THIS FILE IS AUTOMATICALLY GENERATED |
|
| 18 |
- |
|
| 19 |
-Its contents can get overwritten with the processed contents of src/uxn.c. |
|
| 20 |
-See etc/mkuxn-fast.moon for instructions. |
|
| 21 |
- |
|
| 22 |
-*/ |
|
| 23 |
- |
|
| 24 |
-#define MODE_RETURN 0x40 |
|
| 25 |
-#define MODE_KEEP 0x80 |
|
| 26 |
- |
|
| 27 |
-#pragma mark - Operations |
|
| 28 |
- |
|
| 29 |
-/* clang-format off */ |
|
| 30 |
-static void poke8(Uint8 *m, Uint16 a, Uint8 b) { m[a] = b; }
|
|
| 31 |
-static Uint8 peek8(Uint8 *m, Uint16 a) { return m[a]; }
|
|
| 32 |
-static void devw8(Device *d, Uint8 a, Uint8 b) { d->dat[a & 0xf] = b; d->deo(d, a & 0x0f); }
|
|
| 33 |
-static Uint8 devr8(Device *d, Uint8 a) { return d->dei(d, a & 0x0f); }
|
|
| 34 |
-void poke16(Uint8 *m, Uint16 a, Uint16 b) { poke8(m, a, b >> 8); poke8(m, a + 1, b); }
|
|
| 35 |
-Uint16 peek16(Uint8 *m, Uint16 a) { return (peek8(m, a) << 8) + peek8(m, a + 1); }
|
|
| 36 |
-static void devw16(Device *d, Uint8 a, Uint16 b) { devw8(d, a, b >> 8); devw8(d, a + 1, b); }
|
|
| 37 |
- |
|
| 38 |
-/* clang-format on */ |
|
| 39 |
- |
|
| 40 |
-#pragma mark - Core |
|
| 41 |
- |
|
| 42 |
-int |
|
| 43 |
-uxn_eval(Uxn *u, Uint16 vec) |
|
| 44 |
-{
|
|
| 45 |
- Uint8 instr; |
|
| 46 |
- if(!vec || u->dev[0].dat[0xf]) |
|
| 47 |
- return 0; |
|
| 48 |
- u->ram.ptr = vec; |
|
| 49 |
- if(u->wst.ptr > 0xf8) u->wst.ptr = 0xf8; |
|
| 50 |
- while((instr = u->ram.dat[u->ram.ptr++])) {
|
|
| 51 |
- switch(instr) {
|
|
| 52 |
-#pragma GCC diagnostic push |
|
| 53 |
-#pragma GCC diagnostic ignored "-Wunused-value" |
|
| 54 |
-#pragma GCC diagnostic ignored "-Wunused-variable" |
|
| 55 |
- case 0x01: /* INC */ |
|
| 56 |
- {
|
|
| 57 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 58 |
- u->wst.dat[u->wst.ptr - 1] = a + 1; |
|
| 59 |
-#ifndef NO_STACK_CHECKS |
|
| 60 |
- if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
| 61 |
- u->wst.error = 1; |
|
| 62 |
- goto error; |
|
| 63 |
- } |
|
| 64 |
-#endif |
|
| 65 |
- } |
|
| 66 |
- break; |
|
| 67 |
- case 0x02: /* POP */ |
|
| 68 |
- {
|
|
| 69 |
- u->wst.dat[u->wst.ptr - 1]; |
|
| 70 |
-#ifndef NO_STACK_CHECKS |
|
| 71 |
- if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
| 72 |
- u->wst.error = 1; |
|
| 73 |
- goto error; |
|
| 74 |
- } |
|
| 75 |
-#endif |
|
| 76 |
- u->wst.ptr -= 1; |
|
| 77 |
- } |
|
| 78 |
- break; |
|
| 79 |
- case 0x03: /* DUP */ |
|
| 80 |
- {
|
|
| 81 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 82 |
- u->wst.dat[u->wst.ptr] = a; |
|
| 83 |
-#ifndef NO_STACK_CHECKS |
|
| 84 |
- if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
| 85 |
- u->wst.error = 1; |
|
| 86 |
- goto error; |
|
| 87 |
- } |
|
| 88 |
- if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
| 89 |
- u->wst.error = 2; |
|
| 90 |
- goto error; |
|
| 91 |
- } |
|
| 92 |
-#endif |
|
| 93 |
- u->wst.ptr += 1; |
|
| 94 |
- } |
|
| 95 |
- break; |
|
| 96 |
- case 0x04: /* NIP */ |
|
| 97 |
- {
|
|
| 98 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 99 |
- u->wst.dat[u->wst.ptr - 2]; |
|
| 100 |
- u->wst.dat[u->wst.ptr - 2] = a; |
|
| 101 |
-#ifndef NO_STACK_CHECKS |
|
| 102 |
- if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 103 |
- u->wst.error = 1; |
|
| 104 |
- goto error; |
|
| 105 |
- } |
|
| 106 |
-#endif |
|
| 107 |
- u->wst.ptr -= 1; |
|
| 108 |
- } |
|
| 109 |
- break; |
|
| 110 |
- case 0x05: /* SWP */ |
|
| 111 |
- {
|
|
| 112 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 113 |
- u->wst.dat[u->wst.ptr - 2] = a; |
|
| 114 |
- u->wst.dat[u->wst.ptr - 1] = b; |
|
| 115 |
-#ifndef NO_STACK_CHECKS |
|
| 116 |
- if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 117 |
- u->wst.error = 1; |
|
| 118 |
- goto error; |
|
| 119 |
- } |
|
| 120 |
-#endif |
|
| 121 |
- } |
|
| 122 |
- break; |
|
| 123 |
- case 0x06: /* OVR */ |
|
| 124 |
- {
|
|
| 125 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 126 |
- u->wst.dat[u->wst.ptr] = b; |
|
| 127 |
-#ifndef NO_STACK_CHECKS |
|
| 128 |
- if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 129 |
- u->wst.error = 1; |
|
| 130 |
- goto error; |
|
| 131 |
- } |
|
| 132 |
- if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
| 133 |
- u->wst.error = 2; |
|
| 134 |
- goto error; |
|
| 135 |
- } |
|
| 136 |
-#endif |
|
| 137 |
- u->wst.ptr += 1; |
|
| 138 |
- } |
|
| 139 |
- break; |
|
| 140 |
- case 0x07: /* ROT */ |
|
| 141 |
- {
|
|
| 142 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2], c = u->wst.dat[u->wst.ptr - 3]; |
|
| 143 |
- u->wst.dat[u->wst.ptr - 3] = b; |
|
| 144 |
- u->wst.dat[u->wst.ptr - 2] = a; |
|
| 145 |
- u->wst.dat[u->wst.ptr - 1] = c; |
|
| 146 |
-#ifndef NO_STACK_CHECKS |
|
| 147 |
- if(__builtin_expect(u->wst.ptr < 3, 0)) {
|
|
| 148 |
- u->wst.error = 1; |
|
| 149 |
- goto error; |
|
| 150 |
- } |
|
| 151 |
-#endif |
|
| 152 |
- } |
|
| 153 |
- break; |
|
| 154 |
- case 0x08: /* EQU */ |
|
| 155 |
- {
|
|
| 156 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 157 |
- u->wst.dat[u->wst.ptr - 2] = b == a; |
|
| 158 |
-#ifndef NO_STACK_CHECKS |
|
| 159 |
- if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 160 |
- u->wst.error = 1; |
|
| 161 |
- goto error; |
|
| 162 |
- } |
|
| 163 |
-#endif |
|
| 164 |
- u->wst.ptr -= 1; |
|
| 165 |
- } |
|
| 166 |
- break; |
|
| 167 |
- case 0x09: /* NEQ */ |
|
| 168 |
- {
|
|
| 169 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 170 |
- u->wst.dat[u->wst.ptr - 2] = b != a; |
|
| 171 |
-#ifndef NO_STACK_CHECKS |
|
| 172 |
- if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 173 |
- u->wst.error = 1; |
|
| 174 |
- goto error; |
|
| 175 |
- } |
|
| 176 |
-#endif |
|
| 177 |
- u->wst.ptr -= 1; |
|
| 178 |
- } |
|
| 179 |
- break; |
|
| 180 |
- case 0x0a: /* GTH */ |
|
| 181 |
- {
|
|
| 182 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 183 |
- u->wst.dat[u->wst.ptr - 2] = b > a; |
|
| 184 |
-#ifndef NO_STACK_CHECKS |
|
| 185 |
- if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 186 |
- u->wst.error = 1; |
|
| 187 |
- goto error; |
|
| 188 |
- } |
|
| 189 |
-#endif |
|
| 190 |
- u->wst.ptr -= 1; |
|
| 191 |
- } |
|
| 192 |
- break; |
|
| 193 |
- case 0x0b: /* LTH */ |
|
| 194 |
- {
|
|
| 195 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 196 |
- u->wst.dat[u->wst.ptr - 2] = b < a; |
|
| 197 |
-#ifndef NO_STACK_CHECKS |
|
| 198 |
- if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 199 |
- u->wst.error = 1; |
|
| 200 |
- goto error; |
|
| 201 |
- } |
|
| 202 |
-#endif |
|
| 203 |
- u->wst.ptr -= 1; |
|
| 204 |
- } |
|
| 205 |
- break; |
|
| 206 |
- case 0x0c: /* JMP */ |
|
| 207 |
- {
|
|
| 208 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 209 |
- u->ram.ptr += (Sint8)a; |
|
| 210 |
-#ifndef NO_STACK_CHECKS |
|
| 211 |
- if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
| 212 |
- u->wst.error = 1; |
|
| 213 |
- goto error; |
|
| 214 |
- } |
|
| 215 |
-#endif |
|
| 216 |
- u->wst.ptr -= 1; |
|
| 217 |
- } |
|
| 218 |
- break; |
|
| 219 |
- case 0x0d: /* JCN */ |
|
| 220 |
- {
|
|
| 221 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 222 |
- if(u->wst.dat[u->wst.ptr - 2]) u->ram.ptr += (Sint8)a; |
|
| 223 |
-#ifndef NO_STACK_CHECKS |
|
| 224 |
- if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 225 |
- u->wst.error = 1; |
|
| 226 |
- goto error; |
|
| 227 |
- } |
|
| 228 |
-#endif |
|
| 229 |
- u->wst.ptr -= 2; |
|
| 230 |
- } |
|
| 231 |
- break; |
|
| 232 |
- case 0x0e: /* JSR */ |
|
| 233 |
- {
|
|
| 234 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 235 |
- u->rst.dat[u->rst.ptr] = u->ram.ptr >> 8; |
|
| 236 |
- u->rst.dat[u->rst.ptr + 1] = u->ram.ptr & 0xff; |
|
| 237 |
- u->ram.ptr += (Sint8)a; |
|
| 238 |
-#ifndef NO_STACK_CHECKS |
|
| 239 |
- if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
| 240 |
- u->wst.error = 1; |
|
| 241 |
- goto error; |
|
| 242 |
- } |
|
| 243 |
-#endif |
|
| 244 |
- u->wst.ptr -= 1; |
|
| 245 |
-#ifndef NO_STACK_CHECKS |
|
| 246 |
- if(__builtin_expect(u->rst.ptr > 253, 0)) {
|
|
| 247 |
- u->rst.error = 2; |
|
| 248 |
- goto error; |
|
| 249 |
- } |
|
| 250 |
-#endif |
|
| 251 |
- u->rst.ptr += 2; |
|
| 252 |
- } |
|
| 253 |
- break; |
|
| 254 |
- case 0x0f: /* STH */ |
|
| 255 |
- {
|
|
| 256 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 257 |
- u->rst.dat[u->rst.ptr] = a; |
|
| 258 |
-#ifndef NO_STACK_CHECKS |
|
| 259 |
- if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
| 260 |
- u->wst.error = 1; |
|
| 261 |
- goto error; |
|
| 262 |
- } |
|
| 263 |
-#endif |
|
| 264 |
- u->wst.ptr -= 1; |
|
| 265 |
-#ifndef NO_STACK_CHECKS |
|
| 266 |
- if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
| 267 |
- u->rst.error = 2; |
|
| 268 |
- goto error; |
|
| 269 |
- } |
|
| 270 |
-#endif |
|
| 271 |
- u->rst.ptr += 1; |
|
| 272 |
- } |
|
| 273 |
- break; |
|
| 274 |
- case 0x10: /* LDZ */ |
|
| 275 |
- {
|
|
| 276 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 277 |
- u->wst.dat[u->wst.ptr - 1] = peek8(u->ram.dat, a); |
|
| 278 |
-#ifndef NO_STACK_CHECKS |
|
| 279 |
- if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
| 280 |
- u->wst.error = 1; |
|
| 281 |
- goto error; |
|
| 282 |
- } |
|
| 283 |
-#endif |
|
| 284 |
- } |
|
| 285 |
- break; |
|
| 286 |
- case 0x11: /* STZ */ |
|
| 287 |
- {
|
|
| 288 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 289 |
- Uint8 b = u->wst.dat[u->wst.ptr - 2]; |
|
| 290 |
- poke8(u->ram.dat, a, b); |
|
| 291 |
-#ifndef NO_STACK_CHECKS |
|
| 292 |
- if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 293 |
- u->wst.error = 1; |
|
| 294 |
- goto error; |
|
| 295 |
- } |
|
| 296 |
-#endif |
|
| 297 |
- u->wst.ptr -= 2; |
|
| 298 |
- } |
|
| 299 |
- break; |
|
| 300 |
- case 0x12: /* LDR */ |
|
| 301 |
- {
|
|
| 302 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 303 |
- u->wst.dat[u->wst.ptr - 1] = peek8(u->ram.dat, u->ram.ptr + (Sint8)a); |
|
| 304 |
-#ifndef NO_STACK_CHECKS |
|
| 305 |
- if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
| 306 |
- u->wst.error = 1; |
|
| 307 |
- goto error; |
|
| 308 |
- } |
|
| 309 |
-#endif |
|
| 310 |
- } |
|
| 311 |
- break; |
|
| 312 |
- case 0x13: /* STR */ |
|
| 313 |
- {
|
|
| 314 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 315 |
- Uint8 b = u->wst.dat[u->wst.ptr - 2]; |
|
| 316 |
- poke8(u->ram.dat, u->ram.ptr + (Sint8)a, b); |
|
| 317 |
-#ifndef NO_STACK_CHECKS |
|
| 318 |
- if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 319 |
- u->wst.error = 1; |
|
| 320 |
- goto error; |
|
| 321 |
- } |
|
| 322 |
-#endif |
|
| 323 |
- u->wst.ptr -= 2; |
|
| 324 |
- } |
|
| 325 |
- break; |
|
| 326 |
- case 0x14: /* LDA */ |
|
| 327 |
- {
|
|
| 328 |
- Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); |
|
| 329 |
- u->wst.dat[u->wst.ptr - 2] = peek8(u->ram.dat, a); |
|
| 330 |
-#ifndef NO_STACK_CHECKS |
|
| 331 |
- if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 332 |
- u->wst.error = 1; |
|
| 333 |
- goto error; |
|
| 334 |
- } |
|
| 335 |
-#endif |
|
| 336 |
- u->wst.ptr -= 1; |
|
| 337 |
- } |
|
| 338 |
- break; |
|
| 339 |
- case 0x15: /* STA */ |
|
| 340 |
- {
|
|
| 341 |
- Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); |
|
| 342 |
- Uint8 b = u->wst.dat[u->wst.ptr - 3]; |
|
| 343 |
- poke8(u->ram.dat, a, b); |
|
| 344 |
-#ifndef NO_STACK_CHECKS |
|
| 345 |
- if(__builtin_expect(u->wst.ptr < 3, 0)) {
|
|
| 346 |
- u->wst.error = 1; |
|
| 347 |
- goto error; |
|
| 348 |
- } |
|
| 349 |
-#endif |
|
| 350 |
- u->wst.ptr -= 3; |
|
| 351 |
- } |
|
| 352 |
- break; |
|
| 353 |
- case 0x16: /* DEI */ |
|
| 354 |
- {
|
|
| 355 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 356 |
- u->wst.dat[u->wst.ptr - 1] = devr8(&u->dev[a >> 4], a); |
|
| 357 |
-#ifndef NO_STACK_CHECKS |
|
| 358 |
- if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
| 359 |
- u->wst.error = 1; |
|
| 360 |
- goto error; |
|
| 361 |
- } |
|
| 362 |
-#endif |
|
| 363 |
- } |
|
| 364 |
- break; |
|
| 365 |
- case 0x17: /* DEO */ |
|
| 366 |
- {
|
|
| 367 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 368 |
- devw8(&u->dev[a >> 4], a, b); |
|
| 369 |
-#ifndef NO_STACK_CHECKS |
|
| 370 |
- if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 371 |
- u->wst.error = 1; |
|
| 372 |
- goto error; |
|
| 373 |
- } |
|
| 374 |
-#endif |
|
| 375 |
- u->wst.ptr -= 2; |
|
| 376 |
- } |
|
| 377 |
- break; |
|
| 378 |
- case 0x18: /* ADD */ |
|
| 379 |
- {
|
|
| 380 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 381 |
- u->wst.dat[u->wst.ptr - 2] = b + a; |
|
| 382 |
-#ifndef NO_STACK_CHECKS |
|
| 383 |
- if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 384 |
- u->wst.error = 1; |
|
| 385 |
- goto error; |
|
| 386 |
- } |
|
| 387 |
-#endif |
|
| 388 |
- u->wst.ptr -= 1; |
|
| 389 |
- } |
|
| 390 |
- break; |
|
| 391 |
- case 0x19: /* SUB */ |
|
| 392 |
- {
|
|
| 393 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 394 |
- u->wst.dat[u->wst.ptr - 2] = b - a; |
|
| 395 |
-#ifndef NO_STACK_CHECKS |
|
| 396 |
- if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 397 |
- u->wst.error = 1; |
|
| 398 |
- goto error; |
|
| 399 |
- } |
|
| 400 |
-#endif |
|
| 401 |
- u->wst.ptr -= 1; |
|
| 402 |
- } |
|
| 403 |
- break; |
|
| 404 |
- case 0x1a: /* MUL */ |
|
| 405 |
- {
|
|
| 406 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 407 |
- u->wst.dat[u->wst.ptr - 2] = b * a; |
|
| 408 |
-#ifndef NO_STACK_CHECKS |
|
| 409 |
- if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 410 |
- u->wst.error = 1; |
|
| 411 |
- goto error; |
|
| 412 |
- } |
|
| 413 |
-#endif |
|
| 414 |
- u->wst.ptr -= 1; |
|
| 415 |
- } |
|
| 416 |
- break; |
|
| 417 |
- case 0x1b: /* DIV */ |
|
| 418 |
- {
|
|
| 419 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 420 |
- if(a == 0) {
|
|
| 421 |
- u->wst.error = 3; |
|
| 422 |
-#ifndef NO_STACK_CHECKS |
|
| 423 |
- goto error; |
|
| 424 |
-#endif |
|
| 425 |
- a = 1; |
|
| 426 |
- } |
|
| 427 |
- u->wst.dat[u->wst.ptr - 2] = b / a; |
|
| 428 |
-#ifndef NO_STACK_CHECKS |
|
| 429 |
- if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 430 |
- u->wst.error = 1; |
|
| 431 |
- goto error; |
|
| 432 |
- } |
|
| 433 |
-#endif |
|
| 434 |
- u->wst.ptr -= 1; |
|
| 435 |
- } |
|
| 436 |
- break; |
|
| 437 |
- case 0x1c: /* AND */ |
|
| 438 |
- {
|
|
| 439 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 440 |
- u->wst.dat[u->wst.ptr - 2] = b & a; |
|
| 441 |
-#ifndef NO_STACK_CHECKS |
|
| 442 |
- if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 443 |
- u->wst.error = 1; |
|
| 444 |
- goto error; |
|
| 445 |
- } |
|
| 446 |
-#endif |
|
| 447 |
- u->wst.ptr -= 1; |
|
| 448 |
- } |
|
| 449 |
- break; |
|
| 450 |
- case 0x1d: /* ORA */ |
|
| 451 |
- {
|
|
| 452 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 453 |
- u->wst.dat[u->wst.ptr - 2] = b | a; |
|
| 454 |
-#ifndef NO_STACK_CHECKS |
|
| 455 |
- if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 456 |
- u->wst.error = 1; |
|
| 457 |
- goto error; |
|
| 458 |
- } |
|
| 459 |
-#endif |
|
| 460 |
- u->wst.ptr -= 1; |
|
| 461 |
- } |
|
| 462 |
- break; |
|
| 463 |
- case 0x1e: /* EOR */ |
|
| 464 |
- {
|
|
| 465 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 466 |
- u->wst.dat[u->wst.ptr - 2] = b ^ a; |
|
| 467 |
-#ifndef NO_STACK_CHECKS |
|
| 468 |
- if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 469 |
- u->wst.error = 1; |
|
| 470 |
- goto error; |
|
| 471 |
- } |
|
| 472 |
-#endif |
|
| 473 |
- u->wst.ptr -= 1; |
|
| 474 |
- } |
|
| 475 |
- break; |
|
| 476 |
- case 0x1f: /* SFT */ |
|
| 477 |
- {
|
|
| 478 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 479 |
- u->wst.dat[u->wst.ptr - 2] = b >> (a & 0x0f) << ((a & 0xf0) >> 4); |
|
| 480 |
-#ifndef NO_STACK_CHECKS |
|
| 481 |
- if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 482 |
- u->wst.error = 1; |
|
| 483 |
- goto error; |
|
| 484 |
- } |
|
| 485 |
-#endif |
|
| 486 |
- u->wst.ptr -= 1; |
|
| 487 |
- } |
|
| 488 |
- break; |
|
| 489 |
- case 0x21: /* INC2 */ |
|
| 490 |
- {
|
|
| 491 |
- Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); |
|
| 492 |
- u->wst.dat[u->wst.ptr - 2] = (a + 1) >> 8; |
|
| 493 |
- u->wst.dat[u->wst.ptr - 1] = (a + 1) & 0xff; |
|
| 494 |
-#ifndef NO_STACK_CHECKS |
|
| 495 |
- if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 496 |
- u->wst.error = 1; |
|
| 497 |
- goto error; |
|
| 498 |
- } |
|
| 499 |
-#endif |
|
| 500 |
- } |
|
| 501 |
- break; |
|
| 502 |
- case 0x22: /* POP2 */ |
|
| 503 |
- {
|
|
| 504 |
- (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); |
|
| 505 |
-#ifndef NO_STACK_CHECKS |
|
| 506 |
- if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 507 |
- u->wst.error = 1; |
|
| 508 |
- goto error; |
|
| 509 |
- } |
|
| 510 |
-#endif |
|
| 511 |
- u->wst.ptr -= 2; |
|
| 512 |
- } |
|
| 513 |
- break; |
|
| 514 |
- case 0x23: /* DUP2 */ |
|
| 515 |
- {
|
|
| 516 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 517 |
- u->wst.dat[u->wst.ptr] = b; |
|
| 518 |
- u->wst.dat[u->wst.ptr + 1] = a; |
|
| 519 |
-#ifndef NO_STACK_CHECKS |
|
| 520 |
- if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 521 |
- u->wst.error = 1; |
|
| 522 |
- goto error; |
|
| 523 |
- } |
|
| 524 |
- if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
| 525 |
- u->wst.error = 2; |
|
| 526 |
- goto error; |
|
| 527 |
- } |
|
| 528 |
-#endif |
|
| 529 |
- u->wst.ptr += 2; |
|
| 530 |
- } |
|
| 531 |
- break; |
|
| 532 |
- case 0x24: /* NIP2 */ |
|
| 533 |
- {
|
|
| 534 |
- Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); |
|
| 535 |
- (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); |
|
| 536 |
- u->wst.dat[u->wst.ptr - 4] = a >> 8; |
|
| 537 |
- u->wst.dat[u->wst.ptr - 3] = a & 0xff; |
|
| 538 |
-#ifndef NO_STACK_CHECKS |
|
| 539 |
- if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
| 540 |
- u->wst.error = 1; |
|
| 541 |
- goto error; |
|
| 542 |
- } |
|
| 543 |
-#endif |
|
| 544 |
- u->wst.ptr -= 2; |
|
| 545 |
- } |
|
| 546 |
- break; |
|
| 547 |
- case 0x25: /* SWP2 */ |
|
| 548 |
- {
|
|
| 549 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2], c = u->wst.dat[u->wst.ptr - 3], d = u->wst.dat[u->wst.ptr - 4]; |
|
| 550 |
- u->wst.dat[u->wst.ptr - 4] = b; |
|
| 551 |
- u->wst.dat[u->wst.ptr - 3] = a; |
|
| 552 |
- u->wst.dat[u->wst.ptr - 2] = d; |
|
| 553 |
- u->wst.dat[u->wst.ptr - 1] = c; |
|
| 554 |
-#ifndef NO_STACK_CHECKS |
|
| 555 |
- if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
| 556 |
- u->wst.error = 1; |
|
| 557 |
- goto error; |
|
| 558 |
- } |
|
| 559 |
-#endif |
|
| 560 |
- } |
|
| 561 |
- break; |
|
| 562 |
- case 0x26: /* OVR2 */ |
|
| 563 |
- {
|
|
| 564 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2], c = u->wst.dat[u->wst.ptr - 3], d = u->wst.dat[u->wst.ptr - 4]; |
|
| 565 |
- u->wst.dat[u->wst.ptr] = d; |
|
| 566 |
- u->wst.dat[u->wst.ptr + 1] = c; |
|
| 567 |
-#ifndef NO_STACK_CHECKS |
|
| 568 |
- if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
| 569 |
- u->wst.error = 1; |
|
| 570 |
- goto error; |
|
| 571 |
- } |
|
| 572 |
- if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
| 573 |
- u->wst.error = 2; |
|
| 574 |
- goto error; |
|
| 575 |
- } |
|
| 576 |
-#endif |
|
| 577 |
- u->wst.ptr += 2; |
|
| 578 |
- } |
|
| 579 |
- break; |
|
| 580 |
- case 0x27: /* ROT2 */ |
|
| 581 |
- {
|
|
| 582 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2], c = u->wst.dat[u->wst.ptr - 3], d = u->wst.dat[u->wst.ptr - 4], e = u->wst.dat[u->wst.ptr - 5], f = u->wst.dat[u->wst.ptr - 6]; |
|
| 583 |
- u->wst.dat[u->wst.ptr - 6] = d; |
|
| 584 |
- u->wst.dat[u->wst.ptr - 5] = c; |
|
| 585 |
- u->wst.dat[u->wst.ptr - 4] = b; |
|
| 586 |
- u->wst.dat[u->wst.ptr - 3] = a; |
|
| 587 |
- u->wst.dat[u->wst.ptr - 2] = f; |
|
| 588 |
- u->wst.dat[u->wst.ptr - 1] = e; |
|
| 589 |
-#ifndef NO_STACK_CHECKS |
|
| 590 |
- if(__builtin_expect(u->wst.ptr < 6, 0)) {
|
|
| 591 |
- u->wst.error = 1; |
|
| 592 |
- goto error; |
|
| 593 |
- } |
|
| 594 |
-#endif |
|
| 595 |
- } |
|
| 596 |
- break; |
|
| 597 |
- case 0x28: /* EQU2 */ |
|
| 598 |
- {
|
|
| 599 |
- Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); |
|
| 600 |
- u->wst.dat[u->wst.ptr - 4] = b == a; |
|
| 601 |
-#ifndef NO_STACK_CHECKS |
|
| 602 |
- if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
| 603 |
- u->wst.error = 1; |
|
| 604 |
- goto error; |
|
| 605 |
- } |
|
| 606 |
-#endif |
|
| 607 |
- u->wst.ptr -= 3; |
|
| 608 |
- } |
|
| 609 |
- break; |
|
| 610 |
- case 0x29: /* NEQ2 */ |
|
| 611 |
- {
|
|
| 612 |
- Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); |
|
| 613 |
- u->wst.dat[u->wst.ptr - 4] = b != a; |
|
| 614 |
-#ifndef NO_STACK_CHECKS |
|
| 615 |
- if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
| 616 |
- u->wst.error = 1; |
|
| 617 |
- goto error; |
|
| 618 |
- } |
|
| 619 |
-#endif |
|
| 620 |
- u->wst.ptr -= 3; |
|
| 621 |
- } |
|
| 622 |
- break; |
|
| 623 |
- case 0x2a: /* GTH2 */ |
|
| 624 |
- {
|
|
| 625 |
- Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); |
|
| 626 |
- u->wst.dat[u->wst.ptr - 4] = b > a; |
|
| 627 |
-#ifndef NO_STACK_CHECKS |
|
| 628 |
- if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
| 629 |
- u->wst.error = 1; |
|
| 630 |
- goto error; |
|
| 631 |
- } |
|
| 632 |
-#endif |
|
| 633 |
- u->wst.ptr -= 3; |
|
| 634 |
- } |
|
| 635 |
- break; |
|
| 636 |
- case 0x2b: /* LTH2 */ |
|
| 637 |
- {
|
|
| 638 |
- Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); |
|
| 639 |
- u->wst.dat[u->wst.ptr - 4] = b < a; |
|
| 640 |
-#ifndef NO_STACK_CHECKS |
|
| 641 |
- if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
| 642 |
- u->wst.error = 1; |
|
| 643 |
- goto error; |
|
| 644 |
- } |
|
| 645 |
-#endif |
|
| 646 |
- u->wst.ptr -= 3; |
|
| 647 |
- } |
|
| 648 |
- break; |
|
| 649 |
- case 0x2c: /* JMP2 */ |
|
| 650 |
- {
|
|
| 651 |
- u->ram.ptr = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); |
|
| 652 |
-#ifndef NO_STACK_CHECKS |
|
| 653 |
- if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 654 |
- u->wst.error = 1; |
|
| 655 |
- goto error; |
|
| 656 |
- } |
|
| 657 |
-#endif |
|
| 658 |
- u->wst.ptr -= 2; |
|
| 659 |
- } |
|
| 660 |
- break; |
|
| 661 |
- case 0x2d: /* JCN2 */ |
|
| 662 |
- {
|
|
| 663 |
- Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); |
|
| 664 |
- if(u->wst.dat[u->wst.ptr - 3]) u->ram.ptr = a; |
|
| 665 |
-#ifndef NO_STACK_CHECKS |
|
| 666 |
- if(__builtin_expect(u->wst.ptr < 3, 0)) {
|
|
| 667 |
- u->wst.error = 1; |
|
| 668 |
- goto error; |
|
| 669 |
- } |
|
| 670 |
-#endif |
|
| 671 |
- u->wst.ptr -= 3; |
|
| 672 |
- } |
|
| 673 |
- break; |
|
| 674 |
- case 0x2e: /* JSR2 */ |
|
| 675 |
- {
|
|
| 676 |
- u->rst.dat[u->rst.ptr] = u->ram.ptr >> 8; |
|
| 677 |
- u->rst.dat[u->rst.ptr + 1] = u->ram.ptr & 0xff; |
|
| 678 |
- u->ram.ptr = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); |
|
| 679 |
-#ifndef NO_STACK_CHECKS |
|
| 680 |
- if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 681 |
- u->wst.error = 1; |
|
| 682 |
- goto error; |
|
| 683 |
- } |
|
| 684 |
-#endif |
|
| 685 |
- u->wst.ptr -= 2; |
|
| 686 |
-#ifndef NO_STACK_CHECKS |
|
| 687 |
- if(__builtin_expect(u->rst.ptr > 253, 0)) {
|
|
| 688 |
- u->rst.error = 2; |
|
| 689 |
- goto error; |
|
| 690 |
- } |
|
| 691 |
-#endif |
|
| 692 |
- u->rst.ptr += 2; |
|
| 693 |
- } |
|
| 694 |
- break; |
|
| 695 |
- case 0x2f: /* STH2 */ |
|
| 696 |
- {
|
|
| 697 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 698 |
- u->rst.dat[u->rst.ptr] = b; |
|
| 699 |
- u->rst.dat[u->rst.ptr + 1] = a; |
|
| 700 |
-#ifndef NO_STACK_CHECKS |
|
| 701 |
- if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 702 |
- u->wst.error = 1; |
|
| 703 |
- goto error; |
|
| 704 |
- } |
|
| 705 |
-#endif |
|
| 706 |
- u->wst.ptr -= 2; |
|
| 707 |
-#ifndef NO_STACK_CHECKS |
|
| 708 |
- if(__builtin_expect(u->rst.ptr > 253, 0)) {
|
|
| 709 |
- u->rst.error = 2; |
|
| 710 |
- goto error; |
|
| 711 |
- } |
|
| 712 |
-#endif |
|
| 713 |
- u->rst.ptr += 2; |
|
| 714 |
- } |
|
| 715 |
- break; |
|
| 716 |
- case 0x30: /* LDZ2 */ |
|
| 717 |
- {
|
|
| 718 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 719 |
- u->wst.dat[u->wst.ptr - 1] = peek8(u->ram.dat, a); |
|
| 720 |
- u->wst.dat[u->wst.ptr] = peek8(u->ram.dat, a + 1); |
|
| 721 |
-#ifndef NO_STACK_CHECKS |
|
| 722 |
- if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
| 723 |
- u->wst.error = 1; |
|
| 724 |
- goto error; |
|
| 725 |
- } |
|
| 726 |
- if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
| 727 |
- u->wst.error = 2; |
|
| 728 |
- goto error; |
|
| 729 |
- } |
|
| 730 |
-#endif |
|
| 731 |
- u->wst.ptr += 1; |
|
| 732 |
- } |
|
| 733 |
- break; |
|
| 734 |
- case 0x31: /* STZ2 */ |
|
| 735 |
- {
|
|
| 736 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 737 |
- Uint16 b = (u->wst.dat[u->wst.ptr - 2] | (u->wst.dat[u->wst.ptr - 3] << 8)); |
|
| 738 |
- poke16(u->ram.dat, a, b); |
|
| 739 |
-#ifndef NO_STACK_CHECKS |
|
| 740 |
- if(__builtin_expect(u->wst.ptr < 3, 0)) {
|
|
| 741 |
- u->wst.error = 1; |
|
| 742 |
- goto error; |
|
| 743 |
- } |
|
| 744 |
-#endif |
|
| 745 |
- u->wst.ptr -= 3; |
|
| 746 |
- } |
|
| 747 |
- break; |
|
| 748 |
- case 0x32: /* LDR2 */ |
|
| 749 |
- {
|
|
| 750 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 751 |
- u->wst.dat[u->wst.ptr - 1] = peek8(u->ram.dat, u->ram.ptr + (Sint8)a); |
|
| 752 |
- u->wst.dat[u->wst.ptr] = peek8(u->ram.dat, u->ram.ptr + (Sint8)a + 1); |
|
| 753 |
-#ifndef NO_STACK_CHECKS |
|
| 754 |
- if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
| 755 |
- u->wst.error = 1; |
|
| 756 |
- goto error; |
|
| 757 |
- } |
|
| 758 |
- if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
| 759 |
- u->wst.error = 2; |
|
| 760 |
- goto error; |
|
| 761 |
- } |
|
| 762 |
-#endif |
|
| 763 |
- u->wst.ptr += 1; |
|
| 764 |
- } |
|
| 765 |
- break; |
|
| 766 |
- case 0x33: /* STR2 */ |
|
| 767 |
- {
|
|
| 768 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 769 |
- Uint16 b = (u->wst.dat[u->wst.ptr - 2] | (u->wst.dat[u->wst.ptr - 3] << 8)); |
|
| 770 |
- poke16(u->ram.dat, u->ram.ptr + (Sint8)a, b); |
|
| 771 |
-#ifndef NO_STACK_CHECKS |
|
| 772 |
- if(__builtin_expect(u->wst.ptr < 3, 0)) {
|
|
| 773 |
- u->wst.error = 1; |
|
| 774 |
- goto error; |
|
| 775 |
- } |
|
| 776 |
-#endif |
|
| 777 |
- u->wst.ptr -= 3; |
|
| 778 |
- } |
|
| 779 |
- break; |
|
| 780 |
- case 0x34: /* LDA2 */ |
|
| 781 |
- {
|
|
| 782 |
- Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); |
|
| 783 |
- u->wst.dat[u->wst.ptr - 2] = peek8(u->ram.dat, a); |
|
| 784 |
- u->wst.dat[u->wst.ptr - 1] = peek8(u->ram.dat, a + 1); |
|
| 785 |
-#ifndef NO_STACK_CHECKS |
|
| 786 |
- if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 787 |
- u->wst.error = 1; |
|
| 788 |
- goto error; |
|
| 789 |
- } |
|
| 790 |
-#endif |
|
| 791 |
- } |
|
| 792 |
- break; |
|
| 793 |
- case 0x35: /* STA2 */ |
|
| 794 |
- {
|
|
| 795 |
- Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); |
|
| 796 |
- Uint16 b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); |
|
| 797 |
- poke16(u->ram.dat, a, b); |
|
| 798 |
-#ifndef NO_STACK_CHECKS |
|
| 799 |
- if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
| 800 |
- u->wst.error = 1; |
|
| 801 |
- goto error; |
|
| 802 |
- } |
|
| 803 |
-#endif |
|
| 804 |
- u->wst.ptr -= 4; |
|
| 805 |
- } |
|
| 806 |
- break; |
|
| 807 |
- case 0x36: /* DEI2 */ |
|
| 808 |
- {
|
|
| 809 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 810 |
- u->wst.dat[u->wst.ptr - 1] = devr8(&u->dev[a >> 4], a); |
|
| 811 |
- u->wst.dat[u->wst.ptr] = devr8(&u->dev[a >> 4], a + 1); |
|
| 812 |
-#ifndef NO_STACK_CHECKS |
|
| 813 |
- if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
| 814 |
- u->wst.error = 1; |
|
| 815 |
- goto error; |
|
| 816 |
- } |
|
| 817 |
- if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
| 818 |
- u->wst.error = 2; |
|
| 819 |
- goto error; |
|
| 820 |
- } |
|
| 821 |
-#endif |
|
| 822 |
- u->wst.ptr += 1; |
|
| 823 |
- } |
|
| 824 |
- break; |
|
| 825 |
- case 0x37: /* DEO2 */ |
|
| 826 |
- {
|
|
| 827 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 828 |
- Uint16 b = (u->wst.dat[u->wst.ptr - 2] | (u->wst.dat[u->wst.ptr - 3] << 8)); |
|
| 829 |
- devw16(&u->dev[a >> 4], a, b); |
|
| 830 |
-#ifndef NO_STACK_CHECKS |
|
| 831 |
- if(__builtin_expect(u->wst.ptr < 3, 0)) {
|
|
| 832 |
- u->wst.error = 1; |
|
| 833 |
- goto error; |
|
| 834 |
- } |
|
| 835 |
-#endif |
|
| 836 |
- u->wst.ptr -= 3; |
|
| 837 |
- } |
|
| 838 |
- break; |
|
| 839 |
- case 0x38: /* ADD2 */ |
|
| 840 |
- {
|
|
| 841 |
- Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); |
|
| 842 |
- u->wst.dat[u->wst.ptr - 4] = (b + a) >> 8; |
|
| 843 |
- u->wst.dat[u->wst.ptr - 3] = (b + a) & 0xff; |
|
| 844 |
-#ifndef NO_STACK_CHECKS |
|
| 845 |
- if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
| 846 |
- u->wst.error = 1; |
|
| 847 |
- goto error; |
|
| 848 |
- } |
|
| 849 |
-#endif |
|
| 850 |
- u->wst.ptr -= 2; |
|
| 851 |
- } |
|
| 852 |
- break; |
|
| 853 |
- case 0x39: /* SUB2 */ |
|
| 854 |
- {
|
|
| 855 |
- Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); |
|
| 856 |
- u->wst.dat[u->wst.ptr - 4] = (b - a) >> 8; |
|
| 857 |
- u->wst.dat[u->wst.ptr - 3] = (b - a) & 0xff; |
|
| 858 |
-#ifndef NO_STACK_CHECKS |
|
| 859 |
- if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
| 860 |
- u->wst.error = 1; |
|
| 861 |
- goto error; |
|
| 862 |
- } |
|
| 863 |
-#endif |
|
| 864 |
- u->wst.ptr -= 2; |
|
| 865 |
- } |
|
| 866 |
- break; |
|
| 867 |
- case 0x3a: /* MUL2 */ |
|
| 868 |
- {
|
|
| 869 |
- Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); |
|
| 870 |
- u->wst.dat[u->wst.ptr - 4] = (b * a) >> 8; |
|
| 871 |
- u->wst.dat[u->wst.ptr - 3] = (b * a) & 0xff; |
|
| 872 |
-#ifndef NO_STACK_CHECKS |
|
| 873 |
- if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
| 874 |
- u->wst.error = 1; |
|
| 875 |
- goto error; |
|
| 876 |
- } |
|
| 877 |
-#endif |
|
| 878 |
- u->wst.ptr -= 2; |
|
| 879 |
- } |
|
| 880 |
- break; |
|
| 881 |
- case 0x3b: /* DIV2 */ |
|
| 882 |
- {
|
|
| 883 |
- Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); |
|
| 884 |
- if(a == 0) {
|
|
| 885 |
- u->wst.error = 3; |
|
| 886 |
-#ifndef NO_STACK_CHECKS |
|
| 887 |
- goto error; |
|
| 888 |
-#endif |
|
| 889 |
- a = 1; |
|
| 890 |
- } |
|
| 891 |
- u->wst.dat[u->wst.ptr - 4] = (b / a) >> 8; |
|
| 892 |
- u->wst.dat[u->wst.ptr - 3] = (b / a) & 0xff; |
|
| 893 |
-#ifndef NO_STACK_CHECKS |
|
| 894 |
- if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
| 895 |
- u->wst.error = 1; |
|
| 896 |
- goto error; |
|
| 897 |
- } |
|
| 898 |
-#endif |
|
| 899 |
- u->wst.ptr -= 2; |
|
| 900 |
- } |
|
| 901 |
- break; |
|
| 902 |
- case 0x3c: /* AND2 */ |
|
| 903 |
- {
|
|
| 904 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2], c = u->wst.dat[u->wst.ptr - 3], d = u->wst.dat[u->wst.ptr - 4]; |
|
| 905 |
- u->wst.dat[u->wst.ptr - 4] = d & b; |
|
| 906 |
- u->wst.dat[u->wst.ptr - 3] = c & a; |
|
| 907 |
-#ifndef NO_STACK_CHECKS |
|
| 908 |
- if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
| 909 |
- u->wst.error = 1; |
|
| 910 |
- goto error; |
|
| 911 |
- } |
|
| 912 |
-#endif |
|
| 913 |
- u->wst.ptr -= 2; |
|
| 914 |
- } |
|
| 915 |
- break; |
|
| 916 |
- case 0x3d: /* ORA2 */ |
|
| 917 |
- {
|
|
| 918 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2], c = u->wst.dat[u->wst.ptr - 3], d = u->wst.dat[u->wst.ptr - 4]; |
|
| 919 |
- u->wst.dat[u->wst.ptr - 4] = d | b; |
|
| 920 |
- u->wst.dat[u->wst.ptr - 3] = c | a; |
|
| 921 |
-#ifndef NO_STACK_CHECKS |
|
| 922 |
- if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
| 923 |
- u->wst.error = 1; |
|
| 924 |
- goto error; |
|
| 925 |
- } |
|
| 926 |
-#endif |
|
| 927 |
- u->wst.ptr -= 2; |
|
| 928 |
- } |
|
| 929 |
- break; |
|
| 930 |
- case 0x3e: /* EOR2 */ |
|
| 931 |
- {
|
|
| 932 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2], c = u->wst.dat[u->wst.ptr - 3], d = u->wst.dat[u->wst.ptr - 4]; |
|
| 933 |
- u->wst.dat[u->wst.ptr - 4] = d ^ b; |
|
| 934 |
- u->wst.dat[u->wst.ptr - 3] = c ^ a; |
|
| 935 |
-#ifndef NO_STACK_CHECKS |
|
| 936 |
- if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
| 937 |
- u->wst.error = 1; |
|
| 938 |
- goto error; |
|
| 939 |
- } |
|
| 940 |
-#endif |
|
| 941 |
- u->wst.ptr -= 2; |
|
| 942 |
- } |
|
| 943 |
- break; |
|
| 944 |
- case 0x3f: /* SFT2 */ |
|
| 945 |
- {
|
|
| 946 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 947 |
- Uint16 b = (u->wst.dat[u->wst.ptr - 2] | (u->wst.dat[u->wst.ptr - 3] << 8)); |
|
| 948 |
- u->wst.dat[u->wst.ptr - 3] = (b >> (a & 0x0f) << ((a & 0xf0) >> 4)) >> 8; |
|
| 949 |
- u->wst.dat[u->wst.ptr - 2] = (b >> (a & 0x0f) << ((a & 0xf0) >> 4)) & 0xff; |
|
| 950 |
-#ifndef NO_STACK_CHECKS |
|
| 951 |
- if(__builtin_expect(u->wst.ptr < 3, 0)) {
|
|
| 952 |
- u->wst.error = 1; |
|
| 953 |
- goto error; |
|
| 954 |
- } |
|
| 955 |
-#endif |
|
| 956 |
- u->wst.ptr -= 1; |
|
| 957 |
- } |
|
| 958 |
- break; |
|
| 959 |
- case 0x41: /* INCr */ |
|
| 960 |
- {
|
|
| 961 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 962 |
- u->rst.dat[u->rst.ptr - 1] = a + 1; |
|
| 963 |
-#ifndef NO_STACK_CHECKS |
|
| 964 |
- if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
| 965 |
- u->rst.error = 1; |
|
| 966 |
- goto error; |
|
| 967 |
- } |
|
| 968 |
-#endif |
|
| 969 |
- } |
|
| 970 |
- break; |
|
| 971 |
- case 0x42: /* POPr */ |
|
| 972 |
- {
|
|
| 973 |
- u->rst.dat[u->rst.ptr - 1]; |
|
| 974 |
-#ifndef NO_STACK_CHECKS |
|
| 975 |
- if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
| 976 |
- u->rst.error = 1; |
|
| 977 |
- goto error; |
|
| 978 |
- } |
|
| 979 |
-#endif |
|
| 980 |
- u->rst.ptr -= 1; |
|
| 981 |
- } |
|
| 982 |
- break; |
|
| 983 |
- case 0x43: /* DUPr */ |
|
| 984 |
- {
|
|
| 985 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 986 |
- u->rst.dat[u->rst.ptr] = a; |
|
| 987 |
-#ifndef NO_STACK_CHECKS |
|
| 988 |
- if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
| 989 |
- u->rst.error = 1; |
|
| 990 |
- goto error; |
|
| 991 |
- } |
|
| 992 |
- if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
| 993 |
- u->rst.error = 2; |
|
| 994 |
- goto error; |
|
| 995 |
- } |
|
| 996 |
-#endif |
|
| 997 |
- u->rst.ptr += 1; |
|
| 998 |
- } |
|
| 999 |
- break; |
|
| 1000 |
- case 0x44: /* NIPr */ |
|
| 1001 |
- {
|
|
| 1002 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 1003 |
- u->rst.dat[u->rst.ptr - 2]; |
|
| 1004 |
- u->rst.dat[u->rst.ptr - 2] = a; |
|
| 1005 |
-#ifndef NO_STACK_CHECKS |
|
| 1006 |
- if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 1007 |
- u->rst.error = 1; |
|
| 1008 |
- goto error; |
|
| 1009 |
- } |
|
| 1010 |
-#endif |
|
| 1011 |
- u->rst.ptr -= 1; |
|
| 1012 |
- } |
|
| 1013 |
- break; |
|
| 1014 |
- case 0x45: /* SWPr */ |
|
| 1015 |
- {
|
|
| 1016 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 1017 |
- u->rst.dat[u->rst.ptr - 2] = a; |
|
| 1018 |
- u->rst.dat[u->rst.ptr - 1] = b; |
|
| 1019 |
-#ifndef NO_STACK_CHECKS |
|
| 1020 |
- if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 1021 |
- u->rst.error = 1; |
|
| 1022 |
- goto error; |
|
| 1023 |
- } |
|
| 1024 |
-#endif |
|
| 1025 |
- } |
|
| 1026 |
- break; |
|
| 1027 |
- case 0x46: /* OVRr */ |
|
| 1028 |
- {
|
|
| 1029 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 1030 |
- u->rst.dat[u->rst.ptr] = b; |
|
| 1031 |
-#ifndef NO_STACK_CHECKS |
|
| 1032 |
- if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 1033 |
- u->rst.error = 1; |
|
| 1034 |
- goto error; |
|
| 1035 |
- } |
|
| 1036 |
- if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
| 1037 |
- u->rst.error = 2; |
|
| 1038 |
- goto error; |
|
| 1039 |
- } |
|
| 1040 |
-#endif |
|
| 1041 |
- u->rst.ptr += 1; |
|
| 1042 |
- } |
|
| 1043 |
- break; |
|
| 1044 |
- case 0x47: /* ROTr */ |
|
| 1045 |
- {
|
|
| 1046 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2], c = u->rst.dat[u->rst.ptr - 3]; |
|
| 1047 |
- u->rst.dat[u->rst.ptr - 3] = b; |
|
| 1048 |
- u->rst.dat[u->rst.ptr - 2] = a; |
|
| 1049 |
- u->rst.dat[u->rst.ptr - 1] = c; |
|
| 1050 |
-#ifndef NO_STACK_CHECKS |
|
| 1051 |
- if(__builtin_expect(u->rst.ptr < 3, 0)) {
|
|
| 1052 |
- u->rst.error = 1; |
|
| 1053 |
- goto error; |
|
| 1054 |
- } |
|
| 1055 |
-#endif |
|
| 1056 |
- } |
|
| 1057 |
- break; |
|
| 1058 |
- case 0x48: /* EQUr */ |
|
| 1059 |
- {
|
|
| 1060 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 1061 |
- u->rst.dat[u->rst.ptr - 2] = b == a; |
|
| 1062 |
-#ifndef NO_STACK_CHECKS |
|
| 1063 |
- if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 1064 |
- u->rst.error = 1; |
|
| 1065 |
- goto error; |
|
| 1066 |
- } |
|
| 1067 |
-#endif |
|
| 1068 |
- u->rst.ptr -= 1; |
|
| 1069 |
- } |
|
| 1070 |
- break; |
|
| 1071 |
- case 0x49: /* NEQr */ |
|
| 1072 |
- {
|
|
| 1073 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 1074 |
- u->rst.dat[u->rst.ptr - 2] = b != a; |
|
| 1075 |
-#ifndef NO_STACK_CHECKS |
|
| 1076 |
- if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 1077 |
- u->rst.error = 1; |
|
| 1078 |
- goto error; |
|
| 1079 |
- } |
|
| 1080 |
-#endif |
|
| 1081 |
- u->rst.ptr -= 1; |
|
| 1082 |
- } |
|
| 1083 |
- break; |
|
| 1084 |
- case 0x4a: /* GTHr */ |
|
| 1085 |
- {
|
|
| 1086 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 1087 |
- u->rst.dat[u->rst.ptr - 2] = b > a; |
|
| 1088 |
-#ifndef NO_STACK_CHECKS |
|
| 1089 |
- if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 1090 |
- u->rst.error = 1; |
|
| 1091 |
- goto error; |
|
| 1092 |
- } |
|
| 1093 |
-#endif |
|
| 1094 |
- u->rst.ptr -= 1; |
|
| 1095 |
- } |
|
| 1096 |
- break; |
|
| 1097 |
- case 0x4b: /* LTHr */ |
|
| 1098 |
- {
|
|
| 1099 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 1100 |
- u->rst.dat[u->rst.ptr - 2] = b < a; |
|
| 1101 |
-#ifndef NO_STACK_CHECKS |
|
| 1102 |
- if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 1103 |
- u->rst.error = 1; |
|
| 1104 |
- goto error; |
|
| 1105 |
- } |
|
| 1106 |
-#endif |
|
| 1107 |
- u->rst.ptr -= 1; |
|
| 1108 |
- } |
|
| 1109 |
- break; |
|
| 1110 |
- case 0x4c: /* JMPr */ |
|
| 1111 |
- {
|
|
| 1112 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 1113 |
- u->ram.ptr += (Sint8)a; |
|
| 1114 |
-#ifndef NO_STACK_CHECKS |
|
| 1115 |
- if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
| 1116 |
- u->rst.error = 1; |
|
| 1117 |
- goto error; |
|
| 1118 |
- } |
|
| 1119 |
-#endif |
|
| 1120 |
- u->rst.ptr -= 1; |
|
| 1121 |
- } |
|
| 1122 |
- break; |
|
| 1123 |
- case 0x4d: /* JCNr */ |
|
| 1124 |
- {
|
|
| 1125 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 1126 |
- if(u->rst.dat[u->rst.ptr - 2]) u->ram.ptr += (Sint8)a; |
|
| 1127 |
-#ifndef NO_STACK_CHECKS |
|
| 1128 |
- if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 1129 |
- u->rst.error = 1; |
|
| 1130 |
- goto error; |
|
| 1131 |
- } |
|
| 1132 |
-#endif |
|
| 1133 |
- u->rst.ptr -= 2; |
|
| 1134 |
- } |
|
| 1135 |
- break; |
|
| 1136 |
- case 0x4e: /* JSRr */ |
|
| 1137 |
- {
|
|
| 1138 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 1139 |
- u->wst.dat[u->wst.ptr] = u->ram.ptr >> 8; |
|
| 1140 |
- u->wst.dat[u->wst.ptr + 1] = u->ram.ptr & 0xff; |
|
| 1141 |
- u->ram.ptr += (Sint8)a; |
|
| 1142 |
-#ifndef NO_STACK_CHECKS |
|
| 1143 |
- if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
| 1144 |
- u->rst.error = 1; |
|
| 1145 |
- goto error; |
|
| 1146 |
- } |
|
| 1147 |
-#endif |
|
| 1148 |
- u->rst.ptr -= 1; |
|
| 1149 |
-#ifndef NO_STACK_CHECKS |
|
| 1150 |
- if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
| 1151 |
- u->wst.error = 2; |
|
| 1152 |
- goto error; |
|
| 1153 |
- } |
|
| 1154 |
-#endif |
|
| 1155 |
- u->wst.ptr += 2; |
|
| 1156 |
- } |
|
| 1157 |
- break; |
|
| 1158 |
- case 0x4f: /* STHr */ |
|
| 1159 |
- {
|
|
| 1160 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 1161 |
- u->wst.dat[u->wst.ptr] = a; |
|
| 1162 |
-#ifndef NO_STACK_CHECKS |
|
| 1163 |
- if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
| 1164 |
- u->rst.error = 1; |
|
| 1165 |
- goto error; |
|
| 1166 |
- } |
|
| 1167 |
-#endif |
|
| 1168 |
- u->rst.ptr -= 1; |
|
| 1169 |
-#ifndef NO_STACK_CHECKS |
|
| 1170 |
- if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
| 1171 |
- u->wst.error = 2; |
|
| 1172 |
- goto error; |
|
| 1173 |
- } |
|
| 1174 |
-#endif |
|
| 1175 |
- u->wst.ptr += 1; |
|
| 1176 |
- } |
|
| 1177 |
- break; |
|
| 1178 |
- case 0x50: /* LDZr */ |
|
| 1179 |
- {
|
|
| 1180 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 1181 |
- u->rst.dat[u->rst.ptr - 1] = peek8(u->ram.dat, a); |
|
| 1182 |
-#ifndef NO_STACK_CHECKS |
|
| 1183 |
- if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
| 1184 |
- u->rst.error = 1; |
|
| 1185 |
- goto error; |
|
| 1186 |
- } |
|
| 1187 |
-#endif |
|
| 1188 |
- } |
|
| 1189 |
- break; |
|
| 1190 |
- case 0x51: /* STZr */ |
|
| 1191 |
- {
|
|
| 1192 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 1193 |
- Uint8 b = u->rst.dat[u->rst.ptr - 2]; |
|
| 1194 |
- poke8(u->ram.dat, a, b); |
|
| 1195 |
-#ifndef NO_STACK_CHECKS |
|
| 1196 |
- if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 1197 |
- u->rst.error = 1; |
|
| 1198 |
- goto error; |
|
| 1199 |
- } |
|
| 1200 |
-#endif |
|
| 1201 |
- u->rst.ptr -= 2; |
|
| 1202 |
- } |
|
| 1203 |
- break; |
|
| 1204 |
- case 0x52: /* LDRr */ |
|
| 1205 |
- {
|
|
| 1206 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 1207 |
- u->rst.dat[u->rst.ptr - 1] = peek8(u->ram.dat, u->ram.ptr + (Sint8)a); |
|
| 1208 |
-#ifndef NO_STACK_CHECKS |
|
| 1209 |
- if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
| 1210 |
- u->rst.error = 1; |
|
| 1211 |
- goto error; |
|
| 1212 |
- } |
|
| 1213 |
-#endif |
|
| 1214 |
- } |
|
| 1215 |
- break; |
|
| 1216 |
- case 0x53: /* STRr */ |
|
| 1217 |
- {
|
|
| 1218 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 1219 |
- Uint8 b = u->rst.dat[u->rst.ptr - 2]; |
|
| 1220 |
- poke8(u->ram.dat, u->ram.ptr + (Sint8)a, b); |
|
| 1221 |
-#ifndef NO_STACK_CHECKS |
|
| 1222 |
- if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 1223 |
- u->rst.error = 1; |
|
| 1224 |
- goto error; |
|
| 1225 |
- } |
|
| 1226 |
-#endif |
|
| 1227 |
- u->rst.ptr -= 2; |
|
| 1228 |
- } |
|
| 1229 |
- break; |
|
| 1230 |
- case 0x54: /* LDAr */ |
|
| 1231 |
- {
|
|
| 1232 |
- Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); |
|
| 1233 |
- u->rst.dat[u->rst.ptr - 2] = peek8(u->ram.dat, a); |
|
| 1234 |
-#ifndef NO_STACK_CHECKS |
|
| 1235 |
- if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 1236 |
- u->rst.error = 1; |
|
| 1237 |
- goto error; |
|
| 1238 |
- } |
|
| 1239 |
-#endif |
|
| 1240 |
- u->rst.ptr -= 1; |
|
| 1241 |
- } |
|
| 1242 |
- break; |
|
| 1243 |
- case 0x55: /* STAr */ |
|
| 1244 |
- {
|
|
| 1245 |
- Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); |
|
| 1246 |
- Uint8 b = u->rst.dat[u->rst.ptr - 3]; |
|
| 1247 |
- poke8(u->ram.dat, a, b); |
|
| 1248 |
-#ifndef NO_STACK_CHECKS |
|
| 1249 |
- if(__builtin_expect(u->rst.ptr < 3, 0)) {
|
|
| 1250 |
- u->rst.error = 1; |
|
| 1251 |
- goto error; |
|
| 1252 |
- } |
|
| 1253 |
-#endif |
|
| 1254 |
- u->rst.ptr -= 3; |
|
| 1255 |
- } |
|
| 1256 |
- break; |
|
| 1257 |
- case 0x56: /* DEIr */ |
|
| 1258 |
- {
|
|
| 1259 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 1260 |
- u->rst.dat[u->rst.ptr - 1] = devr8(&u->dev[a >> 4], a); |
|
| 1261 |
-#ifndef NO_STACK_CHECKS |
|
| 1262 |
- if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
| 1263 |
- u->rst.error = 1; |
|
| 1264 |
- goto error; |
|
| 1265 |
- } |
|
| 1266 |
-#endif |
|
| 1267 |
- } |
|
| 1268 |
- break; |
|
| 1269 |
- case 0x57: /* DEOr */ |
|
| 1270 |
- {
|
|
| 1271 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 1272 |
- devw8(&u->dev[a >> 4], a, b); |
|
| 1273 |
-#ifndef NO_STACK_CHECKS |
|
| 1274 |
- if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 1275 |
- u->rst.error = 1; |
|
| 1276 |
- goto error; |
|
| 1277 |
- } |
|
| 1278 |
-#endif |
|
| 1279 |
- u->rst.ptr -= 2; |
|
| 1280 |
- } |
|
| 1281 |
- break; |
|
| 1282 |
- case 0x58: /* ADDr */ |
|
| 1283 |
- {
|
|
| 1284 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 1285 |
- u->rst.dat[u->rst.ptr - 2] = b + a; |
|
| 1286 |
-#ifndef NO_STACK_CHECKS |
|
| 1287 |
- if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 1288 |
- u->rst.error = 1; |
|
| 1289 |
- goto error; |
|
| 1290 |
- } |
|
| 1291 |
-#endif |
|
| 1292 |
- u->rst.ptr -= 1; |
|
| 1293 |
- } |
|
| 1294 |
- break; |
|
| 1295 |
- case 0x59: /* SUBr */ |
|
| 1296 |
- {
|
|
| 1297 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 1298 |
- u->rst.dat[u->rst.ptr - 2] = b - a; |
|
| 1299 |
-#ifndef NO_STACK_CHECKS |
|
| 1300 |
- if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 1301 |
- u->rst.error = 1; |
|
| 1302 |
- goto error; |
|
| 1303 |
- } |
|
| 1304 |
-#endif |
|
| 1305 |
- u->rst.ptr -= 1; |
|
| 1306 |
- } |
|
| 1307 |
- break; |
|
| 1308 |
- case 0x5a: /* MULr */ |
|
| 1309 |
- {
|
|
| 1310 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 1311 |
- u->rst.dat[u->rst.ptr - 2] = b * a; |
|
| 1312 |
-#ifndef NO_STACK_CHECKS |
|
| 1313 |
- if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 1314 |
- u->rst.error = 1; |
|
| 1315 |
- goto error; |
|
| 1316 |
- } |
|
| 1317 |
-#endif |
|
| 1318 |
- u->rst.ptr -= 1; |
|
| 1319 |
- } |
|
| 1320 |
- break; |
|
| 1321 |
- case 0x5b: /* DIVr */ |
|
| 1322 |
- {
|
|
| 1323 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 1324 |
- if(a == 0) {
|
|
| 1325 |
- u->rst.error = 3; |
|
| 1326 |
-#ifndef NO_STACK_CHECKS |
|
| 1327 |
- goto error; |
|
| 1328 |
-#endif |
|
| 1329 |
- a = 1; |
|
| 1330 |
- } |
|
| 1331 |
- u->rst.dat[u->rst.ptr - 2] = b / a; |
|
| 1332 |
-#ifndef NO_STACK_CHECKS |
|
| 1333 |
- if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 1334 |
- u->rst.error = 1; |
|
| 1335 |
- goto error; |
|
| 1336 |
- } |
|
| 1337 |
-#endif |
|
| 1338 |
- u->rst.ptr -= 1; |
|
| 1339 |
- } |
|
| 1340 |
- break; |
|
| 1341 |
- case 0x5c: /* ANDr */ |
|
| 1342 |
- {
|
|
| 1343 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 1344 |
- u->rst.dat[u->rst.ptr - 2] = b & a; |
|
| 1345 |
-#ifndef NO_STACK_CHECKS |
|
| 1346 |
- if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 1347 |
- u->rst.error = 1; |
|
| 1348 |
- goto error; |
|
| 1349 |
- } |
|
| 1350 |
-#endif |
|
| 1351 |
- u->rst.ptr -= 1; |
|
| 1352 |
- } |
|
| 1353 |
- break; |
|
| 1354 |
- case 0x5d: /* ORAr */ |
|
| 1355 |
- {
|
|
| 1356 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 1357 |
- u->rst.dat[u->rst.ptr - 2] = b | a; |
|
| 1358 |
-#ifndef NO_STACK_CHECKS |
|
| 1359 |
- if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 1360 |
- u->rst.error = 1; |
|
| 1361 |
- goto error; |
|
| 1362 |
- } |
|
| 1363 |
-#endif |
|
| 1364 |
- u->rst.ptr -= 1; |
|
| 1365 |
- } |
|
| 1366 |
- break; |
|
| 1367 |
- case 0x5e: /* EORr */ |
|
| 1368 |
- {
|
|
| 1369 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 1370 |
- u->rst.dat[u->rst.ptr - 2] = b ^ a; |
|
| 1371 |
-#ifndef NO_STACK_CHECKS |
|
| 1372 |
- if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 1373 |
- u->rst.error = 1; |
|
| 1374 |
- goto error; |
|
| 1375 |
- } |
|
| 1376 |
-#endif |
|
| 1377 |
- u->rst.ptr -= 1; |
|
| 1378 |
- } |
|
| 1379 |
- break; |
|
| 1380 |
- case 0x5f: /* SFTr */ |
|
| 1381 |
- {
|
|
| 1382 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 1383 |
- u->rst.dat[u->rst.ptr - 2] = b >> (a & 0x0f) << ((a & 0xf0) >> 4); |
|
| 1384 |
-#ifndef NO_STACK_CHECKS |
|
| 1385 |
- if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 1386 |
- u->rst.error = 1; |
|
| 1387 |
- goto error; |
|
| 1388 |
- } |
|
| 1389 |
-#endif |
|
| 1390 |
- u->rst.ptr -= 1; |
|
| 1391 |
- } |
|
| 1392 |
- break; |
|
| 1393 |
- case 0x61: /* INC2r */ |
|
| 1394 |
- {
|
|
| 1395 |
- Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); |
|
| 1396 |
- u->rst.dat[u->rst.ptr - 2] = (a + 1) >> 8; |
|
| 1397 |
- u->rst.dat[u->rst.ptr - 1] = (a + 1) & 0xff; |
|
| 1398 |
-#ifndef NO_STACK_CHECKS |
|
| 1399 |
- if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 1400 |
- u->rst.error = 1; |
|
| 1401 |
- goto error; |
|
| 1402 |
- } |
|
| 1403 |
-#endif |
|
| 1404 |
- } |
|
| 1405 |
- break; |
|
| 1406 |
- case 0x62: /* POP2r */ |
|
| 1407 |
- {
|
|
| 1408 |
- (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); |
|
| 1409 |
-#ifndef NO_STACK_CHECKS |
|
| 1410 |
- if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 1411 |
- u->rst.error = 1; |
|
| 1412 |
- goto error; |
|
| 1413 |
- } |
|
| 1414 |
-#endif |
|
| 1415 |
- u->rst.ptr -= 2; |
|
| 1416 |
- } |
|
| 1417 |
- break; |
|
| 1418 |
- case 0x63: /* DUP2r */ |
|
| 1419 |
- {
|
|
| 1420 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 1421 |
- u->rst.dat[u->rst.ptr] = b; |
|
| 1422 |
- u->rst.dat[u->rst.ptr + 1] = a; |
|
| 1423 |
-#ifndef NO_STACK_CHECKS |
|
| 1424 |
- if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 1425 |
- u->rst.error = 1; |
|
| 1426 |
- goto error; |
|
| 1427 |
- } |
|
| 1428 |
- if(__builtin_expect(u->rst.ptr > 253, 0)) {
|
|
| 1429 |
- u->rst.error = 2; |
|
| 1430 |
- goto error; |
|
| 1431 |
- } |
|
| 1432 |
-#endif |
|
| 1433 |
- u->rst.ptr += 2; |
|
| 1434 |
- } |
|
| 1435 |
- break; |
|
| 1436 |
- case 0x64: /* NIP2r */ |
|
| 1437 |
- {
|
|
| 1438 |
- Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); |
|
| 1439 |
- (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); |
|
| 1440 |
- u->rst.dat[u->rst.ptr - 4] = a >> 8; |
|
| 1441 |
- u->rst.dat[u->rst.ptr - 3] = a & 0xff; |
|
| 1442 |
-#ifndef NO_STACK_CHECKS |
|
| 1443 |
- if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
| 1444 |
- u->rst.error = 1; |
|
| 1445 |
- goto error; |
|
| 1446 |
- } |
|
| 1447 |
-#endif |
|
| 1448 |
- u->rst.ptr -= 2; |
|
| 1449 |
- } |
|
| 1450 |
- break; |
|
| 1451 |
- case 0x65: /* SWP2r */ |
|
| 1452 |
- {
|
|
| 1453 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2], c = u->rst.dat[u->rst.ptr - 3], d = u->rst.dat[u->rst.ptr - 4]; |
|
| 1454 |
- u->rst.dat[u->rst.ptr - 4] = b; |
|
| 1455 |
- u->rst.dat[u->rst.ptr - 3] = a; |
|
| 1456 |
- u->rst.dat[u->rst.ptr - 2] = d; |
|
| 1457 |
- u->rst.dat[u->rst.ptr - 1] = c; |
|
| 1458 |
-#ifndef NO_STACK_CHECKS |
|
| 1459 |
- if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
| 1460 |
- u->rst.error = 1; |
|
| 1461 |
- goto error; |
|
| 1462 |
- } |
|
| 1463 |
-#endif |
|
| 1464 |
- } |
|
| 1465 |
- break; |
|
| 1466 |
- case 0x66: /* OVR2r */ |
|
| 1467 |
- {
|
|
| 1468 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2], c = u->rst.dat[u->rst.ptr - 3], d = u->rst.dat[u->rst.ptr - 4]; |
|
| 1469 |
- u->rst.dat[u->rst.ptr] = d; |
|
| 1470 |
- u->rst.dat[u->rst.ptr + 1] = c; |
|
| 1471 |
-#ifndef NO_STACK_CHECKS |
|
| 1472 |
- if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
| 1473 |
- u->rst.error = 1; |
|
| 1474 |
- goto error; |
|
| 1475 |
- } |
|
| 1476 |
- if(__builtin_expect(u->rst.ptr > 253, 0)) {
|
|
| 1477 |
- u->rst.error = 2; |
|
| 1478 |
- goto error; |
|
| 1479 |
- } |
|
| 1480 |
-#endif |
|
| 1481 |
- u->rst.ptr += 2; |
|
| 1482 |
- } |
|
| 1483 |
- break; |
|
| 1484 |
- case 0x67: /* ROT2r */ |
|
| 1485 |
- {
|
|
| 1486 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2], c = u->rst.dat[u->rst.ptr - 3], d = u->rst.dat[u->rst.ptr - 4], e = u->rst.dat[u->rst.ptr - 5], f = u->rst.dat[u->rst.ptr - 6]; |
|
| 1487 |
- u->rst.dat[u->rst.ptr - 6] = d; |
|
| 1488 |
- u->rst.dat[u->rst.ptr - 5] = c; |
|
| 1489 |
- u->rst.dat[u->rst.ptr - 4] = b; |
|
| 1490 |
- u->rst.dat[u->rst.ptr - 3] = a; |
|
| 1491 |
- u->rst.dat[u->rst.ptr - 2] = f; |
|
| 1492 |
- u->rst.dat[u->rst.ptr - 1] = e; |
|
| 1493 |
-#ifndef NO_STACK_CHECKS |
|
| 1494 |
- if(__builtin_expect(u->rst.ptr < 6, 0)) {
|
|
| 1495 |
- u->rst.error = 1; |
|
| 1496 |
- goto error; |
|
| 1497 |
- } |
|
| 1498 |
-#endif |
|
| 1499 |
- } |
|
| 1500 |
- break; |
|
| 1501 |
- case 0x68: /* EQU2r */ |
|
| 1502 |
- {
|
|
| 1503 |
- Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); |
|
| 1504 |
- u->rst.dat[u->rst.ptr - 4] = b == a; |
|
| 1505 |
-#ifndef NO_STACK_CHECKS |
|
| 1506 |
- if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
| 1507 |
- u->rst.error = 1; |
|
| 1508 |
- goto error; |
|
| 1509 |
- } |
|
| 1510 |
-#endif |
|
| 1511 |
- u->rst.ptr -= 3; |
|
| 1512 |
- } |
|
| 1513 |
- break; |
|
| 1514 |
- case 0x69: /* NEQ2r */ |
|
| 1515 |
- {
|
|
| 1516 |
- Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); |
|
| 1517 |
- u->rst.dat[u->rst.ptr - 4] = b != a; |
|
| 1518 |
-#ifndef NO_STACK_CHECKS |
|
| 1519 |
- if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
| 1520 |
- u->rst.error = 1; |
|
| 1521 |
- goto error; |
|
| 1522 |
- } |
|
| 1523 |
-#endif |
|
| 1524 |
- u->rst.ptr -= 3; |
|
| 1525 |
- } |
|
| 1526 |
- break; |
|
| 1527 |
- case 0x6a: /* GTH2r */ |
|
| 1528 |
- {
|
|
| 1529 |
- Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); |
|
| 1530 |
- u->rst.dat[u->rst.ptr - 4] = b > a; |
|
| 1531 |
-#ifndef NO_STACK_CHECKS |
|
| 1532 |
- if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
| 1533 |
- u->rst.error = 1; |
|
| 1534 |
- goto error; |
|
| 1535 |
- } |
|
| 1536 |
-#endif |
|
| 1537 |
- u->rst.ptr -= 3; |
|
| 1538 |
- } |
|
| 1539 |
- break; |
|
| 1540 |
- case 0x6b: /* LTH2r */ |
|
| 1541 |
- {
|
|
| 1542 |
- Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); |
|
| 1543 |
- u->rst.dat[u->rst.ptr - 4] = b < a; |
|
| 1544 |
-#ifndef NO_STACK_CHECKS |
|
| 1545 |
- if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
| 1546 |
- u->rst.error = 1; |
|
| 1547 |
- goto error; |
|
| 1548 |
- } |
|
| 1549 |
-#endif |
|
| 1550 |
- u->rst.ptr -= 3; |
|
| 1551 |
- } |
|
| 1552 |
- break; |
|
| 1553 |
- case 0x6c: /* JMP2r */ |
|
| 1554 |
- {
|
|
| 1555 |
- u->ram.ptr = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); |
|
| 1556 |
-#ifndef NO_STACK_CHECKS |
|
| 1557 |
- if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 1558 |
- u->rst.error = 1; |
|
| 1559 |
- goto error; |
|
| 1560 |
- } |
|
| 1561 |
-#endif |
|
| 1562 |
- u->rst.ptr -= 2; |
|
| 1563 |
- } |
|
| 1564 |
- break; |
|
| 1565 |
- case 0x6d: /* JCN2r */ |
|
| 1566 |
- {
|
|
| 1567 |
- Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); |
|
| 1568 |
- if(u->rst.dat[u->rst.ptr - 3]) u->ram.ptr = a; |
|
| 1569 |
-#ifndef NO_STACK_CHECKS |
|
| 1570 |
- if(__builtin_expect(u->rst.ptr < 3, 0)) {
|
|
| 1571 |
- u->rst.error = 1; |
|
| 1572 |
- goto error; |
|
| 1573 |
- } |
|
| 1574 |
-#endif |
|
| 1575 |
- u->rst.ptr -= 3; |
|
| 1576 |
- } |
|
| 1577 |
- break; |
|
| 1578 |
- case 0x6e: /* JSR2r */ |
|
| 1579 |
- {
|
|
| 1580 |
- u->wst.dat[u->wst.ptr] = u->ram.ptr >> 8; |
|
| 1581 |
- u->wst.dat[u->wst.ptr + 1] = u->ram.ptr & 0xff; |
|
| 1582 |
- u->ram.ptr = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); |
|
| 1583 |
-#ifndef NO_STACK_CHECKS |
|
| 1584 |
- if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 1585 |
- u->rst.error = 1; |
|
| 1586 |
- goto error; |
|
| 1587 |
- } |
|
| 1588 |
-#endif |
|
| 1589 |
- u->rst.ptr -= 2; |
|
| 1590 |
-#ifndef NO_STACK_CHECKS |
|
| 1591 |
- if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
| 1592 |
- u->wst.error = 2; |
|
| 1593 |
- goto error; |
|
| 1594 |
- } |
|
| 1595 |
-#endif |
|
| 1596 |
- u->wst.ptr += 2; |
|
| 1597 |
- } |
|
| 1598 |
- break; |
|
| 1599 |
- case 0x6f: /* STH2r */ |
|
| 1600 |
- {
|
|
| 1601 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 1602 |
- u->wst.dat[u->wst.ptr] = b; |
|
| 1603 |
- u->wst.dat[u->wst.ptr + 1] = a; |
|
| 1604 |
-#ifndef NO_STACK_CHECKS |
|
| 1605 |
- if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 1606 |
- u->rst.error = 1; |
|
| 1607 |
- goto error; |
|
| 1608 |
- } |
|
| 1609 |
-#endif |
|
| 1610 |
- u->rst.ptr -= 2; |
|
| 1611 |
-#ifndef NO_STACK_CHECKS |
|
| 1612 |
- if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
| 1613 |
- u->wst.error = 2; |
|
| 1614 |
- goto error; |
|
| 1615 |
- } |
|
| 1616 |
-#endif |
|
| 1617 |
- u->wst.ptr += 2; |
|
| 1618 |
- } |
|
| 1619 |
- break; |
|
| 1620 |
- case 0x70: /* LDZ2r */ |
|
| 1621 |
- {
|
|
| 1622 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 1623 |
- u->rst.dat[u->rst.ptr - 1] = peek8(u->ram.dat, a); |
|
| 1624 |
- u->rst.dat[u->rst.ptr] = peek8(u->ram.dat, a + 1); |
|
| 1625 |
-#ifndef NO_STACK_CHECKS |
|
| 1626 |
- if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
| 1627 |
- u->rst.error = 1; |
|
| 1628 |
- goto error; |
|
| 1629 |
- } |
|
| 1630 |
- if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
| 1631 |
- u->rst.error = 2; |
|
| 1632 |
- goto error; |
|
| 1633 |
- } |
|
| 1634 |
-#endif |
|
| 1635 |
- u->rst.ptr += 1; |
|
| 1636 |
- } |
|
| 1637 |
- break; |
|
| 1638 |
- case 0x71: /* STZ2r */ |
|
| 1639 |
- {
|
|
| 1640 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 1641 |
- Uint16 b = (u->rst.dat[u->rst.ptr - 2] | (u->rst.dat[u->rst.ptr - 3] << 8)); |
|
| 1642 |
- poke16(u->ram.dat, a, b); |
|
| 1643 |
-#ifndef NO_STACK_CHECKS |
|
| 1644 |
- if(__builtin_expect(u->rst.ptr < 3, 0)) {
|
|
| 1645 |
- u->rst.error = 1; |
|
| 1646 |
- goto error; |
|
| 1647 |
- } |
|
| 1648 |
-#endif |
|
| 1649 |
- u->rst.ptr -= 3; |
|
| 1650 |
- } |
|
| 1651 |
- break; |
|
| 1652 |
- case 0x72: /* LDR2r */ |
|
| 1653 |
- {
|
|
| 1654 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 1655 |
- u->rst.dat[u->rst.ptr - 1] = peek8(u->ram.dat, u->ram.ptr + (Sint8)a); |
|
| 1656 |
- u->rst.dat[u->rst.ptr] = peek8(u->ram.dat, u->ram.ptr + (Sint8)a + 1); |
|
| 1657 |
-#ifndef NO_STACK_CHECKS |
|
| 1658 |
- if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
| 1659 |
- u->rst.error = 1; |
|
| 1660 |
- goto error; |
|
| 1661 |
- } |
|
| 1662 |
- if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
| 1663 |
- u->rst.error = 2; |
|
| 1664 |
- goto error; |
|
| 1665 |
- } |
|
| 1666 |
-#endif |
|
| 1667 |
- u->rst.ptr += 1; |
|
| 1668 |
- } |
|
| 1669 |
- break; |
|
| 1670 |
- case 0x73: /* STR2r */ |
|
| 1671 |
- {
|
|
| 1672 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 1673 |
- Uint16 b = (u->rst.dat[u->rst.ptr - 2] | (u->rst.dat[u->rst.ptr - 3] << 8)); |
|
| 1674 |
- poke16(u->ram.dat, u->ram.ptr + (Sint8)a, b); |
|
| 1675 |
-#ifndef NO_STACK_CHECKS |
|
| 1676 |
- if(__builtin_expect(u->rst.ptr < 3, 0)) {
|
|
| 1677 |
- u->rst.error = 1; |
|
| 1678 |
- goto error; |
|
| 1679 |
- } |
|
| 1680 |
-#endif |
|
| 1681 |
- u->rst.ptr -= 3; |
|
| 1682 |
- } |
|
| 1683 |
- break; |
|
| 1684 |
- case 0x74: /* LDA2r */ |
|
| 1685 |
- {
|
|
| 1686 |
- Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); |
|
| 1687 |
- u->rst.dat[u->rst.ptr - 2] = peek8(u->ram.dat, a); |
|
| 1688 |
- u->rst.dat[u->rst.ptr - 1] = peek8(u->ram.dat, a + 1); |
|
| 1689 |
-#ifndef NO_STACK_CHECKS |
|
| 1690 |
- if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 1691 |
- u->rst.error = 1; |
|
| 1692 |
- goto error; |
|
| 1693 |
- } |
|
| 1694 |
-#endif |
|
| 1695 |
- } |
|
| 1696 |
- break; |
|
| 1697 |
- case 0x75: /* STA2r */ |
|
| 1698 |
- {
|
|
| 1699 |
- Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); |
|
| 1700 |
- Uint16 b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); |
|
| 1701 |
- poke16(u->ram.dat, a, b); |
|
| 1702 |
-#ifndef NO_STACK_CHECKS |
|
| 1703 |
- if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
| 1704 |
- u->rst.error = 1; |
|
| 1705 |
- goto error; |
|
| 1706 |
- } |
|
| 1707 |
-#endif |
|
| 1708 |
- u->rst.ptr -= 4; |
|
| 1709 |
- } |
|
| 1710 |
- break; |
|
| 1711 |
- case 0x76: /* DEI2r */ |
|
| 1712 |
- {
|
|
| 1713 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 1714 |
- u->rst.dat[u->rst.ptr - 1] = devr8(&u->dev[a >> 4], a); |
|
| 1715 |
- u->rst.dat[u->rst.ptr] = devr8(&u->dev[a >> 4], a + 1); |
|
| 1716 |
-#ifndef NO_STACK_CHECKS |
|
| 1717 |
- if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
| 1718 |
- u->rst.error = 1; |
|
| 1719 |
- goto error; |
|
| 1720 |
- } |
|
| 1721 |
- if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
| 1722 |
- u->rst.error = 2; |
|
| 1723 |
- goto error; |
|
| 1724 |
- } |
|
| 1725 |
-#endif |
|
| 1726 |
- u->rst.ptr += 1; |
|
| 1727 |
- } |
|
| 1728 |
- break; |
|
| 1729 |
- case 0x77: /* DEO2r */ |
|
| 1730 |
- {
|
|
| 1731 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 1732 |
- Uint16 b = (u->rst.dat[u->rst.ptr - 2] | (u->rst.dat[u->rst.ptr - 3] << 8)); |
|
| 1733 |
- devw16(&u->dev[a >> 4], a, b); |
|
| 1734 |
-#ifndef NO_STACK_CHECKS |
|
| 1735 |
- if(__builtin_expect(u->rst.ptr < 3, 0)) {
|
|
| 1736 |
- u->rst.error = 1; |
|
| 1737 |
- goto error; |
|
| 1738 |
- } |
|
| 1739 |
-#endif |
|
| 1740 |
- u->rst.ptr -= 3; |
|
| 1741 |
- } |
|
| 1742 |
- break; |
|
| 1743 |
- case 0x78: /* ADD2r */ |
|
| 1744 |
- {
|
|
| 1745 |
- Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); |
|
| 1746 |
- u->rst.dat[u->rst.ptr - 4] = (b + a) >> 8; |
|
| 1747 |
- u->rst.dat[u->rst.ptr - 3] = (b + a) & 0xff; |
|
| 1748 |
-#ifndef NO_STACK_CHECKS |
|
| 1749 |
- if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
| 1750 |
- u->rst.error = 1; |
|
| 1751 |
- goto error; |
|
| 1752 |
- } |
|
| 1753 |
-#endif |
|
| 1754 |
- u->rst.ptr -= 2; |
|
| 1755 |
- } |
|
| 1756 |
- break; |
|
| 1757 |
- case 0x79: /* SUB2r */ |
|
| 1758 |
- {
|
|
| 1759 |
- Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); |
|
| 1760 |
- u->rst.dat[u->rst.ptr - 4] = (b - a) >> 8; |
|
| 1761 |
- u->rst.dat[u->rst.ptr - 3] = (b - a) & 0xff; |
|
| 1762 |
-#ifndef NO_STACK_CHECKS |
|
| 1763 |
- if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
| 1764 |
- u->rst.error = 1; |
|
| 1765 |
- goto error; |
|
| 1766 |
- } |
|
| 1767 |
-#endif |
|
| 1768 |
- u->rst.ptr -= 2; |
|
| 1769 |
- } |
|
| 1770 |
- break; |
|
| 1771 |
- case 0x7a: /* MUL2r */ |
|
| 1772 |
- {
|
|
| 1773 |
- Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); |
|
| 1774 |
- u->rst.dat[u->rst.ptr - 4] = (b * a) >> 8; |
|
| 1775 |
- u->rst.dat[u->rst.ptr - 3] = (b * a) & 0xff; |
|
| 1776 |
-#ifndef NO_STACK_CHECKS |
|
| 1777 |
- if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
| 1778 |
- u->rst.error = 1; |
|
| 1779 |
- goto error; |
|
| 1780 |
- } |
|
| 1781 |
-#endif |
|
| 1782 |
- u->rst.ptr -= 2; |
|
| 1783 |
- } |
|
| 1784 |
- break; |
|
| 1785 |
- case 0x7b: /* DIV2r */ |
|
| 1786 |
- {
|
|
| 1787 |
- Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); |
|
| 1788 |
- if(a == 0) {
|
|
| 1789 |
- u->rst.error = 3; |
|
| 1790 |
-#ifndef NO_STACK_CHECKS |
|
| 1791 |
- goto error; |
|
| 1792 |
-#endif |
|
| 1793 |
- a = 1; |
|
| 1794 |
- } |
|
| 1795 |
- u->rst.dat[u->rst.ptr - 4] = (b / a) >> 8; |
|
| 1796 |
- u->rst.dat[u->rst.ptr - 3] = (b / a) & 0xff; |
|
| 1797 |
-#ifndef NO_STACK_CHECKS |
|
| 1798 |
- if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
| 1799 |
- u->rst.error = 1; |
|
| 1800 |
- goto error; |
|
| 1801 |
- } |
|
| 1802 |
-#endif |
|
| 1803 |
- u->rst.ptr -= 2; |
|
| 1804 |
- } |
|
| 1805 |
- break; |
|
| 1806 |
- case 0x7c: /* AND2r */ |
|
| 1807 |
- {
|
|
| 1808 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2], c = u->rst.dat[u->rst.ptr - 3], d = u->rst.dat[u->rst.ptr - 4]; |
|
| 1809 |
- u->rst.dat[u->rst.ptr - 4] = d & b; |
|
| 1810 |
- u->rst.dat[u->rst.ptr - 3] = c & a; |
|
| 1811 |
-#ifndef NO_STACK_CHECKS |
|
| 1812 |
- if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
| 1813 |
- u->rst.error = 1; |
|
| 1814 |
- goto error; |
|
| 1815 |
- } |
|
| 1816 |
-#endif |
|
| 1817 |
- u->rst.ptr -= 2; |
|
| 1818 |
- } |
|
| 1819 |
- break; |
|
| 1820 |
- case 0x7d: /* ORA2r */ |
|
| 1821 |
- {
|
|
| 1822 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2], c = u->rst.dat[u->rst.ptr - 3], d = u->rst.dat[u->rst.ptr - 4]; |
|
| 1823 |
- u->rst.dat[u->rst.ptr - 4] = d | b; |
|
| 1824 |
- u->rst.dat[u->rst.ptr - 3] = c | a; |
|
| 1825 |
-#ifndef NO_STACK_CHECKS |
|
| 1826 |
- if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
| 1827 |
- u->rst.error = 1; |
|
| 1828 |
- goto error; |
|
| 1829 |
- } |
|
| 1830 |
-#endif |
|
| 1831 |
- u->rst.ptr -= 2; |
|
| 1832 |
- } |
|
| 1833 |
- break; |
|
| 1834 |
- case 0x7e: /* EOR2r */ |
|
| 1835 |
- {
|
|
| 1836 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2], c = u->rst.dat[u->rst.ptr - 3], d = u->rst.dat[u->rst.ptr - 4]; |
|
| 1837 |
- u->rst.dat[u->rst.ptr - 4] = d ^ b; |
|
| 1838 |
- u->rst.dat[u->rst.ptr - 3] = c ^ a; |
|
| 1839 |
-#ifndef NO_STACK_CHECKS |
|
| 1840 |
- if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
| 1841 |
- u->rst.error = 1; |
|
| 1842 |
- goto error; |
|
| 1843 |
- } |
|
| 1844 |
-#endif |
|
| 1845 |
- u->rst.ptr -= 2; |
|
| 1846 |
- } |
|
| 1847 |
- break; |
|
| 1848 |
- case 0x7f: /* SFT2r */ |
|
| 1849 |
- {
|
|
| 1850 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 1851 |
- Uint16 b = (u->rst.dat[u->rst.ptr - 2] | (u->rst.dat[u->rst.ptr - 3] << 8)); |
|
| 1852 |
- u->rst.dat[u->rst.ptr - 3] = (b >> (a & 0x0f) << ((a & 0xf0) >> 4)) >> 8; |
|
| 1853 |
- u->rst.dat[u->rst.ptr - 2] = (b >> (a & 0x0f) << ((a & 0xf0) >> 4)) & 0xff; |
|
| 1854 |
-#ifndef NO_STACK_CHECKS |
|
| 1855 |
- if(__builtin_expect(u->rst.ptr < 3, 0)) {
|
|
| 1856 |
- u->rst.error = 1; |
|
| 1857 |
- goto error; |
|
| 1858 |
- } |
|
| 1859 |
-#endif |
|
| 1860 |
- u->rst.ptr -= 1; |
|
| 1861 |
- } |
|
| 1862 |
- break; |
|
| 1863 |
- case 0x80: /* LIT */ |
|
| 1864 |
- {
|
|
| 1865 |
- u->wst.dat[u->wst.ptr] = peek8(u->ram.dat, u->ram.ptr++); |
|
| 1866 |
-#ifndef NO_STACK_CHECKS |
|
| 1867 |
- if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
| 1868 |
- u->wst.error = 2; |
|
| 1869 |
- goto error; |
|
| 1870 |
- } |
|
| 1871 |
-#endif |
|
| 1872 |
- u->wst.ptr += 1; |
|
| 1873 |
- } |
|
| 1874 |
- break; |
|
| 1875 |
- case 0x81: /* INCk */ |
|
| 1876 |
- {
|
|
| 1877 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 1878 |
- u->wst.dat[u->wst.ptr] = a + 1; |
|
| 1879 |
-#ifndef NO_STACK_CHECKS |
|
| 1880 |
- if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
| 1881 |
- u->wst.error = 1; |
|
| 1882 |
- goto error; |
|
| 1883 |
- } |
|
| 1884 |
- if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
| 1885 |
- u->wst.error = 2; |
|
| 1886 |
- goto error; |
|
| 1887 |
- } |
|
| 1888 |
-#endif |
|
| 1889 |
- u->wst.ptr += 1; |
|
| 1890 |
- } |
|
| 1891 |
- break; |
|
| 1892 |
- case 0x82: /* POPk */ |
|
| 1893 |
- {
|
|
| 1894 |
- u->wst.dat[u->wst.ptr - 1]; |
|
| 1895 |
-#ifndef NO_STACK_CHECKS |
|
| 1896 |
- if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
| 1897 |
- u->wst.error = 1; |
|
| 1898 |
- goto error; |
|
| 1899 |
- } |
|
| 1900 |
-#endif |
|
| 1901 |
- } |
|
| 1902 |
- break; |
|
| 1903 |
- case 0x83: /* DUPk */ |
|
| 1904 |
- {
|
|
| 1905 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 1906 |
- u->wst.dat[u->wst.ptr] = a; |
|
| 1907 |
- u->wst.dat[u->wst.ptr + 1] = a; |
|
| 1908 |
-#ifndef NO_STACK_CHECKS |
|
| 1909 |
- if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
| 1910 |
- u->wst.error = 1; |
|
| 1911 |
- goto error; |
|
| 1912 |
- } |
|
| 1913 |
- if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
| 1914 |
- u->wst.error = 2; |
|
| 1915 |
- goto error; |
|
| 1916 |
- } |
|
| 1917 |
-#endif |
|
| 1918 |
- u->wst.ptr += 2; |
|
| 1919 |
- } |
|
| 1920 |
- break; |
|
| 1921 |
- case 0x84: /* NIPk */ |
|
| 1922 |
- {
|
|
| 1923 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 1924 |
- u->wst.dat[u->wst.ptr - 2]; |
|
| 1925 |
- u->wst.dat[u->wst.ptr] = a; |
|
| 1926 |
-#ifndef NO_STACK_CHECKS |
|
| 1927 |
- if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 1928 |
- u->wst.error = 1; |
|
| 1929 |
- goto error; |
|
| 1930 |
- } |
|
| 1931 |
- if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
| 1932 |
- u->wst.error = 2; |
|
| 1933 |
- goto error; |
|
| 1934 |
- } |
|
| 1935 |
-#endif |
|
| 1936 |
- u->wst.ptr += 1; |
|
| 1937 |
- } |
|
| 1938 |
- break; |
|
| 1939 |
- case 0x85: /* SWPk */ |
|
| 1940 |
- {
|
|
| 1941 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 1942 |
- u->wst.dat[u->wst.ptr] = a; |
|
| 1943 |
- u->wst.dat[u->wst.ptr + 1] = b; |
|
| 1944 |
-#ifndef NO_STACK_CHECKS |
|
| 1945 |
- if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 1946 |
- u->wst.error = 1; |
|
| 1947 |
- goto error; |
|
| 1948 |
- } |
|
| 1949 |
- if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
| 1950 |
- u->wst.error = 2; |
|
| 1951 |
- goto error; |
|
| 1952 |
- } |
|
| 1953 |
-#endif |
|
| 1954 |
- u->wst.ptr += 2; |
|
| 1955 |
- } |
|
| 1956 |
- break; |
|
| 1957 |
- case 0x86: /* OVRk */ |
|
| 1958 |
- {
|
|
| 1959 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 1960 |
- u->wst.dat[u->wst.ptr] = b; |
|
| 1961 |
- u->wst.dat[u->wst.ptr + 1] = a; |
|
| 1962 |
- u->wst.dat[u->wst.ptr + 2] = b; |
|
| 1963 |
-#ifndef NO_STACK_CHECKS |
|
| 1964 |
- if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 1965 |
- u->wst.error = 1; |
|
| 1966 |
- goto error; |
|
| 1967 |
- } |
|
| 1968 |
- if(__builtin_expect(u->wst.ptr > 252, 0)) {
|
|
| 1969 |
- u->wst.error = 2; |
|
| 1970 |
- goto error; |
|
| 1971 |
- } |
|
| 1972 |
-#endif |
|
| 1973 |
- u->wst.ptr += 3; |
|
| 1974 |
- } |
|
| 1975 |
- break; |
|
| 1976 |
- case 0x87: /* ROTk */ |
|
| 1977 |
- {
|
|
| 1978 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2], c = u->wst.dat[u->wst.ptr - 3]; |
|
| 1979 |
- u->wst.dat[u->wst.ptr] = b; |
|
| 1980 |
- u->wst.dat[u->wst.ptr + 1] = a; |
|
| 1981 |
- u->wst.dat[u->wst.ptr + 2] = c; |
|
| 1982 |
-#ifndef NO_STACK_CHECKS |
|
| 1983 |
- if(__builtin_expect(u->wst.ptr < 3, 0)) {
|
|
| 1984 |
- u->wst.error = 1; |
|
| 1985 |
- goto error; |
|
| 1986 |
- } |
|
| 1987 |
- if(__builtin_expect(u->wst.ptr > 252, 0)) {
|
|
| 1988 |
- u->wst.error = 2; |
|
| 1989 |
- goto error; |
|
| 1990 |
- } |
|
| 1991 |
-#endif |
|
| 1992 |
- u->wst.ptr += 3; |
|
| 1993 |
- } |
|
| 1994 |
- break; |
|
| 1995 |
- case 0x88: /* EQUk */ |
|
| 1996 |
- {
|
|
| 1997 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 1998 |
- u->wst.dat[u->wst.ptr] = b == a; |
|
| 1999 |
-#ifndef NO_STACK_CHECKS |
|
| 2000 |
- if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 2001 |
- u->wst.error = 1; |
|
| 2002 |
- goto error; |
|
| 2003 |
- } |
|
| 2004 |
- if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
| 2005 |
- u->wst.error = 2; |
|
| 2006 |
- goto error; |
|
| 2007 |
- } |
|
| 2008 |
-#endif |
|
| 2009 |
- u->wst.ptr += 1; |
|
| 2010 |
- } |
|
| 2011 |
- break; |
|
| 2012 |
- case 0x89: /* NEQk */ |
|
| 2013 |
- {
|
|
| 2014 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 2015 |
- u->wst.dat[u->wst.ptr] = b != a; |
|
| 2016 |
-#ifndef NO_STACK_CHECKS |
|
| 2017 |
- if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 2018 |
- u->wst.error = 1; |
|
| 2019 |
- goto error; |
|
| 2020 |
- } |
|
| 2021 |
- if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
| 2022 |
- u->wst.error = 2; |
|
| 2023 |
- goto error; |
|
| 2024 |
- } |
|
| 2025 |
-#endif |
|
| 2026 |
- u->wst.ptr += 1; |
|
| 2027 |
- } |
|
| 2028 |
- break; |
|
| 2029 |
- case 0x8a: /* GTHk */ |
|
| 2030 |
- {
|
|
| 2031 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 2032 |
- u->wst.dat[u->wst.ptr] = b > a; |
|
| 2033 |
-#ifndef NO_STACK_CHECKS |
|
| 2034 |
- if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 2035 |
- u->wst.error = 1; |
|
| 2036 |
- goto error; |
|
| 2037 |
- } |
|
| 2038 |
- if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
| 2039 |
- u->wst.error = 2; |
|
| 2040 |
- goto error; |
|
| 2041 |
- } |
|
| 2042 |
-#endif |
|
| 2043 |
- u->wst.ptr += 1; |
|
| 2044 |
- } |
|
| 2045 |
- break; |
|
| 2046 |
- case 0x8b: /* LTHk */ |
|
| 2047 |
- {
|
|
| 2048 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 2049 |
- u->wst.dat[u->wst.ptr] = b < a; |
|
| 2050 |
-#ifndef NO_STACK_CHECKS |
|
| 2051 |
- if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 2052 |
- u->wst.error = 1; |
|
| 2053 |
- goto error; |
|
| 2054 |
- } |
|
| 2055 |
- if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
| 2056 |
- u->wst.error = 2; |
|
| 2057 |
- goto error; |
|
| 2058 |
- } |
|
| 2059 |
-#endif |
|
| 2060 |
- u->wst.ptr += 1; |
|
| 2061 |
- } |
|
| 2062 |
- break; |
|
| 2063 |
- case 0x8c: /* JMPk */ |
|
| 2064 |
- {
|
|
| 2065 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 2066 |
- u->ram.ptr += (Sint8)a; |
|
| 2067 |
-#ifndef NO_STACK_CHECKS |
|
| 2068 |
- if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
| 2069 |
- u->wst.error = 1; |
|
| 2070 |
- goto error; |
|
| 2071 |
- } |
|
| 2072 |
-#endif |
|
| 2073 |
- } |
|
| 2074 |
- break; |
|
| 2075 |
- case 0x8d: /* JCNk */ |
|
| 2076 |
- {
|
|
| 2077 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 2078 |
- if(u->wst.dat[u->wst.ptr - 2]) u->ram.ptr += (Sint8)a; |
|
| 2079 |
-#ifndef NO_STACK_CHECKS |
|
| 2080 |
- if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 2081 |
- u->wst.error = 1; |
|
| 2082 |
- goto error; |
|
| 2083 |
- } |
|
| 2084 |
-#endif |
|
| 2085 |
- } |
|
| 2086 |
- break; |
|
| 2087 |
- case 0x8e: /* JSRk */ |
|
| 2088 |
- {
|
|
| 2089 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 2090 |
- u->rst.dat[u->rst.ptr] = u->ram.ptr >> 8; |
|
| 2091 |
- u->rst.dat[u->rst.ptr + 1] = u->ram.ptr & 0xff; |
|
| 2092 |
- u->ram.ptr += (Sint8)a; |
|
| 2093 |
-#ifndef NO_STACK_CHECKS |
|
| 2094 |
- if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
| 2095 |
- u->wst.error = 1; |
|
| 2096 |
- goto error; |
|
| 2097 |
- } |
|
| 2098 |
- if(__builtin_expect(u->rst.ptr > 253, 0)) {
|
|
| 2099 |
- u->rst.error = 2; |
|
| 2100 |
- goto error; |
|
| 2101 |
- } |
|
| 2102 |
-#endif |
|
| 2103 |
- u->rst.ptr += 2; |
|
| 2104 |
- } |
|
| 2105 |
- break; |
|
| 2106 |
- case 0x8f: /* STHk */ |
|
| 2107 |
- {
|
|
| 2108 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 2109 |
- u->rst.dat[u->rst.ptr] = a; |
|
| 2110 |
-#ifndef NO_STACK_CHECKS |
|
| 2111 |
- if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
| 2112 |
- u->wst.error = 1; |
|
| 2113 |
- goto error; |
|
| 2114 |
- } |
|
| 2115 |
- if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
| 2116 |
- u->rst.error = 2; |
|
| 2117 |
- goto error; |
|
| 2118 |
- } |
|
| 2119 |
-#endif |
|
| 2120 |
- u->rst.ptr += 1; |
|
| 2121 |
- } |
|
| 2122 |
- break; |
|
| 2123 |
- case 0x90: /* LDZk */ |
|
| 2124 |
- {
|
|
| 2125 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 2126 |
- u->wst.dat[u->wst.ptr] = peek8(u->ram.dat, a); |
|
| 2127 |
-#ifndef NO_STACK_CHECKS |
|
| 2128 |
- if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
| 2129 |
- u->wst.error = 1; |
|
| 2130 |
- goto error; |
|
| 2131 |
- } |
|
| 2132 |
- if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
| 2133 |
- u->wst.error = 2; |
|
| 2134 |
- goto error; |
|
| 2135 |
- } |
|
| 2136 |
-#endif |
|
| 2137 |
- u->wst.ptr += 1; |
|
| 2138 |
- } |
|
| 2139 |
- break; |
|
| 2140 |
- case 0x91: /* STZk */ |
|
| 2141 |
- {
|
|
| 2142 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 2143 |
- Uint8 b = u->wst.dat[u->wst.ptr - 2]; |
|
| 2144 |
- poke8(u->ram.dat, a, b); |
|
| 2145 |
-#ifndef NO_STACK_CHECKS |
|
| 2146 |
- if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 2147 |
- u->wst.error = 1; |
|
| 2148 |
- goto error; |
|
| 2149 |
- } |
|
| 2150 |
-#endif |
|
| 2151 |
- } |
|
| 2152 |
- break; |
|
| 2153 |
- case 0x92: /* LDRk */ |
|
| 2154 |
- {
|
|
| 2155 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 2156 |
- u->wst.dat[u->wst.ptr] = peek8(u->ram.dat, u->ram.ptr + (Sint8)a); |
|
| 2157 |
-#ifndef NO_STACK_CHECKS |
|
| 2158 |
- if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
| 2159 |
- u->wst.error = 1; |
|
| 2160 |
- goto error; |
|
| 2161 |
- } |
|
| 2162 |
- if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
| 2163 |
- u->wst.error = 2; |
|
| 2164 |
- goto error; |
|
| 2165 |
- } |
|
| 2166 |
-#endif |
|
| 2167 |
- u->wst.ptr += 1; |
|
| 2168 |
- } |
|
| 2169 |
- break; |
|
| 2170 |
- case 0x93: /* STRk */ |
|
| 2171 |
- {
|
|
| 2172 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 2173 |
- Uint8 b = u->wst.dat[u->wst.ptr - 2]; |
|
| 2174 |
- poke8(u->ram.dat, u->ram.ptr + (Sint8)a, b); |
|
| 2175 |
-#ifndef NO_STACK_CHECKS |
|
| 2176 |
- if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 2177 |
- u->wst.error = 1; |
|
| 2178 |
- goto error; |
|
| 2179 |
- } |
|
| 2180 |
-#endif |
|
| 2181 |
- } |
|
| 2182 |
- break; |
|
| 2183 |
- case 0x94: /* LDAk */ |
|
| 2184 |
- {
|
|
| 2185 |
- Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); |
|
| 2186 |
- u->wst.dat[u->wst.ptr] = peek8(u->ram.dat, a); |
|
| 2187 |
-#ifndef NO_STACK_CHECKS |
|
| 2188 |
- if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 2189 |
- u->wst.error = 1; |
|
| 2190 |
- goto error; |
|
| 2191 |
- } |
|
| 2192 |
- if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
| 2193 |
- u->wst.error = 2; |
|
| 2194 |
- goto error; |
|
| 2195 |
- } |
|
| 2196 |
-#endif |
|
| 2197 |
- u->wst.ptr += 1; |
|
| 2198 |
- } |
|
| 2199 |
- break; |
|
| 2200 |
- case 0x95: /* STAk */ |
|
| 2201 |
- {
|
|
| 2202 |
- Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); |
|
| 2203 |
- Uint8 b = u->wst.dat[u->wst.ptr - 3]; |
|
| 2204 |
- poke8(u->ram.dat, a, b); |
|
| 2205 |
-#ifndef NO_STACK_CHECKS |
|
| 2206 |
- if(__builtin_expect(u->wst.ptr < 3, 0)) {
|
|
| 2207 |
- u->wst.error = 1; |
|
| 2208 |
- goto error; |
|
| 2209 |
- } |
|
| 2210 |
-#endif |
|
| 2211 |
- } |
|
| 2212 |
- break; |
|
| 2213 |
- case 0x96: /* DEIk */ |
|
| 2214 |
- {
|
|
| 2215 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 2216 |
- u->wst.dat[u->wst.ptr] = devr8(&u->dev[a >> 4], a); |
|
| 2217 |
-#ifndef NO_STACK_CHECKS |
|
| 2218 |
- if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
| 2219 |
- u->wst.error = 1; |
|
| 2220 |
- goto error; |
|
| 2221 |
- } |
|
| 2222 |
- if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
| 2223 |
- u->wst.error = 2; |
|
| 2224 |
- goto error; |
|
| 2225 |
- } |
|
| 2226 |
-#endif |
|
| 2227 |
- u->wst.ptr += 1; |
|
| 2228 |
- } |
|
| 2229 |
- break; |
|
| 2230 |
- case 0x97: /* DEOk */ |
|
| 2231 |
- {
|
|
| 2232 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 2233 |
- devw8(&u->dev[a >> 4], a, b); |
|
| 2234 |
-#ifndef NO_STACK_CHECKS |
|
| 2235 |
- if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 2236 |
- u->wst.error = 1; |
|
| 2237 |
- goto error; |
|
| 2238 |
- } |
|
| 2239 |
-#endif |
|
| 2240 |
- } |
|
| 2241 |
- break; |
|
| 2242 |
- case 0x98: /* ADDk */ |
|
| 2243 |
- {
|
|
| 2244 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 2245 |
- u->wst.dat[u->wst.ptr] = b + a; |
|
| 2246 |
-#ifndef NO_STACK_CHECKS |
|
| 2247 |
- if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 2248 |
- u->wst.error = 1; |
|
| 2249 |
- goto error; |
|
| 2250 |
- } |
|
| 2251 |
- if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
| 2252 |
- u->wst.error = 2; |
|
| 2253 |
- goto error; |
|
| 2254 |
- } |
|
| 2255 |
-#endif |
|
| 2256 |
- u->wst.ptr += 1; |
|
| 2257 |
- } |
|
| 2258 |
- break; |
|
| 2259 |
- case 0x99: /* SUBk */ |
|
| 2260 |
- {
|
|
| 2261 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 2262 |
- u->wst.dat[u->wst.ptr] = b - a; |
|
| 2263 |
-#ifndef NO_STACK_CHECKS |
|
| 2264 |
- if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 2265 |
- u->wst.error = 1; |
|
| 2266 |
- goto error; |
|
| 2267 |
- } |
|
| 2268 |
- if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
| 2269 |
- u->wst.error = 2; |
|
| 2270 |
- goto error; |
|
| 2271 |
- } |
|
| 2272 |
-#endif |
|
| 2273 |
- u->wst.ptr += 1; |
|
| 2274 |
- } |
|
| 2275 |
- break; |
|
| 2276 |
- case 0x9a: /* MULk */ |
|
| 2277 |
- {
|
|
| 2278 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 2279 |
- u->wst.dat[u->wst.ptr] = b * a; |
|
| 2280 |
-#ifndef NO_STACK_CHECKS |
|
| 2281 |
- if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 2282 |
- u->wst.error = 1; |
|
| 2283 |
- goto error; |
|
| 2284 |
- } |
|
| 2285 |
- if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
| 2286 |
- u->wst.error = 2; |
|
| 2287 |
- goto error; |
|
| 2288 |
- } |
|
| 2289 |
-#endif |
|
| 2290 |
- u->wst.ptr += 1; |
|
| 2291 |
- } |
|
| 2292 |
- break; |
|
| 2293 |
- case 0x9b: /* DIVk */ |
|
| 2294 |
- {
|
|
| 2295 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 2296 |
- if(a == 0) {
|
|
| 2297 |
- u->wst.error = 3; |
|
| 2298 |
-#ifndef NO_STACK_CHECKS |
|
| 2299 |
- goto error; |
|
| 2300 |
-#endif |
|
| 2301 |
- a = 1; |
|
| 2302 |
- } |
|
| 2303 |
- u->wst.dat[u->wst.ptr] = b / a; |
|
| 2304 |
-#ifndef NO_STACK_CHECKS |
|
| 2305 |
- if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 2306 |
- u->wst.error = 1; |
|
| 2307 |
- goto error; |
|
| 2308 |
- } |
|
| 2309 |
- if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
| 2310 |
- u->wst.error = 2; |
|
| 2311 |
- goto error; |
|
| 2312 |
- } |
|
| 2313 |
-#endif |
|
| 2314 |
- u->wst.ptr += 1; |
|
| 2315 |
- } |
|
| 2316 |
- break; |
|
| 2317 |
- case 0x9c: /* ANDk */ |
|
| 2318 |
- {
|
|
| 2319 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 2320 |
- u->wst.dat[u->wst.ptr] = b & a; |
|
| 2321 |
-#ifndef NO_STACK_CHECKS |
|
| 2322 |
- if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 2323 |
- u->wst.error = 1; |
|
| 2324 |
- goto error; |
|
| 2325 |
- } |
|
| 2326 |
- if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
| 2327 |
- u->wst.error = 2; |
|
| 2328 |
- goto error; |
|
| 2329 |
- } |
|
| 2330 |
-#endif |
|
| 2331 |
- u->wst.ptr += 1; |
|
| 2332 |
- } |
|
| 2333 |
- break; |
|
| 2334 |
- case 0x9d: /* ORAk */ |
|
| 2335 |
- {
|
|
| 2336 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 2337 |
- u->wst.dat[u->wst.ptr] = b | a; |
|
| 2338 |
-#ifndef NO_STACK_CHECKS |
|
| 2339 |
- if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 2340 |
- u->wst.error = 1; |
|
| 2341 |
- goto error; |
|
| 2342 |
- } |
|
| 2343 |
- if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
| 2344 |
- u->wst.error = 2; |
|
| 2345 |
- goto error; |
|
| 2346 |
- } |
|
| 2347 |
-#endif |
|
| 2348 |
- u->wst.ptr += 1; |
|
| 2349 |
- } |
|
| 2350 |
- break; |
|
| 2351 |
- case 0x9e: /* EORk */ |
|
| 2352 |
- {
|
|
| 2353 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 2354 |
- u->wst.dat[u->wst.ptr] = b ^ a; |
|
| 2355 |
-#ifndef NO_STACK_CHECKS |
|
| 2356 |
- if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 2357 |
- u->wst.error = 1; |
|
| 2358 |
- goto error; |
|
| 2359 |
- } |
|
| 2360 |
- if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
| 2361 |
- u->wst.error = 2; |
|
| 2362 |
- goto error; |
|
| 2363 |
- } |
|
| 2364 |
-#endif |
|
| 2365 |
- u->wst.ptr += 1; |
|
| 2366 |
- } |
|
| 2367 |
- break; |
|
| 2368 |
- case 0x9f: /* SFTk */ |
|
| 2369 |
- {
|
|
| 2370 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 2371 |
- u->wst.dat[u->wst.ptr] = b >> (a & 0x0f) << ((a & 0xf0) >> 4); |
|
| 2372 |
-#ifndef NO_STACK_CHECKS |
|
| 2373 |
- if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 2374 |
- u->wst.error = 1; |
|
| 2375 |
- goto error; |
|
| 2376 |
- } |
|
| 2377 |
- if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
| 2378 |
- u->wst.error = 2; |
|
| 2379 |
- goto error; |
|
| 2380 |
- } |
|
| 2381 |
-#endif |
|
| 2382 |
- u->wst.ptr += 1; |
|
| 2383 |
- } |
|
| 2384 |
- break; |
|
| 2385 |
- case 0xa0: /* LIT2 */ |
|
| 2386 |
- case 0x20: /* LIT2_deprecated */ |
|
| 2387 |
- {
|
|
| 2388 |
- u->wst.dat[u->wst.ptr] = peek8(u->ram.dat, u->ram.ptr++); |
|
| 2389 |
- u->wst.dat[u->wst.ptr + 1] = peek8(u->ram.dat, u->ram.ptr++); |
|
| 2390 |
-#ifndef NO_STACK_CHECKS |
|
| 2391 |
- if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
| 2392 |
- u->wst.error = 2; |
|
| 2393 |
- goto error; |
|
| 2394 |
- } |
|
| 2395 |
-#endif |
|
| 2396 |
- u->wst.ptr += 2; |
|
| 2397 |
- } |
|
| 2398 |
- break; |
|
| 2399 |
- case 0xa1: /* INC2k */ |
|
| 2400 |
- {
|
|
| 2401 |
- Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); |
|
| 2402 |
- u->wst.dat[u->wst.ptr] = (a + 1) >> 8; |
|
| 2403 |
- u->wst.dat[u->wst.ptr + 1] = (a + 1) & 0xff; |
|
| 2404 |
-#ifndef NO_STACK_CHECKS |
|
| 2405 |
- if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 2406 |
- u->wst.error = 1; |
|
| 2407 |
- goto error; |
|
| 2408 |
- } |
|
| 2409 |
- if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
| 2410 |
- u->wst.error = 2; |
|
| 2411 |
- goto error; |
|
| 2412 |
- } |
|
| 2413 |
-#endif |
|
| 2414 |
- u->wst.ptr += 2; |
|
| 2415 |
- } |
|
| 2416 |
- break; |
|
| 2417 |
- case 0xa2: /* POP2k */ |
|
| 2418 |
- {
|
|
| 2419 |
- (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); |
|
| 2420 |
-#ifndef NO_STACK_CHECKS |
|
| 2421 |
- if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 2422 |
- u->wst.error = 1; |
|
| 2423 |
- goto error; |
|
| 2424 |
- } |
|
| 2425 |
-#endif |
|
| 2426 |
- } |
|
| 2427 |
- break; |
|
| 2428 |
- case 0xa3: /* DUP2k */ |
|
| 2429 |
- {
|
|
| 2430 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 2431 |
- u->wst.dat[u->wst.ptr] = b; |
|
| 2432 |
- u->wst.dat[u->wst.ptr + 1] = a; |
|
| 2433 |
- u->wst.dat[u->wst.ptr + 2] = b; |
|
| 2434 |
- u->wst.dat[u->wst.ptr + 3] = a; |
|
| 2435 |
-#ifndef NO_STACK_CHECKS |
|
| 2436 |
- if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 2437 |
- u->wst.error = 1; |
|
| 2438 |
- goto error; |
|
| 2439 |
- } |
|
| 2440 |
- if(__builtin_expect(u->wst.ptr > 251, 0)) {
|
|
| 2441 |
- u->wst.error = 2; |
|
| 2442 |
- goto error; |
|
| 2443 |
- } |
|
| 2444 |
-#endif |
|
| 2445 |
- u->wst.ptr += 4; |
|
| 2446 |
- } |
|
| 2447 |
- break; |
|
| 2448 |
- case 0xa4: /* NIP2k */ |
|
| 2449 |
- {
|
|
| 2450 |
- Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); |
|
| 2451 |
- (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); |
|
| 2452 |
- u->wst.dat[u->wst.ptr] = a >> 8; |
|
| 2453 |
- u->wst.dat[u->wst.ptr + 1] = a & 0xff; |
|
| 2454 |
-#ifndef NO_STACK_CHECKS |
|
| 2455 |
- if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
| 2456 |
- u->wst.error = 1; |
|
| 2457 |
- goto error; |
|
| 2458 |
- } |
|
| 2459 |
- if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
| 2460 |
- u->wst.error = 2; |
|
| 2461 |
- goto error; |
|
| 2462 |
- } |
|
| 2463 |
-#endif |
|
| 2464 |
- u->wst.ptr += 2; |
|
| 2465 |
- } |
|
| 2466 |
- break; |
|
| 2467 |
- case 0xa5: /* SWP2k */ |
|
| 2468 |
- {
|
|
| 2469 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2], c = u->wst.dat[u->wst.ptr - 3], d = u->wst.dat[u->wst.ptr - 4]; |
|
| 2470 |
- u->wst.dat[u->wst.ptr] = b; |
|
| 2471 |
- u->wst.dat[u->wst.ptr + 1] = a; |
|
| 2472 |
- u->wst.dat[u->wst.ptr + 2] = d; |
|
| 2473 |
- u->wst.dat[u->wst.ptr + 3] = c; |
|
| 2474 |
-#ifndef NO_STACK_CHECKS |
|
| 2475 |
- if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
| 2476 |
- u->wst.error = 1; |
|
| 2477 |
- goto error; |
|
| 2478 |
- } |
|
| 2479 |
- if(__builtin_expect(u->wst.ptr > 251, 0)) {
|
|
| 2480 |
- u->wst.error = 2; |
|
| 2481 |
- goto error; |
|
| 2482 |
- } |
|
| 2483 |
-#endif |
|
| 2484 |
- u->wst.ptr += 4; |
|
| 2485 |
- } |
|
| 2486 |
- break; |
|
| 2487 |
- case 0xa6: /* OVR2k */ |
|
| 2488 |
- {
|
|
| 2489 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2], c = u->wst.dat[u->wst.ptr - 3], d = u->wst.dat[u->wst.ptr - 4]; |
|
| 2490 |
- u->wst.dat[u->wst.ptr] = d; |
|
| 2491 |
- u->wst.dat[u->wst.ptr + 1] = c; |
|
| 2492 |
- u->wst.dat[u->wst.ptr + 2] = b; |
|
| 2493 |
- u->wst.dat[u->wst.ptr + 3] = a; |
|
| 2494 |
- u->wst.dat[u->wst.ptr + 4] = d; |
|
| 2495 |
- u->wst.dat[u->wst.ptr + 5] = c; |
|
| 2496 |
-#ifndef NO_STACK_CHECKS |
|
| 2497 |
- if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
| 2498 |
- u->wst.error = 1; |
|
| 2499 |
- goto error; |
|
| 2500 |
- } |
|
| 2501 |
- if(__builtin_expect(u->wst.ptr > 249, 0)) {
|
|
| 2502 |
- u->wst.error = 2; |
|
| 2503 |
- goto error; |
|
| 2504 |
- } |
|
| 2505 |
-#endif |
|
| 2506 |
- u->wst.ptr += 6; |
|
| 2507 |
- } |
|
| 2508 |
- break; |
|
| 2509 |
- case 0xa7: /* ROT2k */ |
|
| 2510 |
- {
|
|
| 2511 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2], c = u->wst.dat[u->wst.ptr - 3], d = u->wst.dat[u->wst.ptr - 4], e = u->wst.dat[u->wst.ptr - 5], f = u->wst.dat[u->wst.ptr - 6]; |
|
| 2512 |
- u->wst.dat[u->wst.ptr] = d; |
|
| 2513 |
- u->wst.dat[u->wst.ptr + 1] = c; |
|
| 2514 |
- u->wst.dat[u->wst.ptr + 2] = b; |
|
| 2515 |
- u->wst.dat[u->wst.ptr + 3] = a; |
|
| 2516 |
- u->wst.dat[u->wst.ptr + 4] = f; |
|
| 2517 |
- u->wst.dat[u->wst.ptr + 5] = e; |
|
| 2518 |
-#ifndef NO_STACK_CHECKS |
|
| 2519 |
- if(__builtin_expect(u->wst.ptr < 6, 0)) {
|
|
| 2520 |
- u->wst.error = 1; |
|
| 2521 |
- goto error; |
|
| 2522 |
- } |
|
| 2523 |
- if(__builtin_expect(u->wst.ptr > 249, 0)) {
|
|
| 2524 |
- u->wst.error = 2; |
|
| 2525 |
- goto error; |
|
| 2526 |
- } |
|
| 2527 |
-#endif |
|
| 2528 |
- u->wst.ptr += 6; |
|
| 2529 |
- } |
|
| 2530 |
- break; |
|
| 2531 |
- case 0xa8: /* EQU2k */ |
|
| 2532 |
- {
|
|
| 2533 |
- Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); |
|
| 2534 |
- u->wst.dat[u->wst.ptr] = b == a; |
|
| 2535 |
-#ifndef NO_STACK_CHECKS |
|
| 2536 |
- if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
| 2537 |
- u->wst.error = 1; |
|
| 2538 |
- goto error; |
|
| 2539 |
- } |
|
| 2540 |
- if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
| 2541 |
- u->wst.error = 2; |
|
| 2542 |
- goto error; |
|
| 2543 |
- } |
|
| 2544 |
-#endif |
|
| 2545 |
- u->wst.ptr += 1; |
|
| 2546 |
- } |
|
| 2547 |
- break; |
|
| 2548 |
- case 0xa9: /* NEQ2k */ |
|
| 2549 |
- {
|
|
| 2550 |
- Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); |
|
| 2551 |
- u->wst.dat[u->wst.ptr] = b != a; |
|
| 2552 |
-#ifndef NO_STACK_CHECKS |
|
| 2553 |
- if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
| 2554 |
- u->wst.error = 1; |
|
| 2555 |
- goto error; |
|
| 2556 |
- } |
|
| 2557 |
- if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
| 2558 |
- u->wst.error = 2; |
|
| 2559 |
- goto error; |
|
| 2560 |
- } |
|
| 2561 |
-#endif |
|
| 2562 |
- u->wst.ptr += 1; |
|
| 2563 |
- } |
|
| 2564 |
- break; |
|
| 2565 |
- case 0xaa: /* GTH2k */ |
|
| 2566 |
- {
|
|
| 2567 |
- Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); |
|
| 2568 |
- u->wst.dat[u->wst.ptr] = b > a; |
|
| 2569 |
-#ifndef NO_STACK_CHECKS |
|
| 2570 |
- if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
| 2571 |
- u->wst.error = 1; |
|
| 2572 |
- goto error; |
|
| 2573 |
- } |
|
| 2574 |
- if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
| 2575 |
- u->wst.error = 2; |
|
| 2576 |
- goto error; |
|
| 2577 |
- } |
|
| 2578 |
-#endif |
|
| 2579 |
- u->wst.ptr += 1; |
|
| 2580 |
- } |
|
| 2581 |
- break; |
|
| 2582 |
- case 0xab: /* LTH2k */ |
|
| 2583 |
- {
|
|
| 2584 |
- Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); |
|
| 2585 |
- u->wst.dat[u->wst.ptr] = b < a; |
|
| 2586 |
-#ifndef NO_STACK_CHECKS |
|
| 2587 |
- if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
| 2588 |
- u->wst.error = 1; |
|
| 2589 |
- goto error; |
|
| 2590 |
- } |
|
| 2591 |
- if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
| 2592 |
- u->wst.error = 2; |
|
| 2593 |
- goto error; |
|
| 2594 |
- } |
|
| 2595 |
-#endif |
|
| 2596 |
- u->wst.ptr += 1; |
|
| 2597 |
- } |
|
| 2598 |
- break; |
|
| 2599 |
- case 0xac: /* JMP2k */ |
|
| 2600 |
- {
|
|
| 2601 |
- u->ram.ptr = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); |
|
| 2602 |
-#ifndef NO_STACK_CHECKS |
|
| 2603 |
- if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 2604 |
- u->wst.error = 1; |
|
| 2605 |
- goto error; |
|
| 2606 |
- } |
|
| 2607 |
-#endif |
|
| 2608 |
- } |
|
| 2609 |
- break; |
|
| 2610 |
- case 0xad: /* JCN2k */ |
|
| 2611 |
- {
|
|
| 2612 |
- Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); |
|
| 2613 |
- if(u->wst.dat[u->wst.ptr - 3]) u->ram.ptr = a; |
|
| 2614 |
-#ifndef NO_STACK_CHECKS |
|
| 2615 |
- if(__builtin_expect(u->wst.ptr < 3, 0)) {
|
|
| 2616 |
- u->wst.error = 1; |
|
| 2617 |
- goto error; |
|
| 2618 |
- } |
|
| 2619 |
-#endif |
|
| 2620 |
- } |
|
| 2621 |
- break; |
|
| 2622 |
- case 0xae: /* JSR2k */ |
|
| 2623 |
- {
|
|
| 2624 |
- u->rst.dat[u->rst.ptr] = u->ram.ptr >> 8; |
|
| 2625 |
- u->rst.dat[u->rst.ptr + 1] = u->ram.ptr & 0xff; |
|
| 2626 |
- u->ram.ptr = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); |
|
| 2627 |
-#ifndef NO_STACK_CHECKS |
|
| 2628 |
- if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 2629 |
- u->wst.error = 1; |
|
| 2630 |
- goto error; |
|
| 2631 |
- } |
|
| 2632 |
- if(__builtin_expect(u->rst.ptr > 253, 0)) {
|
|
| 2633 |
- u->rst.error = 2; |
|
| 2634 |
- goto error; |
|
| 2635 |
- } |
|
| 2636 |
-#endif |
|
| 2637 |
- u->rst.ptr += 2; |
|
| 2638 |
- } |
|
| 2639 |
- break; |
|
| 2640 |
- case 0xaf: /* STH2k */ |
|
| 2641 |
- {
|
|
| 2642 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 2643 |
- u->rst.dat[u->rst.ptr] = b; |
|
| 2644 |
- u->rst.dat[u->rst.ptr + 1] = a; |
|
| 2645 |
-#ifndef NO_STACK_CHECKS |
|
| 2646 |
- if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 2647 |
- u->wst.error = 1; |
|
| 2648 |
- goto error; |
|
| 2649 |
- } |
|
| 2650 |
- if(__builtin_expect(u->rst.ptr > 253, 0)) {
|
|
| 2651 |
- u->rst.error = 2; |
|
| 2652 |
- goto error; |
|
| 2653 |
- } |
|
| 2654 |
-#endif |
|
| 2655 |
- u->rst.ptr += 2; |
|
| 2656 |
- } |
|
| 2657 |
- break; |
|
| 2658 |
- case 0xb0: /* LDZ2k */ |
|
| 2659 |
- {
|
|
| 2660 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 2661 |
- u->wst.dat[u->wst.ptr] = peek8(u->ram.dat, a); |
|
| 2662 |
- u->wst.dat[u->wst.ptr + 1] = peek8(u->ram.dat, a + 1); |
|
| 2663 |
-#ifndef NO_STACK_CHECKS |
|
| 2664 |
- if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
| 2665 |
- u->wst.error = 1; |
|
| 2666 |
- goto error; |
|
| 2667 |
- } |
|
| 2668 |
- if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
| 2669 |
- u->wst.error = 2; |
|
| 2670 |
- goto error; |
|
| 2671 |
- } |
|
| 2672 |
-#endif |
|
| 2673 |
- u->wst.ptr += 2; |
|
| 2674 |
- } |
|
| 2675 |
- break; |
|
| 2676 |
- case 0xb1: /* STZ2k */ |
|
| 2677 |
- {
|
|
| 2678 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 2679 |
- Uint16 b = (u->wst.dat[u->wst.ptr - 2] | (u->wst.dat[u->wst.ptr - 3] << 8)); |
|
| 2680 |
- poke16(u->ram.dat, a, b); |
|
| 2681 |
-#ifndef NO_STACK_CHECKS |
|
| 2682 |
- if(__builtin_expect(u->wst.ptr < 3, 0)) {
|
|
| 2683 |
- u->wst.error = 1; |
|
| 2684 |
- goto error; |
|
| 2685 |
- } |
|
| 2686 |
-#endif |
|
| 2687 |
- } |
|
| 2688 |
- break; |
|
| 2689 |
- case 0xb2: /* LDR2k */ |
|
| 2690 |
- {
|
|
| 2691 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 2692 |
- u->wst.dat[u->wst.ptr] = peek8(u->ram.dat, u->ram.ptr + (Sint8)a); |
|
| 2693 |
- u->wst.dat[u->wst.ptr + 1] = peek8(u->ram.dat, u->ram.ptr + (Sint8)a + 1); |
|
| 2694 |
-#ifndef NO_STACK_CHECKS |
|
| 2695 |
- if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
| 2696 |
- u->wst.error = 1; |
|
| 2697 |
- goto error; |
|
| 2698 |
- } |
|
| 2699 |
- if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
| 2700 |
- u->wst.error = 2; |
|
| 2701 |
- goto error; |
|
| 2702 |
- } |
|
| 2703 |
-#endif |
|
| 2704 |
- u->wst.ptr += 2; |
|
| 2705 |
- } |
|
| 2706 |
- break; |
|
| 2707 |
- case 0xb3: /* STR2k */ |
|
| 2708 |
- {
|
|
| 2709 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 2710 |
- Uint16 b = (u->wst.dat[u->wst.ptr - 2] | (u->wst.dat[u->wst.ptr - 3] << 8)); |
|
| 2711 |
- poke16(u->ram.dat, u->ram.ptr + (Sint8)a, b); |
|
| 2712 |
-#ifndef NO_STACK_CHECKS |
|
| 2713 |
- if(__builtin_expect(u->wst.ptr < 3, 0)) {
|
|
| 2714 |
- u->wst.error = 1; |
|
| 2715 |
- goto error; |
|
| 2716 |
- } |
|
| 2717 |
-#endif |
|
| 2718 |
- } |
|
| 2719 |
- break; |
|
| 2720 |
- case 0xb4: /* LDA2k */ |
|
| 2721 |
- {
|
|
| 2722 |
- Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); |
|
| 2723 |
- u->wst.dat[u->wst.ptr] = peek8(u->ram.dat, a); |
|
| 2724 |
- u->wst.dat[u->wst.ptr + 1] = peek8(u->ram.dat, a + 1); |
|
| 2725 |
-#ifndef NO_STACK_CHECKS |
|
| 2726 |
- if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 2727 |
- u->wst.error = 1; |
|
| 2728 |
- goto error; |
|
| 2729 |
- } |
|
| 2730 |
- if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
| 2731 |
- u->wst.error = 2; |
|
| 2732 |
- goto error; |
|
| 2733 |
- } |
|
| 2734 |
-#endif |
|
| 2735 |
- u->wst.ptr += 2; |
|
| 2736 |
- } |
|
| 2737 |
- break; |
|
| 2738 |
- case 0xb5: /* STA2k */ |
|
| 2739 |
- {
|
|
| 2740 |
- Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); |
|
| 2741 |
- Uint16 b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); |
|
| 2742 |
- poke16(u->ram.dat, a, b); |
|
| 2743 |
-#ifndef NO_STACK_CHECKS |
|
| 2744 |
- if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
| 2745 |
- u->wst.error = 1; |
|
| 2746 |
- goto error; |
|
| 2747 |
- } |
|
| 2748 |
-#endif |
|
| 2749 |
- } |
|
| 2750 |
- break; |
|
| 2751 |
- case 0xb6: /* DEI2k */ |
|
| 2752 |
- {
|
|
| 2753 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 2754 |
- u->wst.dat[u->wst.ptr] = devr8(&u->dev[a >> 4], a); |
|
| 2755 |
- u->wst.dat[u->wst.ptr + 1] = devr8(&u->dev[a >> 4], a + 1); |
|
| 2756 |
-#ifndef NO_STACK_CHECKS |
|
| 2757 |
- if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
| 2758 |
- u->wst.error = 1; |
|
| 2759 |
- goto error; |
|
| 2760 |
- } |
|
| 2761 |
- if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
| 2762 |
- u->wst.error = 2; |
|
| 2763 |
- goto error; |
|
| 2764 |
- } |
|
| 2765 |
-#endif |
|
| 2766 |
- u->wst.ptr += 2; |
|
| 2767 |
- } |
|
| 2768 |
- break; |
|
| 2769 |
- case 0xb7: /* DEO2k */ |
|
| 2770 |
- {
|
|
| 2771 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 2772 |
- Uint16 b = (u->wst.dat[u->wst.ptr - 2] | (u->wst.dat[u->wst.ptr - 3] << 8)); |
|
| 2773 |
- devw16(&u->dev[a >> 4], a, b); |
|
| 2774 |
-#ifndef NO_STACK_CHECKS |
|
| 2775 |
- if(__builtin_expect(u->wst.ptr < 3, 0)) {
|
|
| 2776 |
- u->wst.error = 1; |
|
| 2777 |
- goto error; |
|
| 2778 |
- } |
|
| 2779 |
-#endif |
|
| 2780 |
- } |
|
| 2781 |
- break; |
|
| 2782 |
- case 0xb8: /* ADD2k */ |
|
| 2783 |
- {
|
|
| 2784 |
- Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); |
|
| 2785 |
- u->wst.dat[u->wst.ptr] = (b + a) >> 8; |
|
| 2786 |
- u->wst.dat[u->wst.ptr + 1] = (b + a) & 0xff; |
|
| 2787 |
-#ifndef NO_STACK_CHECKS |
|
| 2788 |
- if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
| 2789 |
- u->wst.error = 1; |
|
| 2790 |
- goto error; |
|
| 2791 |
- } |
|
| 2792 |
- if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
| 2793 |
- u->wst.error = 2; |
|
| 2794 |
- goto error; |
|
| 2795 |
- } |
|
| 2796 |
-#endif |
|
| 2797 |
- u->wst.ptr += 2; |
|
| 2798 |
- } |
|
| 2799 |
- break; |
|
| 2800 |
- case 0xb9: /* SUB2k */ |
|
| 2801 |
- {
|
|
| 2802 |
- Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); |
|
| 2803 |
- u->wst.dat[u->wst.ptr] = (b - a) >> 8; |
|
| 2804 |
- u->wst.dat[u->wst.ptr + 1] = (b - a) & 0xff; |
|
| 2805 |
-#ifndef NO_STACK_CHECKS |
|
| 2806 |
- if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
| 2807 |
- u->wst.error = 1; |
|
| 2808 |
- goto error; |
|
| 2809 |
- } |
|
| 2810 |
- if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
| 2811 |
- u->wst.error = 2; |
|
| 2812 |
- goto error; |
|
| 2813 |
- } |
|
| 2814 |
-#endif |
|
| 2815 |
- u->wst.ptr += 2; |
|
| 2816 |
- } |
|
| 2817 |
- break; |
|
| 2818 |
- case 0xba: /* MUL2k */ |
|
| 2819 |
- {
|
|
| 2820 |
- Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); |
|
| 2821 |
- u->wst.dat[u->wst.ptr] = (b * a) >> 8; |
|
| 2822 |
- u->wst.dat[u->wst.ptr + 1] = (b * a) & 0xff; |
|
| 2823 |
-#ifndef NO_STACK_CHECKS |
|
| 2824 |
- if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
| 2825 |
- u->wst.error = 1; |
|
| 2826 |
- goto error; |
|
| 2827 |
- } |
|
| 2828 |
- if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
| 2829 |
- u->wst.error = 2; |
|
| 2830 |
- goto error; |
|
| 2831 |
- } |
|
| 2832 |
-#endif |
|
| 2833 |
- u->wst.ptr += 2; |
|
| 2834 |
- } |
|
| 2835 |
- break; |
|
| 2836 |
- case 0xbb: /* DIV2k */ |
|
| 2837 |
- {
|
|
| 2838 |
- Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); |
|
| 2839 |
- if(a == 0) {
|
|
| 2840 |
- u->wst.error = 3; |
|
| 2841 |
-#ifndef NO_STACK_CHECKS |
|
| 2842 |
- goto error; |
|
| 2843 |
-#endif |
|
| 2844 |
- a = 1; |
|
| 2845 |
- } |
|
| 2846 |
- u->wst.dat[u->wst.ptr] = (b / a) >> 8; |
|
| 2847 |
- u->wst.dat[u->wst.ptr + 1] = (b / a) & 0xff; |
|
| 2848 |
-#ifndef NO_STACK_CHECKS |
|
| 2849 |
- if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
| 2850 |
- u->wst.error = 1; |
|
| 2851 |
- goto error; |
|
| 2852 |
- } |
|
| 2853 |
- if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
| 2854 |
- u->wst.error = 2; |
|
| 2855 |
- goto error; |
|
| 2856 |
- } |
|
| 2857 |
-#endif |
|
| 2858 |
- u->wst.ptr += 2; |
|
| 2859 |
- } |
|
| 2860 |
- break; |
|
| 2861 |
- case 0xbc: /* AND2k */ |
|
| 2862 |
- {
|
|
| 2863 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2], c = u->wst.dat[u->wst.ptr - 3], d = u->wst.dat[u->wst.ptr - 4]; |
|
| 2864 |
- u->wst.dat[u->wst.ptr] = d & b; |
|
| 2865 |
- u->wst.dat[u->wst.ptr + 1] = c & a; |
|
| 2866 |
-#ifndef NO_STACK_CHECKS |
|
| 2867 |
- if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
| 2868 |
- u->wst.error = 1; |
|
| 2869 |
- goto error; |
|
| 2870 |
- } |
|
| 2871 |
- if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
| 2872 |
- u->wst.error = 2; |
|
| 2873 |
- goto error; |
|
| 2874 |
- } |
|
| 2875 |
-#endif |
|
| 2876 |
- u->wst.ptr += 2; |
|
| 2877 |
- } |
|
| 2878 |
- break; |
|
| 2879 |
- case 0xbd: /* ORA2k */ |
|
| 2880 |
- {
|
|
| 2881 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2], c = u->wst.dat[u->wst.ptr - 3], d = u->wst.dat[u->wst.ptr - 4]; |
|
| 2882 |
- u->wst.dat[u->wst.ptr] = d | b; |
|
| 2883 |
- u->wst.dat[u->wst.ptr + 1] = c | a; |
|
| 2884 |
-#ifndef NO_STACK_CHECKS |
|
| 2885 |
- if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
| 2886 |
- u->wst.error = 1; |
|
| 2887 |
- goto error; |
|
| 2888 |
- } |
|
| 2889 |
- if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
| 2890 |
- u->wst.error = 2; |
|
| 2891 |
- goto error; |
|
| 2892 |
- } |
|
| 2893 |
-#endif |
|
| 2894 |
- u->wst.ptr += 2; |
|
| 2895 |
- } |
|
| 2896 |
- break; |
|
| 2897 |
- case 0xbe: /* EOR2k */ |
|
| 2898 |
- {
|
|
| 2899 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2], c = u->wst.dat[u->wst.ptr - 3], d = u->wst.dat[u->wst.ptr - 4]; |
|
| 2900 |
- u->wst.dat[u->wst.ptr] = d ^ b; |
|
| 2901 |
- u->wst.dat[u->wst.ptr + 1] = c ^ a; |
|
| 2902 |
-#ifndef NO_STACK_CHECKS |
|
| 2903 |
- if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
| 2904 |
- u->wst.error = 1; |
|
| 2905 |
- goto error; |
|
| 2906 |
- } |
|
| 2907 |
- if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
| 2908 |
- u->wst.error = 2; |
|
| 2909 |
- goto error; |
|
| 2910 |
- } |
|
| 2911 |
-#endif |
|
| 2912 |
- u->wst.ptr += 2; |
|
| 2913 |
- } |
|
| 2914 |
- break; |
|
| 2915 |
- case 0xbf: /* SFT2k */ |
|
| 2916 |
- {
|
|
| 2917 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 2918 |
- Uint16 b = (u->wst.dat[u->wst.ptr - 2] | (u->wst.dat[u->wst.ptr - 3] << 8)); |
|
| 2919 |
- u->wst.dat[u->wst.ptr] = (b >> (a & 0x0f) << ((a & 0xf0) >> 4)) >> 8; |
|
| 2920 |
- u->wst.dat[u->wst.ptr + 1] = (b >> (a & 0x0f) << ((a & 0xf0) >> 4)) & 0xff; |
|
| 2921 |
-#ifndef NO_STACK_CHECKS |
|
| 2922 |
- if(__builtin_expect(u->wst.ptr < 3, 0)) {
|
|
| 2923 |
- u->wst.error = 1; |
|
| 2924 |
- goto error; |
|
| 2925 |
- } |
|
| 2926 |
- if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
| 2927 |
- u->wst.error = 2; |
|
| 2928 |
- goto error; |
|
| 2929 |
- } |
|
| 2930 |
-#endif |
|
| 2931 |
- u->wst.ptr += 2; |
|
| 2932 |
- } |
|
| 2933 |
- break; |
|
| 2934 |
- case 0xc0: /* LITr */ |
|
| 2935 |
- case 0x40: /* LITr_deprecated */ |
|
| 2936 |
- {
|
|
| 2937 |
- u->rst.dat[u->rst.ptr] = peek8(u->ram.dat, u->ram.ptr++); |
|
| 2938 |
-#ifndef NO_STACK_CHECKS |
|
| 2939 |
- if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
| 2940 |
- u->rst.error = 2; |
|
| 2941 |
- goto error; |
|
| 2942 |
- } |
|
| 2943 |
-#endif |
|
| 2944 |
- u->rst.ptr += 1; |
|
| 2945 |
- } |
|
| 2946 |
- break; |
|
| 2947 |
- case 0xc1: /* INCkr */ |
|
| 2948 |
- {
|
|
| 2949 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 2950 |
- u->rst.dat[u->rst.ptr] = a + 1; |
|
| 2951 |
-#ifndef NO_STACK_CHECKS |
|
| 2952 |
- if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
| 2953 |
- u->rst.error = 1; |
|
| 2954 |
- goto error; |
|
| 2955 |
- } |
|
| 2956 |
- if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
| 2957 |
- u->rst.error = 2; |
|
| 2958 |
- goto error; |
|
| 2959 |
- } |
|
| 2960 |
-#endif |
|
| 2961 |
- u->rst.ptr += 1; |
|
| 2962 |
- } |
|
| 2963 |
- break; |
|
| 2964 |
- case 0xc2: /* POPkr */ |
|
| 2965 |
- {
|
|
| 2966 |
- u->rst.dat[u->rst.ptr - 1]; |
|
| 2967 |
-#ifndef NO_STACK_CHECKS |
|
| 2968 |
- if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
| 2969 |
- u->rst.error = 1; |
|
| 2970 |
- goto error; |
|
| 2971 |
- } |
|
| 2972 |
-#endif |
|
| 2973 |
- } |
|
| 2974 |
- break; |
|
| 2975 |
- case 0xc3: /* DUPkr */ |
|
| 2976 |
- {
|
|
| 2977 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 2978 |
- u->rst.dat[u->rst.ptr] = a; |
|
| 2979 |
- u->rst.dat[u->rst.ptr + 1] = a; |
|
| 2980 |
-#ifndef NO_STACK_CHECKS |
|
| 2981 |
- if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
| 2982 |
- u->rst.error = 1; |
|
| 2983 |
- goto error; |
|
| 2984 |
- } |
|
| 2985 |
- if(__builtin_expect(u->rst.ptr > 253, 0)) {
|
|
| 2986 |
- u->rst.error = 2; |
|
| 2987 |
- goto error; |
|
| 2988 |
- } |
|
| 2989 |
-#endif |
|
| 2990 |
- u->rst.ptr += 2; |
|
| 2991 |
- } |
|
| 2992 |
- break; |
|
| 2993 |
- case 0xc4: /* NIPkr */ |
|
| 2994 |
- {
|
|
| 2995 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 2996 |
- u->rst.dat[u->rst.ptr - 2]; |
|
| 2997 |
- u->rst.dat[u->rst.ptr] = a; |
|
| 2998 |
-#ifndef NO_STACK_CHECKS |
|
| 2999 |
- if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 3000 |
- u->rst.error = 1; |
|
| 3001 |
- goto error; |
|
| 3002 |
- } |
|
| 3003 |
- if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
| 3004 |
- u->rst.error = 2; |
|
| 3005 |
- goto error; |
|
| 3006 |
- } |
|
| 3007 |
-#endif |
|
| 3008 |
- u->rst.ptr += 1; |
|
| 3009 |
- } |
|
| 3010 |
- break; |
|
| 3011 |
- case 0xc5: /* SWPkr */ |
|
| 3012 |
- {
|
|
| 3013 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 3014 |
- u->rst.dat[u->rst.ptr] = a; |
|
| 3015 |
- u->rst.dat[u->rst.ptr + 1] = b; |
|
| 3016 |
-#ifndef NO_STACK_CHECKS |
|
| 3017 |
- if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 3018 |
- u->rst.error = 1; |
|
| 3019 |
- goto error; |
|
| 3020 |
- } |
|
| 3021 |
- if(__builtin_expect(u->rst.ptr > 253, 0)) {
|
|
| 3022 |
- u->rst.error = 2; |
|
| 3023 |
- goto error; |
|
| 3024 |
- } |
|
| 3025 |
-#endif |
|
| 3026 |
- u->rst.ptr += 2; |
|
| 3027 |
- } |
|
| 3028 |
- break; |
|
| 3029 |
- case 0xc6: /* OVRkr */ |
|
| 3030 |
- {
|
|
| 3031 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 3032 |
- u->rst.dat[u->rst.ptr] = b; |
|
| 3033 |
- u->rst.dat[u->rst.ptr + 1] = a; |
|
| 3034 |
- u->rst.dat[u->rst.ptr + 2] = b; |
|
| 3035 |
-#ifndef NO_STACK_CHECKS |
|
| 3036 |
- if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 3037 |
- u->rst.error = 1; |
|
| 3038 |
- goto error; |
|
| 3039 |
- } |
|
| 3040 |
- if(__builtin_expect(u->rst.ptr > 252, 0)) {
|
|
| 3041 |
- u->rst.error = 2; |
|
| 3042 |
- goto error; |
|
| 3043 |
- } |
|
| 3044 |
-#endif |
|
| 3045 |
- u->rst.ptr += 3; |
|
| 3046 |
- } |
|
| 3047 |
- break; |
|
| 3048 |
- case 0xc7: /* ROTkr */ |
|
| 3049 |
- {
|
|
| 3050 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2], c = u->rst.dat[u->rst.ptr - 3]; |
|
| 3051 |
- u->rst.dat[u->rst.ptr] = b; |
|
| 3052 |
- u->rst.dat[u->rst.ptr + 1] = a; |
|
| 3053 |
- u->rst.dat[u->rst.ptr + 2] = c; |
|
| 3054 |
-#ifndef NO_STACK_CHECKS |
|
| 3055 |
- if(__builtin_expect(u->rst.ptr < 3, 0)) {
|
|
| 3056 |
- u->rst.error = 1; |
|
| 3057 |
- goto error; |
|
| 3058 |
- } |
|
| 3059 |
- if(__builtin_expect(u->rst.ptr > 252, 0)) {
|
|
| 3060 |
- u->rst.error = 2; |
|
| 3061 |
- goto error; |
|
| 3062 |
- } |
|
| 3063 |
-#endif |
|
| 3064 |
- u->rst.ptr += 3; |
|
| 3065 |
- } |
|
| 3066 |
- break; |
|
| 3067 |
- case 0xc8: /* EQUkr */ |
|
| 3068 |
- {
|
|
| 3069 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 3070 |
- u->rst.dat[u->rst.ptr] = b == a; |
|
| 3071 |
-#ifndef NO_STACK_CHECKS |
|
| 3072 |
- if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 3073 |
- u->rst.error = 1; |
|
| 3074 |
- goto error; |
|
| 3075 |
- } |
|
| 3076 |
- if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
| 3077 |
- u->rst.error = 2; |
|
| 3078 |
- goto error; |
|
| 3079 |
- } |
|
| 3080 |
-#endif |
|
| 3081 |
- u->rst.ptr += 1; |
|
| 3082 |
- } |
|
| 3083 |
- break; |
|
| 3084 |
- case 0xc9: /* NEQkr */ |
|
| 3085 |
- {
|
|
| 3086 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 3087 |
- u->rst.dat[u->rst.ptr] = b != a; |
|
| 3088 |
-#ifndef NO_STACK_CHECKS |
|
| 3089 |
- if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 3090 |
- u->rst.error = 1; |
|
| 3091 |
- goto error; |
|
| 3092 |
- } |
|
| 3093 |
- if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
| 3094 |
- u->rst.error = 2; |
|
| 3095 |
- goto error; |
|
| 3096 |
- } |
|
| 3097 |
-#endif |
|
| 3098 |
- u->rst.ptr += 1; |
|
| 3099 |
- } |
|
| 3100 |
- break; |
|
| 3101 |
- case 0xca: /* GTHkr */ |
|
| 3102 |
- {
|
|
| 3103 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 3104 |
- u->rst.dat[u->rst.ptr] = b > a; |
|
| 3105 |
-#ifndef NO_STACK_CHECKS |
|
| 3106 |
- if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 3107 |
- u->rst.error = 1; |
|
| 3108 |
- goto error; |
|
| 3109 |
- } |
|
| 3110 |
- if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
| 3111 |
- u->rst.error = 2; |
|
| 3112 |
- goto error; |
|
| 3113 |
- } |
|
| 3114 |
-#endif |
|
| 3115 |
- u->rst.ptr += 1; |
|
| 3116 |
- } |
|
| 3117 |
- break; |
|
| 3118 |
- case 0xcb: /* LTHkr */ |
|
| 3119 |
- {
|
|
| 3120 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 3121 |
- u->rst.dat[u->rst.ptr] = b < a; |
|
| 3122 |
-#ifndef NO_STACK_CHECKS |
|
| 3123 |
- if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 3124 |
- u->rst.error = 1; |
|
| 3125 |
- goto error; |
|
| 3126 |
- } |
|
| 3127 |
- if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
| 3128 |
- u->rst.error = 2; |
|
| 3129 |
- goto error; |
|
| 3130 |
- } |
|
| 3131 |
-#endif |
|
| 3132 |
- u->rst.ptr += 1; |
|
| 3133 |
- } |
|
| 3134 |
- break; |
|
| 3135 |
- case 0xcc: /* JMPkr */ |
|
| 3136 |
- {
|
|
| 3137 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 3138 |
- u->ram.ptr += (Sint8)a; |
|
| 3139 |
-#ifndef NO_STACK_CHECKS |
|
| 3140 |
- if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
| 3141 |
- u->rst.error = 1; |
|
| 3142 |
- goto error; |
|
| 3143 |
- } |
|
| 3144 |
-#endif |
|
| 3145 |
- } |
|
| 3146 |
- break; |
|
| 3147 |
- case 0xcd: /* JCNkr */ |
|
| 3148 |
- {
|
|
| 3149 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 3150 |
- if(u->rst.dat[u->rst.ptr - 2]) u->ram.ptr += (Sint8)a; |
|
| 3151 |
-#ifndef NO_STACK_CHECKS |
|
| 3152 |
- if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 3153 |
- u->rst.error = 1; |
|
| 3154 |
- goto error; |
|
| 3155 |
- } |
|
| 3156 |
-#endif |
|
| 3157 |
- } |
|
| 3158 |
- break; |
|
| 3159 |
- case 0xce: /* JSRkr */ |
|
| 3160 |
- {
|
|
| 3161 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 3162 |
- u->wst.dat[u->wst.ptr] = u->ram.ptr >> 8; |
|
| 3163 |
- u->wst.dat[u->wst.ptr + 1] = u->ram.ptr & 0xff; |
|
| 3164 |
- u->ram.ptr += (Sint8)a; |
|
| 3165 |
-#ifndef NO_STACK_CHECKS |
|
| 3166 |
- if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
| 3167 |
- u->rst.error = 1; |
|
| 3168 |
- goto error; |
|
| 3169 |
- } |
|
| 3170 |
- if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
| 3171 |
- u->wst.error = 2; |
|
| 3172 |
- goto error; |
|
| 3173 |
- } |
|
| 3174 |
-#endif |
|
| 3175 |
- u->wst.ptr += 2; |
|
| 3176 |
- } |
|
| 3177 |
- break; |
|
| 3178 |
- case 0xcf: /* STHkr */ |
|
| 3179 |
- {
|
|
| 3180 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 3181 |
- u->wst.dat[u->wst.ptr] = a; |
|
| 3182 |
-#ifndef NO_STACK_CHECKS |
|
| 3183 |
- if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
| 3184 |
- u->rst.error = 1; |
|
| 3185 |
- goto error; |
|
| 3186 |
- } |
|
| 3187 |
- if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
| 3188 |
- u->wst.error = 2; |
|
| 3189 |
- goto error; |
|
| 3190 |
- } |
|
| 3191 |
-#endif |
|
| 3192 |
- u->wst.ptr += 1; |
|
| 3193 |
- } |
|
| 3194 |
- break; |
|
| 3195 |
- case 0xd0: /* LDZkr */ |
|
| 3196 |
- {
|
|
| 3197 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 3198 |
- u->rst.dat[u->rst.ptr] = peek8(u->ram.dat, a); |
|
| 3199 |
-#ifndef NO_STACK_CHECKS |
|
| 3200 |
- if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
| 3201 |
- u->rst.error = 1; |
|
| 3202 |
- goto error; |
|
| 3203 |
- } |
|
| 3204 |
- if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
| 3205 |
- u->rst.error = 2; |
|
| 3206 |
- goto error; |
|
| 3207 |
- } |
|
| 3208 |
-#endif |
|
| 3209 |
- u->rst.ptr += 1; |
|
| 3210 |
- } |
|
| 3211 |
- break; |
|
| 3212 |
- case 0xd1: /* STZkr */ |
|
| 3213 |
- {
|
|
| 3214 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 3215 |
- Uint8 b = u->rst.dat[u->rst.ptr - 2]; |
|
| 3216 |
- poke8(u->ram.dat, a, b); |
|
| 3217 |
-#ifndef NO_STACK_CHECKS |
|
| 3218 |
- if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 3219 |
- u->rst.error = 1; |
|
| 3220 |
- goto error; |
|
| 3221 |
- } |
|
| 3222 |
-#endif |
|
| 3223 |
- } |
|
| 3224 |
- break; |
|
| 3225 |
- case 0xd2: /* LDRkr */ |
|
| 3226 |
- {
|
|
| 3227 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 3228 |
- u->rst.dat[u->rst.ptr] = peek8(u->ram.dat, u->ram.ptr + (Sint8)a); |
|
| 3229 |
-#ifndef NO_STACK_CHECKS |
|
| 3230 |
- if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
| 3231 |
- u->rst.error = 1; |
|
| 3232 |
- goto error; |
|
| 3233 |
- } |
|
| 3234 |
- if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
| 3235 |
- u->rst.error = 2; |
|
| 3236 |
- goto error; |
|
| 3237 |
- } |
|
| 3238 |
-#endif |
|
| 3239 |
- u->rst.ptr += 1; |
|
| 3240 |
- } |
|
| 3241 |
- break; |
|
| 3242 |
- case 0xd3: /* STRkr */ |
|
| 3243 |
- {
|
|
| 3244 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 3245 |
- Uint8 b = u->rst.dat[u->rst.ptr - 2]; |
|
| 3246 |
- poke8(u->ram.dat, u->ram.ptr + (Sint8)a, b); |
|
| 3247 |
-#ifndef NO_STACK_CHECKS |
|
| 3248 |
- if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 3249 |
- u->rst.error = 1; |
|
| 3250 |
- goto error; |
|
| 3251 |
- } |
|
| 3252 |
-#endif |
|
| 3253 |
- } |
|
| 3254 |
- break; |
|
| 3255 |
- case 0xd4: /* LDAkr */ |
|
| 3256 |
- {
|
|
| 3257 |
- Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); |
|
| 3258 |
- u->rst.dat[u->rst.ptr] = peek8(u->ram.dat, a); |
|
| 3259 |
-#ifndef NO_STACK_CHECKS |
|
| 3260 |
- if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 3261 |
- u->rst.error = 1; |
|
| 3262 |
- goto error; |
|
| 3263 |
- } |
|
| 3264 |
- if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
| 3265 |
- u->rst.error = 2; |
|
| 3266 |
- goto error; |
|
| 3267 |
- } |
|
| 3268 |
-#endif |
|
| 3269 |
- u->rst.ptr += 1; |
|
| 3270 |
- } |
|
| 3271 |
- break; |
|
| 3272 |
- case 0xd5: /* STAkr */ |
|
| 3273 |
- {
|
|
| 3274 |
- Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); |
|
| 3275 |
- Uint8 b = u->rst.dat[u->rst.ptr - 3]; |
|
| 3276 |
- poke8(u->ram.dat, a, b); |
|
| 3277 |
-#ifndef NO_STACK_CHECKS |
|
| 3278 |
- if(__builtin_expect(u->rst.ptr < 3, 0)) {
|
|
| 3279 |
- u->rst.error = 1; |
|
| 3280 |
- goto error; |
|
| 3281 |
- } |
|
| 3282 |
-#endif |
|
| 3283 |
- } |
|
| 3284 |
- break; |
|
| 3285 |
- case 0xd6: /* DEIkr */ |
|
| 3286 |
- {
|
|
| 3287 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 3288 |
- u->rst.dat[u->rst.ptr] = devr8(&u->dev[a >> 4], a); |
|
| 3289 |
-#ifndef NO_STACK_CHECKS |
|
| 3290 |
- if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
| 3291 |
- u->rst.error = 1; |
|
| 3292 |
- goto error; |
|
| 3293 |
- } |
|
| 3294 |
- if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
| 3295 |
- u->rst.error = 2; |
|
| 3296 |
- goto error; |
|
| 3297 |
- } |
|
| 3298 |
-#endif |
|
| 3299 |
- u->rst.ptr += 1; |
|
| 3300 |
- } |
|
| 3301 |
- break; |
|
| 3302 |
- case 0xd7: /* DEOkr */ |
|
| 3303 |
- {
|
|
| 3304 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 3305 |
- devw8(&u->dev[a >> 4], a, b); |
|
| 3306 |
-#ifndef NO_STACK_CHECKS |
|
| 3307 |
- if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 3308 |
- u->rst.error = 1; |
|
| 3309 |
- goto error; |
|
| 3310 |
- } |
|
| 3311 |
-#endif |
|
| 3312 |
- } |
|
| 3313 |
- break; |
|
| 3314 |
- case 0xd8: /* ADDkr */ |
|
| 3315 |
- {
|
|
| 3316 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 3317 |
- u->rst.dat[u->rst.ptr] = b + a; |
|
| 3318 |
-#ifndef NO_STACK_CHECKS |
|
| 3319 |
- if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 3320 |
- u->rst.error = 1; |
|
| 3321 |
- goto error; |
|
| 3322 |
- } |
|
| 3323 |
- if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
| 3324 |
- u->rst.error = 2; |
|
| 3325 |
- goto error; |
|
| 3326 |
- } |
|
| 3327 |
-#endif |
|
| 3328 |
- u->rst.ptr += 1; |
|
| 3329 |
- } |
|
| 3330 |
- break; |
|
| 3331 |
- case 0xd9: /* SUBkr */ |
|
| 3332 |
- {
|
|
| 3333 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 3334 |
- u->rst.dat[u->rst.ptr] = b - a; |
|
| 3335 |
-#ifndef NO_STACK_CHECKS |
|
| 3336 |
- if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 3337 |
- u->rst.error = 1; |
|
| 3338 |
- goto error; |
|
| 3339 |
- } |
|
| 3340 |
- if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
| 3341 |
- u->rst.error = 2; |
|
| 3342 |
- goto error; |
|
| 3343 |
- } |
|
| 3344 |
-#endif |
|
| 3345 |
- u->rst.ptr += 1; |
|
| 3346 |
- } |
|
| 3347 |
- break; |
|
| 3348 |
- case 0xda: /* MULkr */ |
|
| 3349 |
- {
|
|
| 3350 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 3351 |
- u->rst.dat[u->rst.ptr] = b * a; |
|
| 3352 |
-#ifndef NO_STACK_CHECKS |
|
| 3353 |
- if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 3354 |
- u->rst.error = 1; |
|
| 3355 |
- goto error; |
|
| 3356 |
- } |
|
| 3357 |
- if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
| 3358 |
- u->rst.error = 2; |
|
| 3359 |
- goto error; |
|
| 3360 |
- } |
|
| 3361 |
-#endif |
|
| 3362 |
- u->rst.ptr += 1; |
|
| 3363 |
- } |
|
| 3364 |
- break; |
|
| 3365 |
- case 0xdb: /* DIVkr */ |
|
| 3366 |
- {
|
|
| 3367 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 3368 |
- if(a == 0) {
|
|
| 3369 |
- u->rst.error = 3; |
|
| 3370 |
-#ifndef NO_STACK_CHECKS |
|
| 3371 |
- goto error; |
|
| 3372 |
-#endif |
|
| 3373 |
- a = 1; |
|
| 3374 |
- } |
|
| 3375 |
- u->rst.dat[u->rst.ptr] = b / a; |
|
| 3376 |
-#ifndef NO_STACK_CHECKS |
|
| 3377 |
- if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 3378 |
- u->rst.error = 1; |
|
| 3379 |
- goto error; |
|
| 3380 |
- } |
|
| 3381 |
- if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
| 3382 |
- u->rst.error = 2; |
|
| 3383 |
- goto error; |
|
| 3384 |
- } |
|
| 3385 |
-#endif |
|
| 3386 |
- u->rst.ptr += 1; |
|
| 3387 |
- } |
|
| 3388 |
- break; |
|
| 3389 |
- case 0xdc: /* ANDkr */ |
|
| 3390 |
- {
|
|
| 3391 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 3392 |
- u->rst.dat[u->rst.ptr] = b & a; |
|
| 3393 |
-#ifndef NO_STACK_CHECKS |
|
| 3394 |
- if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 3395 |
- u->rst.error = 1; |
|
| 3396 |
- goto error; |
|
| 3397 |
- } |
|
| 3398 |
- if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
| 3399 |
- u->rst.error = 2; |
|
| 3400 |
- goto error; |
|
| 3401 |
- } |
|
| 3402 |
-#endif |
|
| 3403 |
- u->rst.ptr += 1; |
|
| 3404 |
- } |
|
| 3405 |
- break; |
|
| 3406 |
- case 0xdd: /* ORAkr */ |
|
| 3407 |
- {
|
|
| 3408 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 3409 |
- u->rst.dat[u->rst.ptr] = b | a; |
|
| 3410 |
-#ifndef NO_STACK_CHECKS |
|
| 3411 |
- if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 3412 |
- u->rst.error = 1; |
|
| 3413 |
- goto error; |
|
| 3414 |
- } |
|
| 3415 |
- if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
| 3416 |
- u->rst.error = 2; |
|
| 3417 |
- goto error; |
|
| 3418 |
- } |
|
| 3419 |
-#endif |
|
| 3420 |
- u->rst.ptr += 1; |
|
| 3421 |
- } |
|
| 3422 |
- break; |
|
| 3423 |
- case 0xde: /* EORkr */ |
|
| 3424 |
- {
|
|
| 3425 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 3426 |
- u->rst.dat[u->rst.ptr] = b ^ a; |
|
| 3427 |
-#ifndef NO_STACK_CHECKS |
|
| 3428 |
- if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 3429 |
- u->rst.error = 1; |
|
| 3430 |
- goto error; |
|
| 3431 |
- } |
|
| 3432 |
- if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
| 3433 |
- u->rst.error = 2; |
|
| 3434 |
- goto error; |
|
| 3435 |
- } |
|
| 3436 |
-#endif |
|
| 3437 |
- u->rst.ptr += 1; |
|
| 3438 |
- } |
|
| 3439 |
- break; |
|
| 3440 |
- case 0xdf: /* SFTkr */ |
|
| 3441 |
- {
|
|
| 3442 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 3443 |
- u->rst.dat[u->rst.ptr] = b >> (a & 0x0f) << ((a & 0xf0) >> 4); |
|
| 3444 |
-#ifndef NO_STACK_CHECKS |
|
| 3445 |
- if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 3446 |
- u->rst.error = 1; |
|
| 3447 |
- goto error; |
|
| 3448 |
- } |
|
| 3449 |
- if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
| 3450 |
- u->rst.error = 2; |
|
| 3451 |
- goto error; |
|
| 3452 |
- } |
|
| 3453 |
-#endif |
|
| 3454 |
- u->rst.ptr += 1; |
|
| 3455 |
- } |
|
| 3456 |
- break; |
|
| 3457 |
- case 0xe0: /* LIT2r */ |
|
| 3458 |
- case 0x60: /* LIT2r_deprecated */ |
|
| 3459 |
- {
|
|
| 3460 |
- u->rst.dat[u->rst.ptr] = peek8(u->ram.dat, u->ram.ptr++); |
|
| 3461 |
- u->rst.dat[u->rst.ptr + 1] = peek8(u->ram.dat, u->ram.ptr++); |
|
| 3462 |
-#ifndef NO_STACK_CHECKS |
|
| 3463 |
- if(__builtin_expect(u->rst.ptr > 253, 0)) {
|
|
| 3464 |
- u->rst.error = 2; |
|
| 3465 |
- goto error; |
|
| 3466 |
- } |
|
| 3467 |
-#endif |
|
| 3468 |
- u->rst.ptr += 2; |
|
| 3469 |
- } |
|
| 3470 |
- break; |
|
| 3471 |
- case 0xe1: /* INC2kr */ |
|
| 3472 |
- {
|
|
| 3473 |
- Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); |
|
| 3474 |
- u->rst.dat[u->rst.ptr] = (a + 1) >> 8; |
|
| 3475 |
- u->rst.dat[u->rst.ptr + 1] = (a + 1) & 0xff; |
|
| 3476 |
-#ifndef NO_STACK_CHECKS |
|
| 3477 |
- if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 3478 |
- u->rst.error = 1; |
|
| 3479 |
- goto error; |
|
| 3480 |
- } |
|
| 3481 |
- if(__builtin_expect(u->rst.ptr > 253, 0)) {
|
|
| 3482 |
- u->rst.error = 2; |
|
| 3483 |
- goto error; |
|
| 3484 |
- } |
|
| 3485 |
-#endif |
|
| 3486 |
- u->rst.ptr += 2; |
|
| 3487 |
- } |
|
| 3488 |
- break; |
|
| 3489 |
- case 0xe2: /* POP2kr */ |
|
| 3490 |
- {
|
|
| 3491 |
- (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); |
|
| 3492 |
-#ifndef NO_STACK_CHECKS |
|
| 3493 |
- if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 3494 |
- u->rst.error = 1; |
|
| 3495 |
- goto error; |
|
| 3496 |
- } |
|
| 3497 |
-#endif |
|
| 3498 |
- } |
|
| 3499 |
- break; |
|
| 3500 |
- case 0xe3: /* DUP2kr */ |
|
| 3501 |
- {
|
|
| 3502 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 3503 |
- u->rst.dat[u->rst.ptr] = b; |
|
| 3504 |
- u->rst.dat[u->rst.ptr + 1] = a; |
|
| 3505 |
- u->rst.dat[u->rst.ptr + 2] = b; |
|
| 3506 |
- u->rst.dat[u->rst.ptr + 3] = a; |
|
| 3507 |
-#ifndef NO_STACK_CHECKS |
|
| 3508 |
- if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 3509 |
- u->rst.error = 1; |
|
| 3510 |
- goto error; |
|
| 3511 |
- } |
|
| 3512 |
- if(__builtin_expect(u->rst.ptr > 251, 0)) {
|
|
| 3513 |
- u->rst.error = 2; |
|
| 3514 |
- goto error; |
|
| 3515 |
- } |
|
| 3516 |
-#endif |
|
| 3517 |
- u->rst.ptr += 4; |
|
| 3518 |
- } |
|
| 3519 |
- break; |
|
| 3520 |
- case 0xe4: /* NIP2kr */ |
|
| 3521 |
- {
|
|
| 3522 |
- Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); |
|
| 3523 |
- (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); |
|
| 3524 |
- u->rst.dat[u->rst.ptr] = a >> 8; |
|
| 3525 |
- u->rst.dat[u->rst.ptr + 1] = a & 0xff; |
|
| 3526 |
-#ifndef NO_STACK_CHECKS |
|
| 3527 |
- if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
| 3528 |
- u->rst.error = 1; |
|
| 3529 |
- goto error; |
|
| 3530 |
- } |
|
| 3531 |
- if(__builtin_expect(u->rst.ptr > 253, 0)) {
|
|
| 3532 |
- u->rst.error = 2; |
|
| 3533 |
- goto error; |
|
| 3534 |
- } |
|
| 3535 |
-#endif |
|
| 3536 |
- u->rst.ptr += 2; |
|
| 3537 |
- } |
|
| 3538 |
- break; |
|
| 3539 |
- case 0xe5: /* SWP2kr */ |
|
| 3540 |
- {
|
|
| 3541 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2], c = u->rst.dat[u->rst.ptr - 3], d = u->rst.dat[u->rst.ptr - 4]; |
|
| 3542 |
- u->rst.dat[u->rst.ptr] = b; |
|
| 3543 |
- u->rst.dat[u->rst.ptr + 1] = a; |
|
| 3544 |
- u->rst.dat[u->rst.ptr + 2] = d; |
|
| 3545 |
- u->rst.dat[u->rst.ptr + 3] = c; |
|
| 3546 |
-#ifndef NO_STACK_CHECKS |
|
| 3547 |
- if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
| 3548 |
- u->rst.error = 1; |
|
| 3549 |
- goto error; |
|
| 3550 |
- } |
|
| 3551 |
- if(__builtin_expect(u->rst.ptr > 251, 0)) {
|
|
| 3552 |
- u->rst.error = 2; |
|
| 3553 |
- goto error; |
|
| 3554 |
- } |
|
| 3555 |
-#endif |
|
| 3556 |
- u->rst.ptr += 4; |
|
| 3557 |
- } |
|
| 3558 |
- break; |
|
| 3559 |
- case 0xe6: /* OVR2kr */ |
|
| 3560 |
- {
|
|
| 3561 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2], c = u->rst.dat[u->rst.ptr - 3], d = u->rst.dat[u->rst.ptr - 4]; |
|
| 3562 |
- u->rst.dat[u->rst.ptr] = d; |
|
| 3563 |
- u->rst.dat[u->rst.ptr + 1] = c; |
|
| 3564 |
- u->rst.dat[u->rst.ptr + 2] = b; |
|
| 3565 |
- u->rst.dat[u->rst.ptr + 3] = a; |
|
| 3566 |
- u->rst.dat[u->rst.ptr + 4] = d; |
|
| 3567 |
- u->rst.dat[u->rst.ptr + 5] = c; |
|
| 3568 |
-#ifndef NO_STACK_CHECKS |
|
| 3569 |
- if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
| 3570 |
- u->rst.error = 1; |
|
| 3571 |
- goto error; |
|
| 3572 |
- } |
|
| 3573 |
- if(__builtin_expect(u->rst.ptr > 249, 0)) {
|
|
| 3574 |
- u->rst.error = 2; |
|
| 3575 |
- goto error; |
|
| 3576 |
- } |
|
| 3577 |
-#endif |
|
| 3578 |
- u->rst.ptr += 6; |
|
| 3579 |
- } |
|
| 3580 |
- break; |
|
| 3581 |
- case 0xe7: /* ROT2kr */ |
|
| 3582 |
- {
|
|
| 3583 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2], c = u->rst.dat[u->rst.ptr - 3], d = u->rst.dat[u->rst.ptr - 4], e = u->rst.dat[u->rst.ptr - 5], f = u->rst.dat[u->rst.ptr - 6]; |
|
| 3584 |
- u->rst.dat[u->rst.ptr] = d; |
|
| 3585 |
- u->rst.dat[u->rst.ptr + 1] = c; |
|
| 3586 |
- u->rst.dat[u->rst.ptr + 2] = b; |
|
| 3587 |
- u->rst.dat[u->rst.ptr + 3] = a; |
|
| 3588 |
- u->rst.dat[u->rst.ptr + 4] = f; |
|
| 3589 |
- u->rst.dat[u->rst.ptr + 5] = e; |
|
| 3590 |
-#ifndef NO_STACK_CHECKS |
|
| 3591 |
- if(__builtin_expect(u->rst.ptr < 6, 0)) {
|
|
| 3592 |
- u->rst.error = 1; |
|
| 3593 |
- goto error; |
|
| 3594 |
- } |
|
| 3595 |
- if(__builtin_expect(u->rst.ptr > 249, 0)) {
|
|
| 3596 |
- u->rst.error = 2; |
|
| 3597 |
- goto error; |
|
| 3598 |
- } |
|
| 3599 |
-#endif |
|
| 3600 |
- u->rst.ptr += 6; |
|
| 3601 |
- } |
|
| 3602 |
- break; |
|
| 3603 |
- case 0xe8: /* EQU2kr */ |
|
| 3604 |
- {
|
|
| 3605 |
- Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); |
|
| 3606 |
- u->rst.dat[u->rst.ptr] = b == a; |
|
| 3607 |
-#ifndef NO_STACK_CHECKS |
|
| 3608 |
- if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
| 3609 |
- u->rst.error = 1; |
|
| 3610 |
- goto error; |
|
| 3611 |
- } |
|
| 3612 |
- if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
| 3613 |
- u->rst.error = 2; |
|
| 3614 |
- goto error; |
|
| 3615 |
- } |
|
| 3616 |
-#endif |
|
| 3617 |
- u->rst.ptr += 1; |
|
| 3618 |
- } |
|
| 3619 |
- break; |
|
| 3620 |
- case 0xe9: /* NEQ2kr */ |
|
| 3621 |
- {
|
|
| 3622 |
- Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); |
|
| 3623 |
- u->rst.dat[u->rst.ptr] = b != a; |
|
| 3624 |
-#ifndef NO_STACK_CHECKS |
|
| 3625 |
- if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
| 3626 |
- u->rst.error = 1; |
|
| 3627 |
- goto error; |
|
| 3628 |
- } |
|
| 3629 |
- if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
| 3630 |
- u->rst.error = 2; |
|
| 3631 |
- goto error; |
|
| 3632 |
- } |
|
| 3633 |
-#endif |
|
| 3634 |
- u->rst.ptr += 1; |
|
| 3635 |
- } |
|
| 3636 |
- break; |
|
| 3637 |
- case 0xea: /* GTH2kr */ |
|
| 3638 |
- {
|
|
| 3639 |
- Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); |
|
| 3640 |
- u->rst.dat[u->rst.ptr] = b > a; |
|
| 3641 |
-#ifndef NO_STACK_CHECKS |
|
| 3642 |
- if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
| 3643 |
- u->rst.error = 1; |
|
| 3644 |
- goto error; |
|
| 3645 |
- } |
|
| 3646 |
- if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
| 3647 |
- u->rst.error = 2; |
|
| 3648 |
- goto error; |
|
| 3649 |
- } |
|
| 3650 |
-#endif |
|
| 3651 |
- u->rst.ptr += 1; |
|
| 3652 |
- } |
|
| 3653 |
- break; |
|
| 3654 |
- case 0xeb: /* LTH2kr */ |
|
| 3655 |
- {
|
|
| 3656 |
- Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); |
|
| 3657 |
- u->rst.dat[u->rst.ptr] = b < a; |
|
| 3658 |
-#ifndef NO_STACK_CHECKS |
|
| 3659 |
- if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
| 3660 |
- u->rst.error = 1; |
|
| 3661 |
- goto error; |
|
| 3662 |
- } |
|
| 3663 |
- if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
| 3664 |
- u->rst.error = 2; |
|
| 3665 |
- goto error; |
|
| 3666 |
- } |
|
| 3667 |
-#endif |
|
| 3668 |
- u->rst.ptr += 1; |
|
| 3669 |
- } |
|
| 3670 |
- break; |
|
| 3671 |
- case 0xec: /* JMP2kr */ |
|
| 3672 |
- {
|
|
| 3673 |
- u->ram.ptr = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); |
|
| 3674 |
-#ifndef NO_STACK_CHECKS |
|
| 3675 |
- if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 3676 |
- u->rst.error = 1; |
|
| 3677 |
- goto error; |
|
| 3678 |
- } |
|
| 3679 |
-#endif |
|
| 3680 |
- } |
|
| 3681 |
- break; |
|
| 3682 |
- case 0xed: /* JCN2kr */ |
|
| 3683 |
- {
|
|
| 3684 |
- Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); |
|
| 3685 |
- if(u->rst.dat[u->rst.ptr - 3]) u->ram.ptr = a; |
|
| 3686 |
-#ifndef NO_STACK_CHECKS |
|
| 3687 |
- if(__builtin_expect(u->rst.ptr < 3, 0)) {
|
|
| 3688 |
- u->rst.error = 1; |
|
| 3689 |
- goto error; |
|
| 3690 |
- } |
|
| 3691 |
-#endif |
|
| 3692 |
- } |
|
| 3693 |
- break; |
|
| 3694 |
- case 0xee: /* JSR2kr */ |
|
| 3695 |
- {
|
|
| 3696 |
- u->wst.dat[u->wst.ptr] = u->ram.ptr >> 8; |
|
| 3697 |
- u->wst.dat[u->wst.ptr + 1] = u->ram.ptr & 0xff; |
|
| 3698 |
- u->ram.ptr = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); |
|
| 3699 |
-#ifndef NO_STACK_CHECKS |
|
| 3700 |
- if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 3701 |
- u->rst.error = 1; |
|
| 3702 |
- goto error; |
|
| 3703 |
- } |
|
| 3704 |
- if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
| 3705 |
- u->wst.error = 2; |
|
| 3706 |
- goto error; |
|
| 3707 |
- } |
|
| 3708 |
-#endif |
|
| 3709 |
- u->wst.ptr += 2; |
|
| 3710 |
- } |
|
| 3711 |
- break; |
|
| 3712 |
- case 0xef: /* STH2kr */ |
|
| 3713 |
- {
|
|
| 3714 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 3715 |
- u->wst.dat[u->wst.ptr] = b; |
|
| 3716 |
- u->wst.dat[u->wst.ptr + 1] = a; |
|
| 3717 |
-#ifndef NO_STACK_CHECKS |
|
| 3718 |
- if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 3719 |
- u->rst.error = 1; |
|
| 3720 |
- goto error; |
|
| 3721 |
- } |
|
| 3722 |
- if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
| 3723 |
- u->wst.error = 2; |
|
| 3724 |
- goto error; |
|
| 3725 |
- } |
|
| 3726 |
-#endif |
|
| 3727 |
- u->wst.ptr += 2; |
|
| 3728 |
- } |
|
| 3729 |
- break; |
|
| 3730 |
- case 0xf0: /* LDZ2kr */ |
|
| 3731 |
- {
|
|
| 3732 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 3733 |
- u->rst.dat[u->rst.ptr] = peek8(u->ram.dat, a); |
|
| 3734 |
- u->rst.dat[u->rst.ptr + 1] = peek8(u->ram.dat, a + 1); |
|
| 3735 |
-#ifndef NO_STACK_CHECKS |
|
| 3736 |
- if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
| 3737 |
- u->rst.error = 1; |
|
| 3738 |
- goto error; |
|
| 3739 |
- } |
|
| 3740 |
- if(__builtin_expect(u->rst.ptr > 253, 0)) {
|
|
| 3741 |
- u->rst.error = 2; |
|
| 3742 |
- goto error; |
|
| 3743 |
- } |
|
| 3744 |
-#endif |
|
| 3745 |
- u->rst.ptr += 2; |
|
| 3746 |
- } |
|
| 3747 |
- break; |
|
| 3748 |
- case 0xf1: /* STZ2kr */ |
|
| 3749 |
- {
|
|
| 3750 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 3751 |
- Uint16 b = (u->rst.dat[u->rst.ptr - 2] | (u->rst.dat[u->rst.ptr - 3] << 8)); |
|
| 3752 |
- poke16(u->ram.dat, a, b); |
|
| 3753 |
-#ifndef NO_STACK_CHECKS |
|
| 3754 |
- if(__builtin_expect(u->rst.ptr < 3, 0)) {
|
|
| 3755 |
- u->rst.error = 1; |
|
| 3756 |
- goto error; |
|
| 3757 |
- } |
|
| 3758 |
-#endif |
|
| 3759 |
- } |
|
| 3760 |
- break; |
|
| 3761 |
- case 0xf2: /* LDR2kr */ |
|
| 3762 |
- {
|
|
| 3763 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 3764 |
- u->rst.dat[u->rst.ptr] = peek8(u->ram.dat, u->ram.ptr + (Sint8)a); |
|
| 3765 |
- u->rst.dat[u->rst.ptr + 1] = peek8(u->ram.dat, u->ram.ptr + (Sint8)a + 1); |
|
| 3766 |
-#ifndef NO_STACK_CHECKS |
|
| 3767 |
- if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
| 3768 |
- u->rst.error = 1; |
|
| 3769 |
- goto error; |
|
| 3770 |
- } |
|
| 3771 |
- if(__builtin_expect(u->rst.ptr > 253, 0)) {
|
|
| 3772 |
- u->rst.error = 2; |
|
| 3773 |
- goto error; |
|
| 3774 |
- } |
|
| 3775 |
-#endif |
|
| 3776 |
- u->rst.ptr += 2; |
|
| 3777 |
- } |
|
| 3778 |
- break; |
|
| 3779 |
- case 0xf3: /* STR2kr */ |
|
| 3780 |
- {
|
|
| 3781 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 3782 |
- Uint16 b = (u->rst.dat[u->rst.ptr - 2] | (u->rst.dat[u->rst.ptr - 3] << 8)); |
|
| 3783 |
- poke16(u->ram.dat, u->ram.ptr + (Sint8)a, b); |
|
| 3784 |
-#ifndef NO_STACK_CHECKS |
|
| 3785 |
- if(__builtin_expect(u->rst.ptr < 3, 0)) {
|
|
| 3786 |
- u->rst.error = 1; |
|
| 3787 |
- goto error; |
|
| 3788 |
- } |
|
| 3789 |
-#endif |
|
| 3790 |
- } |
|
| 3791 |
- break; |
|
| 3792 |
- case 0xf4: /* LDA2kr */ |
|
| 3793 |
- {
|
|
| 3794 |
- Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); |
|
| 3795 |
- u->rst.dat[u->rst.ptr] = peek8(u->ram.dat, a); |
|
| 3796 |
- u->rst.dat[u->rst.ptr + 1] = peek8(u->ram.dat, a + 1); |
|
| 3797 |
-#ifndef NO_STACK_CHECKS |
|
| 3798 |
- if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 3799 |
- u->rst.error = 1; |
|
| 3800 |
- goto error; |
|
| 3801 |
- } |
|
| 3802 |
- if(__builtin_expect(u->rst.ptr > 253, 0)) {
|
|
| 3803 |
- u->rst.error = 2; |
|
| 3804 |
- goto error; |
|
| 3805 |
- } |
|
| 3806 |
-#endif |
|
| 3807 |
- u->rst.ptr += 2; |
|
| 3808 |
- } |
|
| 3809 |
- break; |
|
| 3810 |
- case 0xf5: /* STA2kr */ |
|
| 3811 |
- {
|
|
| 3812 |
- Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); |
|
| 3813 |
- Uint16 b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); |
|
| 3814 |
- poke16(u->ram.dat, a, b); |
|
| 3815 |
-#ifndef NO_STACK_CHECKS |
|
| 3816 |
- if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
| 3817 |
- u->rst.error = 1; |
|
| 3818 |
- goto error; |
|
| 3819 |
- } |
|
| 3820 |
-#endif |
|
| 3821 |
- } |
|
| 3822 |
- break; |
|
| 3823 |
- case 0xf6: /* DEI2kr */ |
|
| 3824 |
- {
|
|
| 3825 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 3826 |
- u->rst.dat[u->rst.ptr] = devr8(&u->dev[a >> 4], a); |
|
| 3827 |
- u->rst.dat[u->rst.ptr + 1] = devr8(&u->dev[a >> 4], a + 1); |
|
| 3828 |
-#ifndef NO_STACK_CHECKS |
|
| 3829 |
- if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
| 3830 |
- u->rst.error = 1; |
|
| 3831 |
- goto error; |
|
| 3832 |
- } |
|
| 3833 |
- if(__builtin_expect(u->rst.ptr > 253, 0)) {
|
|
| 3834 |
- u->rst.error = 2; |
|
| 3835 |
- goto error; |
|
| 3836 |
- } |
|
| 3837 |
-#endif |
|
| 3838 |
- u->rst.ptr += 2; |
|
| 3839 |
- } |
|
| 3840 |
- break; |
|
| 3841 |
- case 0xf7: /* DEO2kr */ |
|
| 3842 |
- {
|
|
| 3843 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 3844 |
- Uint16 b = (u->rst.dat[u->rst.ptr - 2] | (u->rst.dat[u->rst.ptr - 3] << 8)); |
|
| 3845 |
- devw16(&u->dev[a >> 4], a, b); |
|
| 3846 |
-#ifndef NO_STACK_CHECKS |
|
| 3847 |
- if(__builtin_expect(u->rst.ptr < 3, 0)) {
|
|
| 3848 |
- u->rst.error = 1; |
|
| 3849 |
- goto error; |
|
| 3850 |
- } |
|
| 3851 |
-#endif |
|
| 3852 |
- } |
|
| 3853 |
- break; |
|
| 3854 |
- case 0xf8: /* ADD2kr */ |
|
| 3855 |
- {
|
|
| 3856 |
- Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); |
|
| 3857 |
- u->rst.dat[u->rst.ptr] = (b + a) >> 8; |
|
| 3858 |
- u->rst.dat[u->rst.ptr + 1] = (b + a) & 0xff; |
|
| 3859 |
-#ifndef NO_STACK_CHECKS |
|
| 3860 |
- if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
| 3861 |
- u->rst.error = 1; |
|
| 3862 |
- goto error; |
|
| 3863 |
- } |
|
| 3864 |
- if(__builtin_expect(u->rst.ptr > 253, 0)) {
|
|
| 3865 |
- u->rst.error = 2; |
|
| 3866 |
- goto error; |
|
| 3867 |
- } |
|
| 3868 |
-#endif |
|
| 3869 |
- u->rst.ptr += 2; |
|
| 3870 |
- } |
|
| 3871 |
- break; |
|
| 3872 |
- case 0xf9: /* SUB2kr */ |
|
| 3873 |
- {
|
|
| 3874 |
- Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); |
|
| 3875 |
- u->rst.dat[u->rst.ptr] = (b - a) >> 8; |
|
| 3876 |
- u->rst.dat[u->rst.ptr + 1] = (b - a) & 0xff; |
|
| 3877 |
-#ifndef NO_STACK_CHECKS |
|
| 3878 |
- if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
| 3879 |
- u->rst.error = 1; |
|
| 3880 |
- goto error; |
|
| 3881 |
- } |
|
| 3882 |
- if(__builtin_expect(u->rst.ptr > 253, 0)) {
|
|
| 3883 |
- u->rst.error = 2; |
|
| 3884 |
- goto error; |
|
| 3885 |
- } |
|
| 3886 |
-#endif |
|
| 3887 |
- u->rst.ptr += 2; |
|
| 3888 |
- } |
|
| 3889 |
- break; |
|
| 3890 |
- case 0xfa: /* MUL2kr */ |
|
| 3891 |
- {
|
|
| 3892 |
- Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); |
|
| 3893 |
- u->rst.dat[u->rst.ptr] = (b * a) >> 8; |
|
| 3894 |
- u->rst.dat[u->rst.ptr + 1] = (b * a) & 0xff; |
|
| 3895 |
-#ifndef NO_STACK_CHECKS |
|
| 3896 |
- if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
| 3897 |
- u->rst.error = 1; |
|
| 3898 |
- goto error; |
|
| 3899 |
- } |
|
| 3900 |
- if(__builtin_expect(u->rst.ptr > 253, 0)) {
|
|
| 3901 |
- u->rst.error = 2; |
|
| 3902 |
- goto error; |
|
| 3903 |
- } |
|
| 3904 |
-#endif |
|
| 3905 |
- u->rst.ptr += 2; |
|
| 3906 |
- } |
|
| 3907 |
- break; |
|
| 3908 |
- case 0xfb: /* DIV2kr */ |
|
| 3909 |
- {
|
|
| 3910 |
- Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); |
|
| 3911 |
- if(a == 0) {
|
|
| 3912 |
- u->rst.error = 3; |
|
| 3913 |
-#ifndef NO_STACK_CHECKS |
|
| 3914 |
- goto error; |
|
| 3915 |
-#endif |
|
| 3916 |
- a = 1; |
|
| 3917 |
- } |
|
| 3918 |
- u->rst.dat[u->rst.ptr] = (b / a) >> 8; |
|
| 3919 |
- u->rst.dat[u->rst.ptr + 1] = (b / a) & 0xff; |
|
| 3920 |
-#ifndef NO_STACK_CHECKS |
|
| 3921 |
- if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
| 3922 |
- u->rst.error = 1; |
|
| 3923 |
- goto error; |
|
| 3924 |
- } |
|
| 3925 |
- if(__builtin_expect(u->rst.ptr > 253, 0)) {
|
|
| 3926 |
- u->rst.error = 2; |
|
| 3927 |
- goto error; |
|
| 3928 |
- } |
|
| 3929 |
-#endif |
|
| 3930 |
- u->rst.ptr += 2; |
|
| 3931 |
- } |
|
| 3932 |
- break; |
|
| 3933 |
- case 0xfc: /* AND2kr */ |
|
| 3934 |
- {
|
|
| 3935 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2], c = u->rst.dat[u->rst.ptr - 3], d = u->rst.dat[u->rst.ptr - 4]; |
|
| 3936 |
- u->rst.dat[u->rst.ptr] = d & b; |
|
| 3937 |
- u->rst.dat[u->rst.ptr + 1] = c & a; |
|
| 3938 |
-#ifndef NO_STACK_CHECKS |
|
| 3939 |
- if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
| 3940 |
- u->rst.error = 1; |
|
| 3941 |
- goto error; |
|
| 3942 |
- } |
|
| 3943 |
- if(__builtin_expect(u->rst.ptr > 253, 0)) {
|
|
| 3944 |
- u->rst.error = 2; |
|
| 3945 |
- goto error; |
|
| 3946 |
- } |
|
| 3947 |
-#endif |
|
| 3948 |
- u->rst.ptr += 2; |
|
| 3949 |
- } |
|
| 3950 |
- break; |
|
| 3951 |
- case 0xfd: /* ORA2kr */ |
|
| 3952 |
- {
|
|
| 3953 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2], c = u->rst.dat[u->rst.ptr - 3], d = u->rst.dat[u->rst.ptr - 4]; |
|
| 3954 |
- u->rst.dat[u->rst.ptr] = d | b; |
|
| 3955 |
- u->rst.dat[u->rst.ptr + 1] = c | a; |
|
| 3956 |
-#ifndef NO_STACK_CHECKS |
|
| 3957 |
- if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
| 3958 |
- u->rst.error = 1; |
|
| 3959 |
- goto error; |
|
| 3960 |
- } |
|
| 3961 |
- if(__builtin_expect(u->rst.ptr > 253, 0)) {
|
|
| 3962 |
- u->rst.error = 2; |
|
| 3963 |
- goto error; |
|
| 3964 |
- } |
|
| 3965 |
-#endif |
|
| 3966 |
- u->rst.ptr += 2; |
|
| 3967 |
- } |
|
| 3968 |
- break; |
|
| 3969 |
- case 0xfe: /* EOR2kr */ |
|
| 3970 |
- {
|
|
| 3971 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2], c = u->rst.dat[u->rst.ptr - 3], d = u->rst.dat[u->rst.ptr - 4]; |
|
| 3972 |
- u->rst.dat[u->rst.ptr] = d ^ b; |
|
| 3973 |
- u->rst.dat[u->rst.ptr + 1] = c ^ a; |
|
| 3974 |
-#ifndef NO_STACK_CHECKS |
|
| 3975 |
- if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
| 3976 |
- u->rst.error = 1; |
|
| 3977 |
- goto error; |
|
| 3978 |
- } |
|
| 3979 |
- if(__builtin_expect(u->rst.ptr > 253, 0)) {
|
|
| 3980 |
- u->rst.error = 2; |
|
| 3981 |
- goto error; |
|
| 3982 |
- } |
|
| 3983 |
-#endif |
|
| 3984 |
- u->rst.ptr += 2; |
|
| 3985 |
- } |
|
| 3986 |
- break; |
|
| 3987 |
- case 0xff: /* SFT2kr */ |
|
| 3988 |
- {
|
|
| 3989 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 3990 |
- Uint16 b = (u->rst.dat[u->rst.ptr - 2] | (u->rst.dat[u->rst.ptr - 3] << 8)); |
|
| 3991 |
- u->rst.dat[u->rst.ptr] = (b >> (a & 0x0f) << ((a & 0xf0) >> 4)) >> 8; |
|
| 3992 |
- u->rst.dat[u->rst.ptr + 1] = (b >> (a & 0x0f) << ((a & 0xf0) >> 4)) & 0xff; |
|
| 3993 |
-#ifndef NO_STACK_CHECKS |
|
| 3994 |
- if(__builtin_expect(u->rst.ptr < 3, 0)) {
|
|
| 3995 |
- u->rst.error = 1; |
|
| 3996 |
- goto error; |
|
| 3997 |
- } |
|
| 3998 |
- if(__builtin_expect(u->rst.ptr > 253, 0)) {
|
|
| 3999 |
- u->rst.error = 2; |
|
| 4000 |
- goto error; |
|
| 4001 |
- } |
|
| 4002 |
-#endif |
|
| 4003 |
- u->rst.ptr += 2; |
|
| 4004 |
- } |
|
| 4005 |
- break; |
|
| 4006 |
-#pragma GCC diagnostic pop |
|
| 4007 |
- } |
|
| 4008 |
- } |
|
| 4009 |
- return 1; |
|
| 4010 |
-#ifndef NO_STACK_CHECKS |
|
| 4011 |
-error: |
|
| 4012 |
- if(u->wst.error) |
|
| 4013 |
- return uxn_halt(u, u->wst.error, "Working-stack", instr); |
|
| 4014 |
- else |
|
| 4015 |
- return uxn_halt(u, u->rst.error, "Return-stack", instr); |
|
| 4016 |
-#endif |
|
| 4017 |
-} |
|
| 4018 |
- |
|
| 4019 |
-int |
|
| 4020 |
-uxn_boot(Uxn *u, Uint8 *memory) |
|
| 4021 |
-{
|
|
| 4022 |
- unsigned int i; |
|
| 4023 |
- char *cptr = (char *)u; |
|
| 4024 |
- for(i = 0; i < sizeof(*u); ++i) |
|
| 4025 |
- cptr[i] = 0x00; |
|
| 4026 |
- u->ram.dat = memory; |
|
| 4027 |
- return 1; |
|
| 4028 |
-} |
|
| 4029 |
- |
|
| 4030 |
-Device * |
|
| 4031 |
-uxn_port(Uxn *u, Uint8 id, Uint8 (*deifn)(Device *d, Uint8 port), void (*deofn)(Device *d, Uint8 port)) |
|
| 4032 |
-{
|
|
| 4033 |
- Device *d = &u->dev[id]; |
|
| 4034 |
- d->addr = id * 0x10; |
|
| 4035 |
- d->u = u; |
|
| 4036 |
- d->mem = u->ram.dat; |
|
| 4037 |
- d->dei = deifn; |
|
| 4038 |
- d->deo = deofn; |
|
| 4039 |
- return d; |
|
| 4040 |
-} |