mirror of
https://github.com/ksherlock/x65.git
synced 2025-01-01 15:30:06 +00:00
Struse was updated and fixing related issues
This commit is contained in:
parent
c01b19a68c
commit
c22c238f51
36
x65.cpp
36
x65.cpp
@ -1873,7 +1873,7 @@ void Asm::SetSection(strref line)
|
|||||||
int align = 1;
|
int align = 1;
|
||||||
strref name;
|
strref name;
|
||||||
while (strref arg = line.split_token_any_trim(",:")) {
|
while (strref arg = line.split_token_any_trim(",:")) {
|
||||||
if (arg.get_first() == '$') { ++arg; align = arg.ahextoui(); }
|
if (arg.get_first() == '$') { ++arg; align = (int)arg.ahextoui(); }
|
||||||
else if (arg.is_number()) align = arg.atoi();
|
else if (arg.is_number()) align = arg.atoi();
|
||||||
else if (arg.get_first() == '"') name = (arg + 1).before_or_full('"');
|
else if (arg.get_first() == '"') name = (arg + 1).before_or_full('"');
|
||||||
else if (!name) name = arg;
|
else if (!name) name = arg;
|
||||||
@ -2624,9 +2624,9 @@ void Section::AddText(strref line, strref text_prefix) {
|
|||||||
// shifted: a-z => $41.. A-Z => $61..
|
// shifted: a-z => $41.. A-Z => $61..
|
||||||
// unshifted: a-z, A-Z => $41
|
// unshifted: a-z, A-Z => $41
|
||||||
|
|
||||||
if (CheckOutputCapacity(line.get_len()) == STATUS_OK) {
|
if (CheckOutputCapacity((uint32_t)line.get_len()) == STATUS_OK) {
|
||||||
if (!text_prefix || text_prefix.same_str("ascii")) {
|
if (!text_prefix || text_prefix.same_str("ascii")) {
|
||||||
AddBin((const uint8_t*)line.get(), line.get_len());
|
AddBin((const uint8_t*)line.get(), (int)line.get_len());
|
||||||
} else if (text_prefix.same_str("petscii")) {
|
} else if (text_prefix.same_str("petscii")) {
|
||||||
while (line) {
|
while (line) {
|
||||||
char c = line[0];
|
char c = line[0];
|
||||||
@ -2877,7 +2877,7 @@ StatusCode Asm::BuildMacro(Macro &m, strref arg_list)
|
|||||||
int count = macro_src.substr_case_count(tag.get_strref());
|
int count = macro_src.substr_case_count(tag.get_strref());
|
||||||
dSize += count * ((int)a.get_len() - (int)tag.get_len());
|
dSize += count * ((int)a.get_len() - (int)tag.get_len());
|
||||||
}
|
}
|
||||||
int mac_size = macro_src.get_len() + dSize + 32;
|
int mac_size = (int)macro_src.get_len() + dSize + 32;
|
||||||
if (char *buffer = (char*)malloc(mac_size)) {
|
if (char *buffer = (char*)malloc(mac_size)) {
|
||||||
loadedData.push_back(buffer);
|
loadedData.push_back(buffer);
|
||||||
strovl macexp(buffer, mac_size);
|
strovl macexp(buffer, mac_size);
|
||||||
@ -2924,7 +2924,7 @@ StatusCode Asm::BuildMacro(Macro &m, strref arg_list)
|
|||||||
dSize += count * ((int)a.get_len() - (int)param.get_len());
|
dSize += count * ((int)a.get_len() - (int)param.get_len());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int mac_size = macro_src.get_len() + dSize + 32;
|
int mac_size = (int)macro_src.get_len() + dSize + 32;
|
||||||
if (char *buffer = (char*)malloc(mac_size)) {
|
if (char *buffer = (char*)malloc(mac_size)) {
|
||||||
loadedData.push_back(buffer);
|
loadedData.push_back(buffer);
|
||||||
strovl macexp(buffer, mac_size);
|
strovl macexp(buffer, mac_size);
|
||||||
@ -3158,7 +3158,7 @@ EvalOperator Asm::RPNToken_Merlin(strref &expression, const struct EvalContext &
|
|||||||
{
|
{
|
||||||
char c = expression.get_first();
|
char c = expression.get_first();
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case '$': ++expression; value = expression.ahextoui_skip(); return EVOP_VAL;
|
case '$': ++expression; value = (int)expression.ahextoui_skip(); return EVOP_VAL;
|
||||||
case '-': ++expression; return EVOP_SUB;
|
case '-': ++expression; return EVOP_SUB;
|
||||||
case '+': ++expression; return EVOP_ADD;
|
case '+': ++expression; return EVOP_ADD;
|
||||||
case '*': // asterisk means both multiply and current PC, disambiguate!
|
case '*': // asterisk means both multiply and current PC, disambiguate!
|
||||||
@ -3173,7 +3173,7 @@ EvalOperator Asm::RPNToken_Merlin(strref &expression, const struct EvalContext &
|
|||||||
++expression; return EVOP_LOB;
|
++expression; return EVOP_LOB;
|
||||||
case '%': // % means both binary and scope closure, disambiguate!
|
case '%': // % means both binary and scope closure, disambiguate!
|
||||||
if (expression[1]=='0' || expression[1]=='1') {
|
if (expression[1]=='0' || expression[1]=='1') {
|
||||||
++expression; value = expression.abinarytoui_skip(); return EVOP_VAL; }
|
++expression; value = (int)expression.abinarytoui_skip(); return EVOP_VAL; }
|
||||||
if (etx.scope_end_pc<0 || scope_depth != etx.scope_depth) return EVOP_NRY;
|
if (etx.scope_end_pc<0 || scope_depth != etx.scope_depth) return EVOP_NRY;
|
||||||
++expression; value = etx.scope_end_pc; section = CurrSection().IsRelativeSection() ? SectionId() : -1; return EVOP_VAL;
|
++expression; value = etx.scope_end_pc; section = CurrSection().IsRelativeSection() ? SectionId() : -1; return EVOP_VAL;
|
||||||
case '|':
|
case '|':
|
||||||
@ -3222,7 +3222,7 @@ EvalOperator Asm::RPNToken(strref &exp, const struct EvalContext &etx, EvalOpera
|
|||||||
{
|
{
|
||||||
char c = exp.get_first();
|
char c = exp.get_first();
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case '$': ++exp; value = exp.ahextoui_skip(); return EVOP_VAL;
|
case '$': ++exp; value = (int)exp.ahextoui_skip(); return EVOP_VAL;
|
||||||
case '-': ++exp; return EVOP_SUB;
|
case '-': ++exp; return EVOP_SUB;
|
||||||
case '+': ++exp; return EVOP_ADD;
|
case '+': ++exp; return EVOP_ADD;
|
||||||
case '*': // asterisk means both multiply and current PC, disambiguate!
|
case '*': // asterisk means both multiply and current PC, disambiguate!
|
||||||
@ -3241,7 +3241,7 @@ EvalOperator Asm::RPNToken(strref &exp, const struct EvalContext &etx, EvalOpera
|
|||||||
if (exp[0] == '=') { ++exp; return EVOP_LTE; } return EVOP_LT; }
|
if (exp[0] == '=') { ++exp; return EVOP_LTE; } return EVOP_LT; }
|
||||||
++exp; return EVOP_LOB;
|
++exp; return EVOP_LOB;
|
||||||
case '%': // % means both binary and scope closure, disambiguate!
|
case '%': // % means both binary and scope closure, disambiguate!
|
||||||
if (exp[1] == '0' || exp[1] == '1') { ++exp; value = exp.abinarytoui_skip(); return EVOP_VAL; }
|
if (exp[1] == '0' || exp[1] == '1') { ++exp; value = (int)exp.abinarytoui_skip(); return EVOP_VAL; }
|
||||||
if (etx.scope_end_pc<0 || scope_depth != etx.scope_depth) return EVOP_NRY;
|
if (etx.scope_end_pc<0 || scope_depth != etx.scope_depth) return EVOP_NRY;
|
||||||
++exp; value = etx.scope_end_pc; section = CurrSection().IsRelativeSection() ? SectionId() : -1; return EVOP_VAL;
|
++exp; value = etx.scope_end_pc; section = CurrSection().IsRelativeSection() ? SectionId() : -1; return EVOP_VAL;
|
||||||
case '|': ++exp; return EVOP_OR;
|
case '|': ++exp; return EVOP_OR;
|
||||||
@ -6284,7 +6284,7 @@ static int _AddStrPool(const strref str, pairArray<uint32_t, int> *pLookup, char
|
|||||||
|
|
||||||
int strOffs = strPoolSize;
|
int strOffs = strPoolSize;
|
||||||
if ((strOffs + str.get_len() + 1) > strPoolCap) {
|
if ((strOffs + str.get_len() + 1) > strPoolCap) {
|
||||||
strPoolCap = strOffs + str.get_len() + 4096;
|
strPoolCap = strOffs + (uint32_t)str.get_len() + 4096;
|
||||||
char *strPoolGrow = (char*)malloc(strPoolCap);
|
char *strPoolGrow = (char*)malloc(strPoolCap);
|
||||||
if (strPoolGrow) {
|
if (strPoolGrow) {
|
||||||
if (*strPool) {
|
if (*strPool) {
|
||||||
@ -6300,7 +6300,7 @@ static int _AddStrPool(const strref str, pairArray<uint32_t, int> *pLookup, char
|
|||||||
char *dest = *strPool + strPoolSize;
|
char *dest = *strPool + strPoolSize;
|
||||||
memcpy(dest, str.get(), str.get_len());
|
memcpy(dest, str.get(), str.get_len());
|
||||||
dest[str.get_len()] = 0;
|
dest[str.get_len()] = 0;
|
||||||
strPoolSize += str.get_len()+1;
|
strPoolSize += (uint32_t)str.get_len()+1;
|
||||||
pLookup->insert(index, hash);
|
pLookup->insert(index, hash);
|
||||||
pLookup->getValues()[index] = strOffs;
|
pLookup->getValues()[index] = strOffs;
|
||||||
}
|
}
|
||||||
@ -6829,7 +6829,7 @@ StatusCode Asm::WriteA2GS_OMF(strref filename, bool full_collapse)
|
|||||||
|
|
||||||
_writeNBytes(hdr.SegNum, 2, SegLookup[*i] + 1);
|
_writeNBytes(hdr.SegNum, 2, SegLookup[*i] + 1);
|
||||||
_writeNBytes(hdr.Kind, 2, s.type == ST_CODE ? 0x1000 : (s.type == ST_ZEROPAGE ? 0x12 : 0x1001));
|
_writeNBytes(hdr.Kind, 2, s.type == ST_CODE ? 0x1000 : (s.type == ST_ZEROPAGE ? 0x12 : 0x1001));
|
||||||
_writeNBytes(hdr.DispDataOffset, 2, sizeof(hdr) + 10 + 1 + segName.get_len());
|
_writeNBytes(hdr.DispDataOffset, 2, sizeof(hdr) + 10 + 1 + (int)segName.get_len());
|
||||||
_writeNBytes(hdr.Length, 4, num_bytes_file + num_zeroes_at_end);
|
_writeNBytes(hdr.Length, 4, num_bytes_file + num_zeroes_at_end);
|
||||||
_writeNBytes(hdr.ResSpc, 4, num_zeroes_at_end);
|
_writeNBytes(hdr.ResSpc, 4, num_zeroes_at_end);
|
||||||
_writeNBytes(hdr.Align, 4, s.align_address > 1 ? 256 : 0);
|
_writeNBytes(hdr.Align, 4, s.align_address > 1 ? 256 : 0);
|
||||||
@ -6907,7 +6907,7 @@ StatusCode Asm::WriteA2GS_OMF(strref filename, bool full_collapse)
|
|||||||
instructions[instruction_offs++] = OMFR_END;
|
instructions[instruction_offs++] = OMFR_END;
|
||||||
|
|
||||||
// size of seg = file header + 10 bytes file name + 1 byte seg name length + seg nameh + seg.addr_size() + instruction_size
|
// size of seg = file header + 10 bytes file name + 1 byte seg name length + seg nameh + seg.addr_size() + instruction_size
|
||||||
int segSize = sizeof(hdr) + 10 + 1 + segName.get_len() + num_bytes_file + instruction_offs;
|
int segSize = sizeof(hdr) + 10 + 1 + (int)segName.get_len() + num_bytes_file + instruction_offs;
|
||||||
if (num_bytes_file == 0)
|
if (num_bytes_file == 0)
|
||||||
segSize -= 5;
|
segSize -= 5;
|
||||||
_writeNBytes(hdr.SegTotal, 4, segSize);
|
_writeNBytes(hdr.SegTotal, 4, segSize);
|
||||||
@ -6926,14 +6926,14 @@ StatusCode Asm::WriteA2GS_OMF(strref filename, bool full_collapse)
|
|||||||
// if there is a size of the direct page & stack, write it
|
// if there is a size of the direct page & stack, write it
|
||||||
if (DP_Stack_Size) {
|
if (DP_Stack_Size) {
|
||||||
strref segName("DPStack");
|
strref segName("DPStack");
|
||||||
char lenSegName = segName.get_len();
|
char lenSegName = (char)segName.get_len();
|
||||||
_writeNBytes(hdr.SegNum, 2, (int)SegNum.size()+1);
|
_writeNBytes(hdr.SegNum, 2, (int)SegNum.size()+1);
|
||||||
_writeNBytes(hdr.Kind, 2, 0x12);
|
_writeNBytes(hdr.Kind, 2, 0x12);
|
||||||
_writeNBytes(hdr.DispDataOffset, 2, sizeof(hdr) + 10 + 1 + segName.get_len());
|
_writeNBytes(hdr.DispDataOffset, 2, sizeof(hdr) + 10 + 1 + (int)segName.get_len());
|
||||||
_writeNBytes(hdr.Length, 4, DP_Stack_Size);
|
_writeNBytes(hdr.Length, 4, DP_Stack_Size);
|
||||||
_writeNBytes(hdr.ResSpc, 4, DP_Stack_Size);
|
_writeNBytes(hdr.ResSpc, 4, DP_Stack_Size);
|
||||||
_writeNBytes(hdr.Align, 4, 256);
|
_writeNBytes(hdr.Align, 4, 256);
|
||||||
int segSize = sizeof(hdr) + 10 + 1 + segName.get_len() + 1;
|
int segSize = sizeof(hdr) + 10 + 1 + (int)segName.get_len() + 1;
|
||||||
_writeNBytes(hdr.SegTotal, 4, segSize);
|
_writeNBytes(hdr.SegTotal, 4, segSize);
|
||||||
instructions[0] = 0;
|
instructions[0] = 0;
|
||||||
fwrite(&hdr, sizeof(hdr), 1, f);
|
fwrite(&hdr, sizeof(hdr), 1, f);
|
||||||
@ -7016,7 +7016,7 @@ int main(int argc, char **argv)
|
|||||||
} else if (arg.has_prefix(org)) {
|
} else if (arg.has_prefix(org)) {
|
||||||
arg = arg.after('=');
|
arg = arg.after('=');
|
||||||
if (arg && arg.get_first() == '$' && arg.get_len()>1)
|
if (arg && arg.get_first() == '$' && arg.get_len()>1)
|
||||||
assembler.default_org = (arg + 1).ahextoui();
|
assembler.default_org = (int)(arg + 1).ahextoui();
|
||||||
else if (arg.is_number())
|
else if (arg.is_number())
|
||||||
assembler.default_org = arg.atoi();
|
assembler.default_org = arg.atoi();
|
||||||
// force the current section to be org'd
|
// force the current section to be org'd
|
||||||
@ -7050,6 +7050,8 @@ int main(int argc, char **argv)
|
|||||||
obj_out_file = argv[++a];
|
obj_out_file = argv[++a];
|
||||||
else if (arg.same_str("vice") && (a + 1) < argc)
|
else if (arg.same_str("vice") && (a + 1) < argc)
|
||||||
vs_file = argv[++a];
|
vs_file = argv[++a];
|
||||||
|
else
|
||||||
|
printf("Unexpected option " STRREF_FMT "\n", STRREF_ARG(arg));
|
||||||
} else if (!source_filename)
|
} else if (!source_filename)
|
||||||
source_filename = arg.get();
|
source_filename = arg.get();
|
||||||
else if (!binary_out_name)
|
else if (!binary_out_name)
|
||||||
|
Loading…
Reference in New Issue
Block a user