Skip to content

Commit

Permalink
Improvement: Add support for 16bit constant from two ascii chars
Browse files Browse the repository at this point in the history
  • Loading branch information
furious committed Feb 17, 2021
1 parent b5d0789 commit 6babd4e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
3 changes: 3 additions & 0 deletions docs/manual/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1529,6 +1529,9 @@ <h4 id="number-literals">Number Literals</h4>
<pre><code class="65c816_asar">lda #'a'
sta $00

lda.w #'bc'
sta $01

db 'x','x'+1,'x'+2</code></pre>
<h4 id="opcode-length">Opcode Length Specification</h4>
By appending <code>.b</code>, <code>.w</code> or <code>.l</code> to an opcode, you can specify that opcode's length. This is recommended in cases where the length could be ambiguous.
Expand Down
6 changes: 5 additions & 1 deletion src/asar/asar_math.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -734,8 +734,12 @@ static double getnumcore()
}
if (*str=='\'')
{
if (!str[1] || str[2] != '\'') asar_throw_error(1, error_type_block, error_id_invalid_character);
if (!str[1] || (str[2] != '\'' && str[3] != '\'')) asar_throw_error(1, error_type_block, error_id_invalid_character);
unsigned int rval=table.table[(unsigned char)str[1]];
if(str[3] == '\''){
rval = (rval<<8) ^ table.table[(unsigned char)str[2]];
str+=1;
}
str+=3;
return rval;
}
Expand Down
5 changes: 5 additions & 0 deletions src/asar/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,11 @@ int getlen(const char * orgstr, bool optimizebankextraction)
thislen=1;
str+=3;
}
else if (str[0]=='\'' && str[3]=='\'')
{
thislen=2;
str+=4;
}
else if (is_digit(*str))
{
int val=strtol(str, const_cast<char**>(&str), 10);
Expand Down

0 comments on commit 6babd4e

Please sign in to comment.