diff --git a/code/8086/decoder_table_generator.meta.c b/code/8086/decoder_table_generator.meta.c index 2f30647..10b1962 100644 --- a/code/8086/decoder_table_generator.meta.c +++ b/code/8086/decoder_table_generator.meta.c @@ -40,11 +40,11 @@ typedef Struct_(X8616_DecodeGenInfo) { X8616_InfoList msgs; }; -FI_ B1 x8616_decode_gen_operand_uses_modrm(X8616_Operand operand) { +FI_ B4 x8616_decode_gen_operand_uses_modrm(X8616_Operand operand) { return operand == x8616_operand_rm || operand == x8616_operand_reg_modrm || operand == x8616_operand_segment_modrm; } -FI_ B1 x8616_decode_gen_operand_uses_rm(X8616_Operand operand) { return operand == x8616_operand_rm; } +FI_ B4 x8616_decode_gen_operand_uses_rm(X8616_Operand operand) { return operand == x8616_operand_rm; } internal X8616_DecodePayload x8616_decode_gen_payload_from_operand(X8616_Operand operand) { @@ -141,11 +141,11 @@ x8616_decode_gen_plan(X8616_Encoding const* encoding, U4 encoding_idx, X8616_Inf return plan; } -FI_ B1 x8616_decode_gen_encoding_matches_opcode(X8616_Encoding const* encoding, U1 opcode) { +FI_ B4 x8616_decode_gen_encoding_matches_opcode(X8616_Encoding const* encoding, U1 opcode) { return (opcode & encoding->opcode.mask) == encoding->opcode.bits; } -FI_ B1 x8616_decode_gen_plan_matches_second(X8616_DecodePlan const* plan, U1 byte) { +FI_ B4 x8616_decode_gen_plan_matches_second(X8616_DecodePlan const* plan, U1 byte) { if (plan->mod_rm.mask && ((byte & plan->mod_rm.mask) != plan->mod_rm.bits)) return false; if (plan->post_opcode.mask && ((byte & plan->post_opcode.mask) != plan->post_opcode.bits)) return false; return true; @@ -221,10 +221,10 @@ x8616_decode_gen_pass_validate(X8616_DecodeGen* gen, FArena_R info_scratch) for (U4 encoding_idx = 0; encoding_idx < X8616_ENCODING_COUNT; ++ encoding_idx) { X8616_Encoding const* encoding = x8616_encodings + encoding_idx; - if (! x8616_decode_gen_encoding_matches_opcode(encoding, C_(U1, opcode))) continue; + if (x8616_decode_gen_encoding_matches_opcode(encoding, C_(U1, opcode)) == false) continue; X8616_DecodePlan const* plan = gen->plans + encoding_idx + 1; - if (! x8616_decode_gen_plan_matches_second(plan, C_(U1, second))) continue; + if (x8616_decode_gen_plan_matches_second(plan, C_(U1, second)) == false) continue; if (expected) x8616_info_push(info_scratch, & gen->msgs, x8616_info_error , x8616_info_gen_ambiguous_decode @@ -239,7 +239,7 @@ x8616_decode_gen_pass_validate(X8616_DecodeGen* gen, FArena_R info_scratch) if (dispatch & X8616_DECODE_AUX_BIT) { U2 base = dispatch & X8616_DECODE_AUX_MASK; - actual = gen->aux[base + second]; + actual = gen->aux[base + second]; } else if (dispatch) { U1 candidate = C_(U1, dispatch); @@ -279,24 +279,25 @@ x8616_decode_table_generate(X8616_DecodeGen* gen, FArena_R info_scratch) { #endif enum { - X8616_DECODE_GEN_INFO_MEMORY = kilo(64), - X8616_DECODE_GEN_TEXT_MEMORY = kilo(128), - X8616_DECODE_GEN_FILE_MEMORY = kilo(4), + INFO_MEMORY_SIZE = kilo(64), + TEXT_MEMORY_SIZE = kilo(128), + FILE_MEMORY_SIZE = kilo(4), }; -typedef Struct_(X8616_DecodeGenMemory) { - U1 info[X8616_DECODE_GEN_INFO_MEMORY]; - U1 text[X8616_DECODE_GEN_TEXT_MEMORY]; - U1 file[X8616_DECODE_GEN_FILE_MEMORY]; +typedef FStack_(FStack_64k, U1, kilo(64)); +typedef Struct_(SMemory) { + U1 info[INFO_MEMORY_SIZE]; + U1 text[TEXT_MEMORY_SIZE]; + U1 file[FILE_MEMORY_SIZE]; + + FStack_64k scratch; + + X8616_DecodeGen gen; }; +global SMemory smem; -global X8616_DecodeGen x8616_decode_gen; -global X8616_DecodeGenMemory x8616_decode_gen_memory; - -I_ void -x8616_decode_gen_append_u4(Str8Gen_R out, U4 value, U4 radix, U4 min_digits) { - UTF8 buffer[64]; - Info_str8_from_u4 info = str8_from_u4_info(value, radix, min_digits, 0); +I_ void x8616_decode_gen_append_u4(Str8Gen_R out, U4 value, U4 radix, U4 min_digits) { + UTF8 buffer[64]; Info_str8_from_u4 info = str8_from_u4_info(value, radix, min_digits, 0); Str8 text = str8_from_u4_buf(slice_ut_arr(buffer), value, radix, min_digits, 0, info); str8gen_append_str8(out, text); } @@ -305,29 +306,62 @@ I_ void x8616_decode_gen_append_hex_u1(Str8Gen_R out, U1 value) { x8616_decode_g I_ void x8616_decode_gen_append_hex_u2(Str8Gen_R out, U2 value) { x8616_decode_gen_append_u4(out, value, 16, 4); } I_ void x8616_decode_gen_append_dec (Str8Gen_R out, U4 value) { x8616_decode_gen_append_u4(out, value, 10, 1); } +FI_ Slice scratch_push(U8 len) { return fstack_push_(smem.scratch, len); } + +typedef Opt_(str8_from_u4) { U4 radix, min_digits, digit_group_separator; }; +I_ Str8 str8_from_u4_opt(U4 num, Opt_str8_from_u4 o) { if (o.radix == 0) {o.radix = 10;} +/*gather info*/Info_str8_from_u4 info = str8_from_u4_info(num, o.radix, o.min_digits, o.digit_group_separator); +/*write buf */return str8_from_u4_buf(scratch_push(128), num, o.radix, o.min_digits, o.digit_group_separator, info); +} +#define str8_from_u4(num, ...) str8_from_u4_opt(num, opt_(str8_from_u4, __VA_ARGS__)) + +#define code_str8(...) slit8(stringify(__VA_ARGS__)) + internal void x8616_decode_gen_emit_plan(Str8Gen_R out, X8616_DecodePlan const* plan) { - str8gen_append_str8(out, slit8("\t{ ")); - x8616_decode_gen_append_hex_u2(out, plan->flags); str8gen_append_str8(out, slit8(", ")); - x8616_decode_gen_append_hex_u1(out, plan->op); str8gen_append_str8(out, slit8(", ")); - x8616_decode_gen_append_hex_u1(out, plan->encoding_flags); str8gen_append_str8(out, slit8(", ")); - x8616_decode_gen_append_hex_u1(out, plan->width); str8gen_append_str8(out, slit8(", {")); - x8616_decode_gen_append_hex_u1(out, plan->operands[0]); str8gen_append_str8(out, slit8(",")); - x8616_decode_gen_append_hex_u1(out, plan->operands[1]); str8gen_append_str8(out, slit8("}, ")); - x8616_decode_gen_append_dec(out, plan->operand_count); str8gen_append_str8(out, slit8(", ")); - x8616_decode_gen_append_dec(out, plan->payload); str8gen_append_str8(out, slit8(", ")); - x8616_decode_gen_append_dec(out, plan->prefix_kind); str8gen_append_str8(out, slit8(", ")); - x8616_decode_gen_append_dec(out, plan->d_shift); str8gen_append_str8(out, slit8(",")); - x8616_decode_gen_append_dec(out, plan->w_shift); str8gen_append_str8(out, slit8(",")); - x8616_decode_gen_append_dec(out, plan->s_shift); str8gen_append_str8(out, slit8(",")); - x8616_decode_gen_append_dec(out, plan->v_shift); str8gen_append_str8(out, slit8(",")); - x8616_decode_gen_append_dec(out, plan->z_shift); str8gen_append_str8(out, slit8(",")); - x8616_decode_gen_append_dec(out, plan->reg_shift); str8gen_append_str8(out, slit8(",")); - x8616_decode_gen_append_dec(out, plan->sr_shift); str8gen_append_str8(out, slit8(", {")); - x8616_decode_gen_append_hex_u1(out, plan->mod_rm.bits); str8gen_append_str8(out, slit8(",")); - x8616_decode_gen_append_hex_u1(out, plan->mod_rm.mask); str8gen_append_str8(out, slit8("}, {")); - x8616_decode_gen_append_hex_u1(out, plan->post_opcode.bits); str8gen_append_str8(out, slit8(",")); - x8616_decode_gen_append_hex_u1(out, plan->post_opcode.mask); str8gen_append_str8(out, slit8("} },\n")); + defer_rewind(smem.scratch.top) + { + Str8 template = code_str8( + \t{ + , , , , + { , }, , + , , + , , , , , , , + { , }, + { , }, + },\n + ); + KTL_Slot_Str8 tbl[] = { + #define dec(value) str8_from_u4(value, .radix = 10, .min_digits = 1) + #define hex_u1(value) str8_from_u4(value, .radix = 16, .min_digits = 2) + #define hex_u2(value) str8_from_u4(value, .radix = 16, .min_digits = 4) + #define entry(key,value) { ktl_str8_key(key), value } + entry("flags", hex_u2(plan->flags)), + entry("op", hex_u1(plan->op)), + entry("encoding_flags", hex_u1(plan->encoding_flags)), + entry("width", hex_u1(plan->width)), + entry("operands[0]", hex_u1(plan->operands[0])), + entry("operands[1]", hex_u1(plan->operands[1])), + entry("operand_count", dec(plan->operand_count)), + entry("payload", dec(plan->payload)), + entry("prefix_kind", dec(plan->prefix_kind)), + entry("d_shift", dec(plan->d_shift)), + entry("w_shift", dec(plan->w_shift)), + entry("s_shift", dec(plan->s_shift)), + entry("v_shift", dec(plan->v_shift)), + entry("z_shift", dec(plan->z_shift)), + entry("reg_shift", dec(plan->reg_shift)), + entry("sr_shift", dec(plan->sr_shift)), + entry("mod_rm.bits", hex_u1(plan->mod_rm.bits)), + entry("mod_rm.mask", hex_u1(plan->mod_rm.mask)), + entry("post_opcode.bits", hex_u1(plan->post_opcode.bits)), + entry("post_opcode.mask", hex_u1(plan->post_opcode.mask)), + #undef dec + #undef hex + #undef entry + }; + str8gen_append_fmt(out, template, ktl_str8_from_arr(tbl)); + } } internal Str8 @@ -366,19 +400,19 @@ x8616_decode_gen_emit(Str8Gen_R out, X8616_DecodeGen const* gen) { CLANG_OPTIMIZE_DISABLE int main(void) { - FArena info_scratch = farena_make(slice_ut_arr(x8616_decode_gen_memory.info)); - X8616_DecodeGenInfo gen_info = x8616_decode_table_generate(& x8616_decode_gen, & info_scratch); + FArena info_scratch = farena_make(slice_ut_arr(smem.info)); + X8616_DecodeGenInfo gen_info = x8616_decode_table_generate(& smem.gen, & info_scratch); if (gen_info.msgs.error_count) { ms_exit_process(1); return 1; } Str8Gen output = { - .ptr = C_(UTF8*, x8616_decode_gen_memory.text), - .cap = S_(x8616_decode_gen_memory.text), + .ptr = C_(UTF8*, smem.text), + .cap = S_(smem.text), }; - Str8 generated = x8616_decode_gen_emit(& output, & x8616_decode_gen); + Str8 generated = x8616_decode_gen_emit(& output, & smem.gen); - FArena file_scratch = farena_make(slice_ut_arr(x8616_decode_gen_memory.file)); + FArena file_scratch = farena_make(slice_ut_arr(smem.file)); B4 wrote = write_data_to_file_path(slit8(X8616_DECODE_TABLE_OUTPUT), generated, & file_scratch); - if (! wrote) { ms_exit_process(2); return 2; } + if (wrote == false) { ms_exit_process(2); return 2; } if (gen_info.verified_count != 256 * 256) { ms_exit_process(3); return 3; } ms_exit_process(0); diff --git a/code/8086/gen/decoder_table.h b/code/8086/gen/decoder_table.h index 7e182ed..5e9b4c0 100644 --- a/code/8086/gen/decoder_table.h +++ b/code/8086/gen/decoder_table.h @@ -3,138 +3,138 @@ RO_ global X8616_DecodePlan x8616_decode_plans[132] = { - { 0x0000, 0x00, 0x00, 0x00, {0x00,0x00}, 0, 0, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x020d, 0x02, 0x00, 0x00, {0x01,0x02}, 2, 0, 0, 1,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0209, 0x02, 0x00, 0x00, {0x01,0x07}, 2, 1, 0, 0,0,0,0,0,0,0, {0x00,0x38}, {0x00,0x00} }, - { 0x0088, 0x02, 0x00, 0x00, {0x03,0x07}, 2, 1, 0, 0,3,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x000c, 0x02, 0x00, 0x00, {0x06,0x0a}, 2, 4, 0, 1,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0205, 0x02, 0x00, 0x02, {0x01,0x04}, 2, 0, 0, 1,0,0,0,0,0,0, {0x00,0x20}, {0x00,0x00} }, - { 0x0201, 0x0b, 0x00, 0x02, {0x01,0x00}, 1, 0, 0, 0,0,0,0,0,0,0, {0x30,0x38}, {0x00,0x00} }, - { 0x0080, 0x0b, 0x00, 0x02, {0x03,0x00}, 1, 0, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0100, 0x0b, 0x00, 0x02, {0x05,0x00}, 1, 0, 0, 0,0,0,0,0,0,3, {0x00,0x00}, {0x00,0x00} }, - { 0x0201, 0x0c, 0x00, 0x02, {0x01,0x00}, 1, 0, 0, 0,0,0,0,0,0,0, {0x00,0x38}, {0x00,0x00} }, - { 0x0080, 0x0c, 0x00, 0x02, {0x03,0x00}, 1, 0, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0100, 0x0c, 0x00, 0x02, {0x05,0x00}, 1, 0, 0, 0,0,0,0,0,0,3, {0x00,0x00}, {0x00,0x00} }, - { 0x0209, 0x0d, 0x00, 0x00, {0x02,0x01}, 2, 0, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0080, 0x0d, 0x00, 0x02, {0x06,0x03}, 2, 0, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0008, 0x0e, 0x00, 0x00, {0x06,0x08}, 2, 2, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0008, 0x0e, 0x00, 0x00, {0x06,0x0e}, 2, 0, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0008, 0x0f, 0x00, 0x00, {0x08,0x06}, 2, 2, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0008, 0x0f, 0x00, 0x00, {0x0e,0x06}, 2, 0, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0000, 0x10, 0x00, 0x00, {0x00,0x00}, 0, 0, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0201, 0x11, 0x00, 0x02, {0x02,0x01}, 2, 0, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0201, 0x12, 0x00, 0x02, {0x02,0x01}, 2, 0, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0201, 0x13, 0x00, 0x02, {0x02,0x01}, 2, 0, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0000, 0x14, 0x00, 0x00, {0x00,0x00}, 0, 0, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0000, 0x15, 0x00, 0x00, {0x00,0x00}, 0, 0, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0000, 0x16, 0x00, 0x00, {0x00,0x00}, 0, 0, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0000, 0x17, 0x00, 0x00, {0x00,0x00}, 0, 0, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x020d, 0x03, 0x00, 0x00, {0x01,0x02}, 2, 0, 0, 1,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0219, 0x03, 0x00, 0x00, {0x01,0x07}, 2, 1, 0, 0,0,1,0,0,0,0, {0x00,0x38}, {0x00,0x00} }, - { 0x0008, 0x03, 0x00, 0x00, {0x06,0x07}, 2, 1, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x020d, 0x04, 0x00, 0x00, {0x01,0x02}, 2, 0, 0, 1,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0209, 0x04, 0x00, 0x00, {0x01,0x07}, 2, 1, 0, 0,0,0,0,0,0,0, {0x08,0x38}, {0x00,0x00} }, - { 0x0008, 0x04, 0x00, 0x00, {0x06,0x07}, 2, 1, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x020d, 0x05, 0x00, 0x00, {0x01,0x02}, 2, 0, 0, 1,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0219, 0x05, 0x00, 0x00, {0x01,0x07}, 2, 1, 0, 0,0,1,0,0,0,0, {0x10,0x38}, {0x00,0x00} }, - { 0x0008, 0x05, 0x00, 0x00, {0x06,0x07}, 2, 1, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x020d, 0x06, 0x00, 0x00, {0x01,0x02}, 2, 0, 0, 1,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0219, 0x06, 0x00, 0x00, {0x01,0x07}, 2, 1, 0, 0,0,1,0,0,0,0, {0x18,0x38}, {0x00,0x00} }, - { 0x0008, 0x06, 0x00, 0x00, {0x06,0x07}, 2, 1, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x020d, 0x07, 0x00, 0x00, {0x01,0x02}, 2, 0, 0, 1,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0209, 0x07, 0x00, 0x00, {0x01,0x07}, 2, 1, 0, 0,0,0,0,0,0,0, {0x20,0x38}, {0x00,0x00} }, - { 0x0008, 0x07, 0x00, 0x00, {0x06,0x07}, 2, 1, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x020d, 0x08, 0x00, 0x00, {0x01,0x02}, 2, 0, 0, 1,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0219, 0x08, 0x00, 0x00, {0x01,0x07}, 2, 1, 0, 0,0,1,0,0,0,0, {0x28,0x38}, {0x00,0x00} }, - { 0x0008, 0x08, 0x00, 0x00, {0x06,0x07}, 2, 1, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x020d, 0x09, 0x00, 0x00, {0x01,0x02}, 2, 0, 0, 1,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0209, 0x09, 0x00, 0x00, {0x01,0x07}, 2, 1, 0, 0,0,0,0,0,0,0, {0x30,0x38}, {0x00,0x00} }, - { 0x0008, 0x09, 0x00, 0x00, {0x06,0x07}, 2, 1, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x020d, 0x0a, 0x00, 0x00, {0x01,0x02}, 2, 0, 0, 1,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0219, 0x0a, 0x00, 0x00, {0x01,0x07}, 2, 1, 0, 0,0,1,0,0,0,0, {0x38,0x38}, {0x00,0x00} }, - { 0x0008, 0x0a, 0x00, 0x00, {0x06,0x07}, 2, 1, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0209, 0x18, 0x00, 0x00, {0x01,0x00}, 1, 0, 0, 0,0,0,0,0,0,0, {0x00,0x38}, {0x00,0x00} }, - { 0x0080, 0x18, 0x00, 0x02, {0x03,0x00}, 1, 0, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0000, 0x19, 0x00, 0x00, {0x00,0x00}, 0, 0, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0000, 0x1a, 0x00, 0x00, {0x00,0x00}, 0, 0, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0209, 0x1b, 0x00, 0x00, {0x01,0x00}, 1, 0, 0, 0,0,0,0,0,0,0, {0x08,0x38}, {0x00,0x00} }, - { 0x0080, 0x1b, 0x00, 0x02, {0x03,0x00}, 1, 0, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0209, 0x1c, 0x00, 0x00, {0x01,0x00}, 1, 0, 0, 0,0,0,0,0,0,0, {0x18,0x38}, {0x00,0x00} }, - { 0x0209, 0x1f, 0x00, 0x00, {0x01,0x00}, 1, 0, 0, 0,0,0,0,0,0,0, {0x20,0x38}, {0x00,0x00} }, - { 0x0209, 0x20, 0x00, 0x00, {0x01,0x00}, 1, 0, 0, 0,0,0,0,0,0,0, {0x28,0x38}, {0x00,0x00} }, - { 0x0209, 0x22, 0x00, 0x00, {0x01,0x00}, 1, 0, 0, 0,0,0,0,0,0,0, {0x30,0x38}, {0x00,0x00} }, - { 0x0209, 0x23, 0x00, 0x00, {0x01,0x00}, 1, 0, 0, 0,0,0,0,0,0,0, {0x38,0x38}, {0x00,0x00} }, - { 0x0209, 0x27, 0x00, 0x00, {0x01,0x00}, 1, 0, 0, 0,0,0,0,0,0,0, {0x10,0x38}, {0x00,0x00} }, - { 0x0000, 0x1d, 0x00, 0x00, {0x00,0x00}, 0, 0, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0000, 0x1e, 0x00, 0x00, {0x00,0x00}, 0, 0, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0002, 0x21, 0x00, 0x00, {0x00,0x00}, 0, 0, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x0a,0xff} }, - { 0x0002, 0x24, 0x00, 0x00, {0x00,0x00}, 0, 0, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x0a,0xff} }, - { 0x0000, 0x25, 0x00, 0x00, {0x00,0x00}, 0, 0, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0000, 0x26, 0x00, 0x00, {0x00,0x00}, 0, 0, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0229, 0x2b, 0x00, 0x00, {0x01,0x0f}, 2, 0, 0, 0,0,0,1,0,0,0, {0x00,0x38}, {0x00,0x00} }, - { 0x0229, 0x2c, 0x00, 0x00, {0x01,0x0f}, 2, 0, 0, 0,0,0,1,0,0,0, {0x08,0x38}, {0x00,0x00} }, - { 0x0229, 0x2d, 0x00, 0x00, {0x01,0x0f}, 2, 0, 0, 0,0,0,1,0,0,0, {0x10,0x38}, {0x00,0x00} }, - { 0x0229, 0x2e, 0x00, 0x00, {0x01,0x0f}, 2, 0, 0, 0,0,0,1,0,0,0, {0x18,0x38}, {0x00,0x00} }, - { 0x0229, 0x28, 0x00, 0x00, {0x01,0x0f}, 2, 0, 0, 0,0,0,1,0,0,0, {0x20,0x38}, {0x00,0x00} }, - { 0x0229, 0x29, 0x00, 0x00, {0x01,0x0f}, 2, 0, 0, 0,0,0,1,0,0,0, {0x28,0x38}, {0x00,0x00} }, - { 0x0229, 0x2a, 0x00, 0x00, {0x01,0x0f}, 2, 0, 0, 0,0,0,1,0,0,0, {0x38,0x38}, {0x00,0x00} }, - { 0x0209, 0x2f, 0x00, 0x00, {0x01,0x02}, 2, 0, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0209, 0x2f, 0x00, 0x00, {0x01,0x07}, 2, 1, 0, 0,0,0,0,0,0,0, {0x00,0x38}, {0x00,0x00} }, - { 0x0008, 0x2f, 0x00, 0x00, {0x06,0x07}, 2, 1, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0440, 0x30, 0x02, 0x00, {0x00,0x00}, 0, 0, 2, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0008, 0x31, 0x00, 0x00, {0x00,0x00}, 0, 0, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0008, 0x32, 0x00, 0x00, {0x00,0x00}, 0, 0, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0008, 0x33, 0x00, 0x00, {0x00,0x00}, 0, 0, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0008, 0x34, 0x00, 0x00, {0x00,0x00}, 0, 0, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0008, 0x35, 0x00, 0x00, {0x00,0x00}, 0, 0, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0400, 0x5b, 0x02, 0x00, {0x00,0x00}, 0, 0, 1, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0500, 0x5c, 0x02, 0x00, {0x00,0x00}, 0, 0, 3, 0,0,0,0,0,0,3, {0x00,0x00}, {0x00,0x00} }, - { 0x0000, 0x36, 0x00, 0x00, {0x0c,0x00}, 1, 6, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0201, 0x36, 0x00, 0x02, {0x01,0x00}, 1, 0, 0, 0,0,0,0,0,0,0, {0x10,0x38}, {0x00,0x00} }, - { 0x0000, 0x36, 0x01, 0x00, {0x0d,0x00}, 1, 7, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0201, 0x36, 0x01, 0x02, {0x01,0x00}, 1, 0, 0, 0,0,0,0,0,0,0, {0x18,0x38}, {0x00,0x00} }, - { 0x0000, 0x37, 0x00, 0x00, {0x0c,0x00}, 1, 6, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0000, 0x37, 0x00, 0x00, {0x0b,0x00}, 1, 5, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0201, 0x37, 0x00, 0x02, {0x01,0x00}, 1, 0, 0, 0,0,0,0,0,0,0, {0x20,0x38}, {0x00,0x00} }, - { 0x0000, 0x37, 0x01, 0x00, {0x0d,0x00}, 1, 7, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0201, 0x37, 0x01, 0x02, {0x01,0x00}, 1, 0, 0, 0,0,0,0,0,0,0, {0x28,0x38}, {0x00,0x00} }, - { 0x0000, 0x38, 0x00, 0x00, {0x00,0x00}, 0, 0, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0000, 0x38, 0x00, 0x00, {0x09,0x00}, 1, 3, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0000, 0x39, 0x00, 0x00, {0x00,0x00}, 0, 0, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0000, 0x39, 0x00, 0x00, {0x09,0x00}, 1, 3, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0000, 0x40, 0x00, 0x00, {0x0b,0x00}, 1, 5, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0000, 0x48, 0x00, 0x00, {0x0b,0x00}, 1, 5, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0000, 0x3d, 0x00, 0x00, {0x0b,0x00}, 1, 5, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0000, 0x45, 0x00, 0x00, {0x0b,0x00}, 1, 5, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0000, 0x3a, 0x00, 0x00, {0x0b,0x00}, 1, 5, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0000, 0x42, 0x00, 0x00, {0x0b,0x00}, 1, 5, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0000, 0x3e, 0x00, 0x00, {0x0b,0x00}, 1, 5, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0000, 0x46, 0x00, 0x00, {0x0b,0x00}, 1, 5, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0000, 0x41, 0x00, 0x00, {0x0b,0x00}, 1, 5, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0000, 0x49, 0x00, 0x00, {0x0b,0x00}, 1, 5, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0000, 0x3f, 0x00, 0x00, {0x0b,0x00}, 1, 5, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0000, 0x47, 0x00, 0x00, {0x0b,0x00}, 1, 5, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0000, 0x3b, 0x00, 0x00, {0x0b,0x00}, 1, 5, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0000, 0x43, 0x00, 0x00, {0x0b,0x00}, 1, 5, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0000, 0x3c, 0x00, 0x00, {0x0b,0x00}, 1, 5, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0000, 0x44, 0x00, 0x00, {0x0b,0x00}, 1, 5, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0000, 0x4c, 0x00, 0x00, {0x0b,0x00}, 1, 5, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0000, 0x4b, 0x00, 0x00, {0x0b,0x00}, 1, 5, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0000, 0x4a, 0x00, 0x00, {0x0b,0x00}, 1, 5, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0000, 0x4d, 0x00, 0x00, {0x0b,0x00}, 1, 5, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0000, 0x4e, 0x00, 0x00, {0x08,0x00}, 1, 2, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0000, 0x4f, 0x00, 0x00, {0x00,0x00}, 0, 0, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0000, 0x50, 0x00, 0x00, {0x00,0x00}, 0, 0, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0000, 0x51, 0x00, 0x00, {0x00,0x00}, 0, 0, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0000, 0x52, 0x00, 0x00, {0x00,0x00}, 0, 0, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0000, 0x53, 0x00, 0x00, {0x00,0x00}, 0, 0, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0000, 0x54, 0x00, 0x00, {0x00,0x00}, 0, 0, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0000, 0x55, 0x00, 0x00, {0x00,0x00}, 0, 0, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0000, 0x56, 0x00, 0x00, {0x00,0x00}, 0, 0, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0000, 0x57, 0x00, 0x00, {0x00,0x00}, 0, 0, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0000, 0x58, 0x00, 0x00, {0x00,0x00}, 0, 0, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0000, 0x59, 0x00, 0x00, {0x00,0x00}, 0, 0, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, - { 0x0000, 0x5a, 0x00, 0x00, {0x00,0x00}, 0, 0, 0, 0,0,0,0,0,0,0, {0x00,0x00}, {0x00,0x00} }, + { 0x0000, 0x00, 0x00, 0x00, { 0x00 , 0x00 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x020d, 0x02, 0x00, 0x00, { 0x01 , 0x02 }, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0209, 0x02, 0x00, 0x00, { 0x01 , 0x07 }, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x38 }, { 0x00, 0x00 }, }, + { 0x0088, 0x02, 0x00, 0x00, { 0x03 , 0x07 }, 2, 1, 0, 0, 3, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x000c, 0x02, 0x00, 0x00, { 0x06 , 0x0a }, 2, 4, 0, 1, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0205, 0x02, 0x00, 0x02, { 0x01 , 0x04 }, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0, { 0x00, 0x20 }, { 0x00, 0x00 }, }, + { 0x0201, 0x0b, 0x00, 0x02, { 0x01 , 0x00 }, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x30, 0x38 }, { 0x00, 0x00 }, }, + { 0x0080, 0x0b, 0x00, 0x02, { 0x03 , 0x00 }, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0100, 0x0b, 0x00, 0x02, { 0x05 , 0x00 }, 1, 0, 0, 0, 0, 0, 0, 0, 0, 3, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0201, 0x0c, 0x00, 0x02, { 0x01 , 0x00 }, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x38 }, { 0x00, 0x00 }, }, + { 0x0080, 0x0c, 0x00, 0x02, { 0x03 , 0x00 }, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0100, 0x0c, 0x00, 0x02, { 0x05 , 0x00 }, 1, 0, 0, 0, 0, 0, 0, 0, 0, 3, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0209, 0x0d, 0x00, 0x00, { 0x02 , 0x01 }, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0080, 0x0d, 0x00, 0x02, { 0x06 , 0x03 }, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0008, 0x0e, 0x00, 0x00, { 0x06 , 0x08 }, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0008, 0x0e, 0x00, 0x00, { 0x06 , 0x0e }, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0008, 0x0f, 0x00, 0x00, { 0x08 , 0x06 }, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0008, 0x0f, 0x00, 0x00, { 0x0e , 0x06 }, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0000, 0x10, 0x00, 0x00, { 0x00 , 0x00 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0201, 0x11, 0x00, 0x02, { 0x02 , 0x01 }, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0201, 0x12, 0x00, 0x02, { 0x02 , 0x01 }, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0201, 0x13, 0x00, 0x02, { 0x02 , 0x01 }, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0000, 0x14, 0x00, 0x00, { 0x00 , 0x00 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0000, 0x15, 0x00, 0x00, { 0x00 , 0x00 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0000, 0x16, 0x00, 0x00, { 0x00 , 0x00 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0000, 0x17, 0x00, 0x00, { 0x00 , 0x00 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x020d, 0x03, 0x00, 0x00, { 0x01 , 0x02 }, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0219, 0x03, 0x00, 0x00, { 0x01 , 0x07 }, 2, 1, 0, 0, 0, 1, 0, 0, 0, 0, { 0x00, 0x38 }, { 0x00, 0x00 }, }, + { 0x0008, 0x03, 0x00, 0x00, { 0x06 , 0x07 }, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x020d, 0x04, 0x00, 0x00, { 0x01 , 0x02 }, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0209, 0x04, 0x00, 0x00, { 0x01 , 0x07 }, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, { 0x08, 0x38 }, { 0x00, 0x00 }, }, + { 0x0008, 0x04, 0x00, 0x00, { 0x06 , 0x07 }, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x020d, 0x05, 0x00, 0x00, { 0x01 , 0x02 }, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0219, 0x05, 0x00, 0x00, { 0x01 , 0x07 }, 2, 1, 0, 0, 0, 1, 0, 0, 0, 0, { 0x10, 0x38 }, { 0x00, 0x00 }, }, + { 0x0008, 0x05, 0x00, 0x00, { 0x06 , 0x07 }, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x020d, 0x06, 0x00, 0x00, { 0x01 , 0x02 }, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0219, 0x06, 0x00, 0x00, { 0x01 , 0x07 }, 2, 1, 0, 0, 0, 1, 0, 0, 0, 0, { 0x18, 0x38 }, { 0x00, 0x00 }, }, + { 0x0008, 0x06, 0x00, 0x00, { 0x06 , 0x07 }, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x020d, 0x07, 0x00, 0x00, { 0x01 , 0x02 }, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0209, 0x07, 0x00, 0x00, { 0x01 , 0x07 }, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, { 0x20, 0x38 }, { 0x00, 0x00 }, }, + { 0x0008, 0x07, 0x00, 0x00, { 0x06 , 0x07 }, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x020d, 0x08, 0x00, 0x00, { 0x01 , 0x02 }, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0219, 0x08, 0x00, 0x00, { 0x01 , 0x07 }, 2, 1, 0, 0, 0, 1, 0, 0, 0, 0, { 0x28, 0x38 }, { 0x00, 0x00 }, }, + { 0x0008, 0x08, 0x00, 0x00, { 0x06 , 0x07 }, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x020d, 0x09, 0x00, 0x00, { 0x01 , 0x02 }, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0209, 0x09, 0x00, 0x00, { 0x01 , 0x07 }, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, { 0x30, 0x38 }, { 0x00, 0x00 }, }, + { 0x0008, 0x09, 0x00, 0x00, { 0x06 , 0x07 }, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x020d, 0x0a, 0x00, 0x00, { 0x01 , 0x02 }, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0219, 0x0a, 0x00, 0x00, { 0x01 , 0x07 }, 2, 1, 0, 0, 0, 1, 0, 0, 0, 0, { 0x38, 0x38 }, { 0x00, 0x00 }, }, + { 0x0008, 0x0a, 0x00, 0x00, { 0x06 , 0x07 }, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0209, 0x18, 0x00, 0x00, { 0x01 , 0x00 }, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x38 }, { 0x00, 0x00 }, }, + { 0x0080, 0x18, 0x00, 0x02, { 0x03 , 0x00 }, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0000, 0x19, 0x00, 0x00, { 0x00 , 0x00 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0000, 0x1a, 0x00, 0x00, { 0x00 , 0x00 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0209, 0x1b, 0x00, 0x00, { 0x01 , 0x00 }, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x08, 0x38 }, { 0x00, 0x00 }, }, + { 0x0080, 0x1b, 0x00, 0x02, { 0x03 , 0x00 }, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0209, 0x1c, 0x00, 0x00, { 0x01 , 0x00 }, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x18, 0x38 }, { 0x00, 0x00 }, }, + { 0x0209, 0x1f, 0x00, 0x00, { 0x01 , 0x00 }, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x20, 0x38 }, { 0x00, 0x00 }, }, + { 0x0209, 0x20, 0x00, 0x00, { 0x01 , 0x00 }, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x28, 0x38 }, { 0x00, 0x00 }, }, + { 0x0209, 0x22, 0x00, 0x00, { 0x01 , 0x00 }, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x30, 0x38 }, { 0x00, 0x00 }, }, + { 0x0209, 0x23, 0x00, 0x00, { 0x01 , 0x00 }, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x38, 0x38 }, { 0x00, 0x00 }, }, + { 0x0209, 0x27, 0x00, 0x00, { 0x01 , 0x00 }, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x10, 0x38 }, { 0x00, 0x00 }, }, + { 0x0000, 0x1d, 0x00, 0x00, { 0x00 , 0x00 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0000, 0x1e, 0x00, 0x00, { 0x00 , 0x00 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0002, 0x21, 0x00, 0x00, { 0x00 , 0x00 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x0a, 0xff }, }, + { 0x0002, 0x24, 0x00, 0x00, { 0x00 , 0x00 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x0a, 0xff }, }, + { 0x0000, 0x25, 0x00, 0x00, { 0x00 , 0x00 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0000, 0x26, 0x00, 0x00, { 0x00 , 0x00 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0229, 0x2b, 0x00, 0x00, { 0x01 , 0x0f }, 2, 0, 0, 0, 0, 0, 1, 0, 0, 0, { 0x00, 0x38 }, { 0x00, 0x00 }, }, + { 0x0229, 0x2c, 0x00, 0x00, { 0x01 , 0x0f }, 2, 0, 0, 0, 0, 0, 1, 0, 0, 0, { 0x08, 0x38 }, { 0x00, 0x00 }, }, + { 0x0229, 0x2d, 0x00, 0x00, { 0x01 , 0x0f }, 2, 0, 0, 0, 0, 0, 1, 0, 0, 0, { 0x10, 0x38 }, { 0x00, 0x00 }, }, + { 0x0229, 0x2e, 0x00, 0x00, { 0x01 , 0x0f }, 2, 0, 0, 0, 0, 0, 1, 0, 0, 0, { 0x18, 0x38 }, { 0x00, 0x00 }, }, + { 0x0229, 0x28, 0x00, 0x00, { 0x01 , 0x0f }, 2, 0, 0, 0, 0, 0, 1, 0, 0, 0, { 0x20, 0x38 }, { 0x00, 0x00 }, }, + { 0x0229, 0x29, 0x00, 0x00, { 0x01 , 0x0f }, 2, 0, 0, 0, 0, 0, 1, 0, 0, 0, { 0x28, 0x38 }, { 0x00, 0x00 }, }, + { 0x0229, 0x2a, 0x00, 0x00, { 0x01 , 0x0f }, 2, 0, 0, 0, 0, 0, 1, 0, 0, 0, { 0x38, 0x38 }, { 0x00, 0x00 }, }, + { 0x0209, 0x2f, 0x00, 0x00, { 0x01 , 0x02 }, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0209, 0x2f, 0x00, 0x00, { 0x01 , 0x07 }, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x38 }, { 0x00, 0x00 }, }, + { 0x0008, 0x2f, 0x00, 0x00, { 0x06 , 0x07 }, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0440, 0x30, 0x02, 0x00, { 0x00 , 0x00 }, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0008, 0x31, 0x00, 0x00, { 0x00 , 0x00 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0008, 0x32, 0x00, 0x00, { 0x00 , 0x00 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0008, 0x33, 0x00, 0x00, { 0x00 , 0x00 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0008, 0x34, 0x00, 0x00, { 0x00 , 0x00 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0008, 0x35, 0x00, 0x00, { 0x00 , 0x00 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0400, 0x5b, 0x02, 0x00, { 0x00 , 0x00 }, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0500, 0x5c, 0x02, 0x00, { 0x00 , 0x00 }, 0, 0, 3, 0, 0, 0, 0, 0, 0, 3, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0000, 0x36, 0x00, 0x00, { 0x0c , 0x00 }, 1, 6, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0201, 0x36, 0x00, 0x02, { 0x01 , 0x00 }, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x10, 0x38 }, { 0x00, 0x00 }, }, + { 0x0000, 0x36, 0x01, 0x00, { 0x0d , 0x00 }, 1, 7, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0201, 0x36, 0x01, 0x02, { 0x01 , 0x00 }, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x18, 0x38 }, { 0x00, 0x00 }, }, + { 0x0000, 0x37, 0x00, 0x00, { 0x0c , 0x00 }, 1, 6, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0000, 0x37, 0x00, 0x00, { 0x0b , 0x00 }, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0201, 0x37, 0x00, 0x02, { 0x01 , 0x00 }, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x20, 0x38 }, { 0x00, 0x00 }, }, + { 0x0000, 0x37, 0x01, 0x00, { 0x0d , 0x00 }, 1, 7, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0201, 0x37, 0x01, 0x02, { 0x01 , 0x00 }, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x28, 0x38 }, { 0x00, 0x00 }, }, + { 0x0000, 0x38, 0x00, 0x00, { 0x00 , 0x00 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0000, 0x38, 0x00, 0x00, { 0x09 , 0x00 }, 1, 3, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0000, 0x39, 0x00, 0x00, { 0x00 , 0x00 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0000, 0x39, 0x00, 0x00, { 0x09 , 0x00 }, 1, 3, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0000, 0x40, 0x00, 0x00, { 0x0b , 0x00 }, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0000, 0x48, 0x00, 0x00, { 0x0b , 0x00 }, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0000, 0x3d, 0x00, 0x00, { 0x0b , 0x00 }, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0000, 0x45, 0x00, 0x00, { 0x0b , 0x00 }, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0000, 0x3a, 0x00, 0x00, { 0x0b , 0x00 }, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0000, 0x42, 0x00, 0x00, { 0x0b , 0x00 }, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0000, 0x3e, 0x00, 0x00, { 0x0b , 0x00 }, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0000, 0x46, 0x00, 0x00, { 0x0b , 0x00 }, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0000, 0x41, 0x00, 0x00, { 0x0b , 0x00 }, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0000, 0x49, 0x00, 0x00, { 0x0b , 0x00 }, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0000, 0x3f, 0x00, 0x00, { 0x0b , 0x00 }, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0000, 0x47, 0x00, 0x00, { 0x0b , 0x00 }, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0000, 0x3b, 0x00, 0x00, { 0x0b , 0x00 }, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0000, 0x43, 0x00, 0x00, { 0x0b , 0x00 }, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0000, 0x3c, 0x00, 0x00, { 0x0b , 0x00 }, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0000, 0x44, 0x00, 0x00, { 0x0b , 0x00 }, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0000, 0x4c, 0x00, 0x00, { 0x0b , 0x00 }, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0000, 0x4b, 0x00, 0x00, { 0x0b , 0x00 }, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0000, 0x4a, 0x00, 0x00, { 0x0b , 0x00 }, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0000, 0x4d, 0x00, 0x00, { 0x0b , 0x00 }, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0000, 0x4e, 0x00, 0x00, { 0x08 , 0x00 }, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0000, 0x4f, 0x00, 0x00, { 0x00 , 0x00 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0000, 0x50, 0x00, 0x00, { 0x00 , 0x00 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0000, 0x51, 0x00, 0x00, { 0x00 , 0x00 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0000, 0x52, 0x00, 0x00, { 0x00 , 0x00 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0000, 0x53, 0x00, 0x00, { 0x00 , 0x00 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0000, 0x54, 0x00, 0x00, { 0x00 , 0x00 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0000, 0x55, 0x00, 0x00, { 0x00 , 0x00 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0000, 0x56, 0x00, 0x00, { 0x00 , 0x00 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0000, 0x57, 0x00, 0x00, { 0x00 , 0x00 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0000, 0x58, 0x00, 0x00, { 0x00 , 0x00 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0000, 0x59, 0x00, 0x00, { 0x00 , 0x00 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, + { 0x0000, 0x5a, 0x00, 0x00, { 0x00 , 0x00 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0x00, 0x00 }, { 0x00, 0x00 }, }, }; RO_ global U2 x8616_decode_dispatch[256] = diff --git a/code/duffle/dsl.h b/code/duffle/dsl.h index 0a19561..2dfe658 100644 --- a/code/duffle/dsl.h +++ b/code/duffle/dsl.h @@ -41,8 +41,8 @@ Standard: c23 #define glue(A, B) glue_impl(A, B) #define tmpl(prefix, type) prefix ## _ ## type -#define stringify_impl(S) #S -#define stringify(S) stringify_impl(S) +#define stringify_impl(...) #__VA_ARGS__ +#define stringify(...) stringify_impl(__VA_ARGS__) #define VA_Sel_1( _1, ... ) _1 // <-- Of all th args passed pick _1. #define VA_Sel_2( _1, _2, ... ) _2 // <-- Of all the args passed pick _2. diff --git a/code/duffle/memory.h b/code/duffle/memory.h index 347e029..b657468 100644 --- a/code/duffle/memory.h +++ b/code/duffle/memory.h @@ -5,7 +5,7 @@ #define MEM_ALIGNMENT_DEFAULT 4 -#define assert_bounds(point, start, end) for(;0;){ \ +#define assert_bounds(point, start, end) do{ \ assert((start) <= (point)); \ assert((point) <= (end)); \ } while(0) @@ -67,7 +67,7 @@ FI_ B4 mem_match (U8 a, U8 b, U8 z) { return mem_compare(a, b, z) == 0; } typedef unsigned char TSet_(UTF8); typedef Struct_(Str8) { UTF8* ptr; U8 len; }; typedef Str8 Slice_UTF8; typedef Struct_(Slice_Str8) { Str8* ptr; U8 len; }; -#define slit8(string_literal) (Str8){ (UTF8*) string_literal, S_(string_literal) - 1 } +#define slit8(string_literal) ((Str8){ (UTF8*) string_literal, S_(string_literal) - 1 }) #define str8(p,l) (Str8){p,l} typedef Struct_(Slice) { U8 ptr; U8 len; }; // Untyped Slice @@ -81,7 +81,6 @@ FI_ Slice slice_ut_(U8 ptr, U8 len) { return (Slice){ptr, len}; } #define slice_ut(ptr,len) slice_ut_(u8_(ptr), u8_(len)) #define slice_ut_arr(a) slice_ut_(u8_(a), S_(a)) #define slice_to_ut(s) slice_ut_(u8_((s).ptr), S_slice(s)) - #define slice_iter(container, iter) (T_((container).ptr) iter = (container).ptr; iter != slice_end(container); ++ iter) #define slice_arg_from_array(type, ...) & (tmpl(Slice,type)) { .ptr = Array_decl(type,__VA_ARGS__), .len = Array_len( Array_decl(type,__VA_ARGS__)) } #define slice_from_array(type, array) (tmpl(Slice,type)) { .ptr = array, .len = S_(array) } @@ -108,6 +107,15 @@ typedef Slice_(U8); #pragma endregion Slice +I_ Slice mem_push_aligned_typed(U8 start, U8 capacity, U8_R used, U8 amount, U4 alignment, U4 type_width) { + if (amount == 0) { return (Slice){}; } + U8 desired = amount * (type_width == 0 ? 1 : type_width); + U8 to_commit = align_pow2(desired, alignment ? alignment : MEM_ALIGNMENT_DEFAULT); + U8 ptr = start + used[0]; + mem_bump_u8(start, capacity, used, to_commit); + return (Slice){ ptr, to_commit }; +} + #pragma region FArena typedef Opt_(farena) { U8 alignment, type_width; }; @@ -118,13 +126,8 @@ FI_ void farena_init(FArena_R arena, Slice mem) { assert(arena != nullptr); arena->used = 0; } FI_ FArena farena_make(Slice mem) { FArena a; farena_init(& a, mem); return a; } -I_ Slice farena_push(FArena_R arena, U8 amount, Opt_farena o) { - if (amount == 0) { return (Slice){}; } - U8 desired = amount * (o.type_width == 0 ? 1 : o.type_width); - U8 to_commit = align_pow2(desired, o.alignment ? o.alignment : MEM_ALIGNMENT_DEFAULT); - U8 ptr = arena->start + arena->used; - mem_bump_u8(arena->start, arena->capacity, & arena->used, to_commit); - return (Slice){ ptr, to_commit }; +FI_ Slice farena_push(FArena_R arena, U8 amount, Opt_farena o) { + return mem_push_aligned_typed(arena->start, arena->capacity, & arena->used, amount, o.alignment, o.type_width); } FI_ void farena_reset (FArena_R arena) { arena->used = 0; } FI_ void farena_rewind(FArena_R arena, U8 save_point) { @@ -132,8 +135,25 @@ FI_ void farena_rewind(FArena_R arena, U8 save_point) { arena->used = save_point; } FI_ U8 farena_save(FArena arena) { return arena.used; } -#define farena_push_(arena, amount, ...) farena_push((arena), (amount), opt_(farena, __VA_ARGS__)) -#define farena_push_type(arena, type, ...) C_(type*, farena_push((arena), 1, opt_(farena, .type_width=S_(type), __VA_ARGS__)).ptr) -#define farena_push_array(arena, type, amount, ...) (tmpl(Slice,type)){ C_(type*, farena_push((arena), (amount), opt_(farena, .type_width=S_(type), __VA_ARGS__)).ptr), (amount) } +#define farena_push_(arena, amount, ...) farena_push((arena),(amount),opt_(farena,__VA_ARGS__)) +#define farena_push_type(arena, type, ...) C_(type*,farena_push((arena),1, opt_(farena,.type_width=S_(type),__VA_ARGS__)).ptr) +#define farena_push_array(arena, type, amount, ...) (tmpl(Slice,type)){ C_(type*,farena_push((arena),(amount),opt_(farena,.type_width=S_(type),__VA_ARGS__)).ptr),(amount) } #pragma endregion FArena + +#pragma region FStack +#define FStack_(name, type, width) Struct_(name) { U8 top; type arr[width]; } + +FI_ Slice fstack_push(Slice mem, U8_R top, U8 amount, Opt_farena o) { + return mem_push_aligned_typed(mem.ptr, mem.len, top, amount, o.alignment, o.type_width); +}; + +// This is here more for annotation than anything else. +#define fstack_save(stack) stack.top +#define fstack_rewind(stack, sp) do{stack.top = sp;}while(0) +#define fstack_reset(stack) do{stack.top = 0; }while(0) + +#define fstack_slice(stack) slice_ut_arr((stack).arr) +#define fstack_push_(stk, amount, ...) fstack_push(fstack_slice(stk),&(stk).top,(amount),opt_(farena,__VA_ARGS__)) +#define fstack_push_array(stk, type, amount, ...) (tmpl(Slice,type)){ C_(type*,fstack_push(fstack_slice(stk),&(stk).top,(amount),opt_(farena,.type_width=S_(type),__VA_ARGS__)).ptr),(amount) } +#pragma endregion FStack diff --git a/code/duffle/tables.h b/code/duffle/tables.h index 6113376..6e1a3c1 100644 --- a/code/duffle/tables.h +++ b/code/duffle/tables.h @@ -8,7 +8,7 @@ #pragma region Key Table Linear (KTL) -enum { KT_SLot_value = S_(U8), }; +enum { KT_Slot_value = S_(U8), }; #define KTL_Slot_(type) Struct_(tmpl(KTL_Slot,type)) { \ U8 key; \ type value; \ @@ -34,7 +34,7 @@ FI_ void ktl_populate_slice_a2_str8(KTL_Str8* kt, Slice_A2_Str8 values) { mem_copy(u8_(& kt->ptr[id].value), u8_(& values.ptr[id][1]), S_(Str8)); } } -#define ktl_str8_key(str) hash64_fnv1a_ret(slice_to_ut(str8(str)), 0) -#define ktl_str8_from_arr(arr) (KTL_Str8){arr, array_len(arr)} +#define ktl_str8_key(str) hash64_fnv1a_ret(slice_to_ut(slit8(str)), 0) +#define ktl_str8_from_arr(arr) (KTL_Str8){arr, Array_len(arr)} #pragma endregion KTL diff --git a/code/duffle/text.h b/code/duffle/text.h index 9e94856..a590367 100644 --- a/code/duffle/text.h +++ b/code/duffle/text.h @@ -162,9 +162,9 @@ I_ Str8 str8_fmt_ktl_buf(Slice buffer, KTL_Str8 table, Str8 fmt_template) { // We're going to appending the string, make sure we have enough space in our buffer. // NOTE(Ed): this version doesn't support growing the buffer (No Allocator Interface) - assert((buffer_remaining - potential_token_len) > 0); copy_offset = min(buffer_remaining, value->len); // Prevent Buffer overflow. - mem_copy(u8_(cursor_buffer), u8_(value->ptr), buffer_remaining); + assert((buffer_remaining - copy_offset) > 0); + mem_copy(u8_(cursor_buffer), u8_(value->ptr), copy_offset); // Sync cursor format to after the processed token cursor_buffer += copy_offset; buffer_remaining -= copy_offset; @@ -235,3 +235,24 @@ str16_from_8(FArena* arena, Str8 in) { } return result; } + +// Formatter where serial operation is done on-demand per-entry. + +// enum { +// KTL_Str8FmtEntry_InlaidSize = (S_(Str8) * 2) - S_(Str8Fmt_TokenKind), +// }; +// typedef Enum_(U4, Str8Fmt_SerialOpKind) { +// Str8Fmt_TKind_Str8, +// Str8Fmt_Base16_U1, +// Str8Fmt_Base16_U2, +// Str8Fmt_Base10_U4, +// }; +// typedef Struct_(KTL_Str8Fmt_SerialOp_Entry) { +// union { +// U1 InlaidData[KTL_Str8FmtEntry_InlaidSize]; +// Str8 str; +// void* Ptr; +// }; +// Str8Fmt_SerialOpKind kind; +// }; +// typedef KTL_Slot_(KTL_Str8Fmt_SerialOp_Entry); diff --git a/scripts/build.ps1 b/scripts/build.ps1 index 6450cee..2f2afef 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -128,6 +128,7 @@ $f_ms_extensions = '-fms-extensions' # Allow MSVC language extension $f_ms_compatibility = '-fms-compatibility' $f_ms_runtime_lib_none = '-fno-ms-runtime' $f_preprocess_non_integrated = '-no-integrated-cpp' +$f_stack_probes_disabled = '-mno-stack-arg-probe' # Requires the fully committed stack in link-modules $f_stack_protector = '-fstack-protector' $f_stack_protector_strong = '-fstack-protector-strong' $f_stack_protector_all = '-fstack-protector-all' @@ -289,6 +290,7 @@ function compile-unit { param( $compile_args += $f_wall $compile_args += $f_wno_attributes $compile_args += $f_exceptions_disabled + $compile_args += $f_stack_probes_disabled $compile_args += $f_diagnostics_absolute $compile_args += $f_debug foreach ($p in $include_paths) { @@ -321,6 +323,7 @@ function link-modules { param( $link_args += $f_link_win_no_incremental $link_args += ($f_link_win_path_output + $module) $link_args += $f_link_win_subsystem_console + $link_args += ($f_link_win_stack + '262144,262144') # 256 KiB reserved $link_args += $f_link_win_debug $link_args += ($f_link_win_entry + 'main') $link_args += ($f_link_win_pdb + $pdb)