Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvement: Add support for 16bit constant from two ascii chars #199

Open
wants to merge 1 commit into
base: master_archived
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 ^ (table.table[(unsigned char)str[2]] << 8);
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