0
0
Fork 0
mirror of https://git.sr.ht/~rabbits/uxn synced 2024-11-30 17:53:01 +00:00

Swapped return and short flags in advance of uxn.c refactoring

This commit is contained in:
Andrew Alderwick 2021-08-29 22:28:30 +01:00
parent 8988f536be
commit 4d535ebb46
5 changed files with 1087 additions and 1080 deletions

View file

@ -204,9 +204,9 @@ for l in assert(io.lines('src/uxn.c')) do
}, },
body = dump(ops[op], 'u->wst', 'u->rst') body = dump(ops[op], 'u->wst', 'u->rst')
} }
allops[i + 0x40 + 1] = { allops[i + 0x20 + 1] = {
n = { n = {
i + 0x40 i + 0x20
}, },
body = dump(ops[op], 'u->rst', 'u->wst') body = dump(ops[op], 'u->rst', 'u->wst')
} }
@ -216,13 +216,16 @@ for l in assert(io.lines('src/uxn.c')) do
}, },
body = dump(ops['keep_' .. op], 'u->wst', 'u->rst') body = dump(ops['keep_' .. op], 'u->wst', 'u->rst')
} }
allops[i + 0xc0 + 1] = { allops[i + 0xa0 + 1] = {
n = { n = {
i + 0xc0 i + 0xa0
}, },
body = dump(ops['keep_' .. op], 'u->rst', 'u->wst') body = dump(ops['keep_' .. op], 'u->rst', 'u->wst')
} }
i = i + 1 i = i + 1
if i == 0x20 then
i = i + 0x20
end
end end
end end
end end
@ -237,12 +240,12 @@ for l in assert(io.lines('src/uxnasm.c')) do
for op in l:gmatch('"(...)"') do for op in l:gmatch('"(...)"') do
i = i + 1 i = i + 1
allops[i + 0x00].name = op allops[i + 0x00].name = op
allops[i + 0x20].name = op .. '2' allops[i + 0x20].name = op .. 'r'
allops[i + 0x40].name = op .. 'r' allops[i + 0x40].name = op .. '2'
allops[i + 0x60].name = op .. '2r' allops[i + 0x60].name = op .. '2r'
allops[i + 0x80].name = op .. 'k' allops[i + 0x80].name = op .. 'k'
allops[i + 0xa0].name = op .. '2k' allops[i + 0xa0].name = op .. 'kr'
allops[i + 0xc0].name = op .. 'kr' allops[i + 0xc0].name = op .. '2k'
allops[i + 0xe0].name = op .. '2kr' allops[i + 0xe0].name = op .. '2kr'
end end
end end

View file

@ -158,10 +158,12 @@ for l in assert io.lines 'src/uxn.c'
if not ops[op] if not ops[op]
error 'missing ' .. op error 'missing ' .. op
allops[i + 0x00 + 1] = { n: { i + 0x00 }, body: dump ops[op], 'u->wst', 'u->rst' } allops[i + 0x00 + 1] = { n: { i + 0x00 }, body: dump ops[op], 'u->wst', 'u->rst' }
allops[i + 0x40 + 1] = { n: { i + 0x40 }, body: dump ops[op], 'u->rst', 'u->wst' } allops[i + 0x20 + 1] = { n: { i + 0x20 }, body: dump ops[op], 'u->rst', 'u->wst' }
allops[i + 0x80 + 1] = { n: { i + 0x80 }, body: dump ops['keep_' .. op], 'u->wst', 'u->rst' } allops[i + 0x80 + 1] = { n: { i + 0x80 }, body: dump ops['keep_' .. op], 'u->wst', 'u->rst' }
allops[i + 0xc0 + 1] = { n: { i + 0xc0 }, body: dump ops['keep_' .. op], 'u->rst', 'u->wst' } allops[i + 0xa0 + 1] = { n: { i + 0xa0 }, body: dump ops['keep_' .. op], 'u->rst', 'u->wst' }
i += 1 i += 1
if i == 0x20
i += 0x20
i = 0 i = 0
wanted = false wanted = false
@ -174,12 +176,12 @@ for l in assert io.lines 'src/uxnasm.c'
for op in l\gmatch '"(...)"' for op in l\gmatch '"(...)"'
i += 1 i += 1
allops[i + 0x00].name = op allops[i + 0x00].name = op
allops[i + 0x20].name = op .. '2' allops[i + 0x20].name = op .. 'r'
allops[i + 0x40].name = op .. 'r' allops[i + 0x40].name = op .. '2'
allops[i + 0x60].name = op .. '2r' allops[i + 0x60].name = op .. '2r'
allops[i + 0x80].name = op .. 'k' allops[i + 0x80].name = op .. 'k'
allops[i + 0xa0].name = op .. '2k' allops[i + 0xa0].name = op .. 'kr'
allops[i + 0xc0].name = op .. 'kr' allops[i + 0xc0].name = op .. '2k'
allops[i + 0xe0].name = op .. '2kr' allops[i + 0xe0].name = op .. '2kr'
for i = 1, 256 for i = 1, 256

File diff suppressed because it is too large Load diff

View file

@ -12,7 +12,8 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE. WITH REGARD TO THIS SOFTWARE.
*/ */
#define MODE_RETURN 0x40 #define MODE_RETURN 0x20
#define MODE_SHORT 0x40
#define MODE_KEEP 0x80 #define MODE_KEEP 0x80
#pragma mark - Operations #pragma mark - Operations
@ -145,7 +146,7 @@ uxn_eval(Uxn *u, Uint16 vec)
} else { } else {
pop8 = pop8_nokeep; pop8 = pop8_nokeep;
} }
(*ops[instr & 0x3f])(u); (*ops[(instr & 0x1f) | ((instr & MODE_SHORT) >> 1)])(u);
if(u->wst.error) if(u->wst.error)
return uxn_halt(u, u->wst.error, "Working-stack", instr); return uxn_halt(u, u->wst.error, "Working-stack", instr);
if(u->rst.error) if(u->rst.error)

View file

@ -88,10 +88,10 @@ findopcode(char *s)
if(!scmp(ops[i], s, 3)) if(!scmp(ops[i], s, 3))
continue; continue;
while(s[3 + m]) { while(s[3 + m]) {
if(s[3 + m] == '2') if(s[3 + m] == 'r')
i |= (1 << 5); /* mode: short */ i |= (1 << 5); /* mode: return */
else if(s[3 + m] == 'r') else if(s[3 + m] == '2')
i |= (1 << 6); /* mode: return */ i |= (1 << 6); /* mode: short */
else if(s[3 + m] == 'k') else if(s[3 + m] == 'k')
i |= (1 << 7); /* mode: keep */ i |= (1 << 7); /* mode: keep */
else else