1
0
mirror of https://github.com/ksherlock/x65.git synced 2024-12-27 13:29:18 +00:00

Fixing 16 vs 8 bit immediate load issue (again)

This commit is contained in:
Carl-Henrik Skårstedt 2019-09-20 18:20:30 -07:00
parent 6e8a41acc1
commit 33b229d00a
7 changed files with 74 additions and 17 deletions

View File

@ -23,7 +23,7 @@
<ProjectGuid>{2823019A-A423-4A40-BB9C-5CE242019BD0}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>x65</RootNamespace>
<WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">

View File

@ -1,14 +1,17 @@
cpu 65816
Test65816_ForceAddrMode:
sep #$30
i8
ldx #0
i16
ldx #0
ldx #$1234
a8
lda #0
lda #$1234
lda.w #$1234
i16
ldx #$1234
a16
lda #0
lda.b #0
lda #$1234
lda.b #$1234
{
jmp >$123456

BIN
test/compare/x65scope.prg Normal file

Binary file not shown.

View File

@ -0,0 +1,6 @@
.label ClearVICPage = $1000
.label LenStr = $1012
.label GetSkip = $1019 {
.label .addr = $1026
}

View File

@ -73,6 +73,18 @@ echo x65macro.i test failed
goto exit
:x65macro_test_pass
echo x65 Scope Test >>results\unittest.txt
..\bin\x64\x65 x65scope.s results\x65scope.prg -lst -sym results\x65scope.sym
if %errorlevel% GTR 0 goto x65scope_test_fail
fc /B compare\x65scope.prg results\x65scope.prg >>results\unittest.txt
if %errorlevel% GTR 0 goto x65scope_test_fail
fc compare\x65scope.sym results\x65scope.sym >>results\unittest.txt
if %errorlevel% EQU 0 goto x65scope_test_pass
:x65scope_test_fail
echo x65 Scope Test failed
goto exit
:x65scope_test_pass
echo Merlin LUP Test >>results\unittest.txt
echo --------------- >>results\unittest.txt
..\bin\x64\x65 merlin_lup.s results\merlin_lup.bin -bin -org=$1000 -merlin -lst >>results\unittest.txt

38
test/x65scope.s Normal file
View File

@ -0,0 +1,38 @@
// Test various features of scoping.
ClearVICPage:
{
lda #0
tax
ldy #$40
{
sta $4000,x
inx
bne !
inc !+2
dey
bne !
}
rts
}
LenStr:
{
dc.b %-! ; length of string plus this byte
TEXT "String"
}
GetSkip:
{
clc
tya
adc .addr+1
sta .addr+1
{
bcc %
inc .addr+1
}
.addr
lda $1234
rts
}

18
x65.cpp
View File

@ -5604,16 +5604,14 @@ StatusCode Asm::AddOpcode(strref line, int index, strref source_file) {
break;
case AMB_IMM: // 2 #$12
if (op_param && (validModes&(AMM_IMM_DBL_A | AMM_IMM_DBL_XY)))
codeArg = op_param == 2 ? CA_TWO_BYTES : CA_ONE_BYTE;
else if ((validModes&(AMM_IMM_DBL_A | AMM_IMM_DBL_XY)) &&
expression[0]=='$' && (expression+1).len_hex()==4)
codeArg = CA_TWO_BYTES;
else if (((validModes&AMM_IMM_DBL_A) && accumulator_16bit) ||
((validModes&AMM_IMM_DBL_XY) && index_reg_16bit))
codeArg = CA_TWO_BYTES;
else
codeArg = CA_ONE_BYTE;
codeArg = CA_ONE_BYTE;
// check for double immediate
if( validModes & ( AMM_IMM_DBL_A | AMM_IMM_DBL_XY ) ) {
if( op_param ) { codeArg = op_param == 2 ? CA_TWO_BYTES : CA_ONE_BYTE; }
else if( ( ( validModes&AMM_IMM_DBL_A ) && accumulator_16bit ) ||
( ( validModes&AMM_IMM_DBL_XY ) && index_reg_16bit ) ) { codeArg = CA_TWO_BYTES; }
else { codeArg = CA_ONE_BYTE; }
}
break;
case AMB_ACC: // 9 A