1
0
mirror of https://github.com/ksherlock/x65.git synced 2024-12-26 22:30:50 +00:00

Fixed 16 bit immediate mode, tweaked unit tests, added |/! as WDC syntax for absolute addressing

This commit is contained in:
Carl-Henrik Skårstedt 2019-09-19 21:07:04 -07:00
parent 482470b410
commit de0bc5120f
7 changed files with 170 additions and 41 deletions

3
.gitignore vendored
View File

@ -17,4 +17,5 @@
*.db
*.obj.enc
*.user
*.db*
*.db*
test/results/*

View File

@ -23,7 +23,7 @@
<ProjectGuid>{57EFF4A4-7BF2-43F0-AD62-A79092DA67D1}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>dump_x65</RootNamespace>
<WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">

View File

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

View File

@ -1,5 +1,15 @@
cpu 65816
Test65816_ForceAddrMode:
i8
ldx #0
i16
ldx #0
a8
lda #0
a16
lda #0
lda.b #0
{
jmp >$123456
lda >$123456,x
@ -33,6 +43,25 @@ Test65816_ForceAddrMode:
endif
}
{
lda <$101030 // <addr zero page
if !((*-!) == 2)
err Expected zero page instruction
endif
}
{
lda |$101030 // |addr force absolute
if !((*-!) == 3)
err Expected zero page instruction
endif
}
{
lda >$101030 // .l force long
if !((*-!) == 4)
err Expected zero page instruction
endif
}
{
jmp [$1010]

77
test/local_label.s Normal file
View File

@ -0,0 +1,77 @@
CheckLocalPeriod:
lda #0
.loop
dex
sta $1000,x
bne .loop
CheckLocalColon:
lda #0
:loop
dex
sta $1000,x
bne :loop
CheckLocalSnabelA:
lda #0
@loop
dex
sta $1000,x
bne @loop
CheckLocalExclamation:
lda #0
!loop
dex
sta $1000,x
bne !loop
CheckLocalDallasSign:
lda #0
loop$
dex
dex
sta $1000,x
bne loop$
CheckLocalPeriod2:
lda #0
.loop
dex
sta $1000,x
bne .loop
CheckLocalColon2:
lda #0
:loop
dex
sta $1000,x
bne :loop
CheckLocalSnabelA2:
lda #0
@loop
dex
sta $1000,x
bne @loop
CheckLocalExclamation2:
lda #0
!loop
dex
sta $1000,x
bne !loop
CheckLocalDallasSign2:
lda #0
loop$
dex
sta $1000,x
bne loop$

View File

@ -1,74 +1,83 @@
@echo off
echo Unit tests for x65 assembler >unittest.txt
echo >>unittest.txt
if NOT EXIST results mkdir results
echo 65816 OpCodes Test >>unittest.txt
..\bin\x64\x65 Test65816_OpCodes.s -cpu=65816 -lst >> unittest.txt
if %errorlevel% EQU 0 goto opcodes_65816_pass
:opcodes_65816_fail
echo 65816 OpCodes failed
goto exit
:opcodes_65816_pass
echo Unit tests for x65 assembler >results\unittest.txt
echo >>results\unittest.txt
echo 65816 Force Addressing Mode Test >>unittest.txt
..\bin\x64\x65 AddrMode_65816.s -cpu=65816 -lst >> unittest.txt
echo 65816 Force Addressing Mode Test >>results\unittest.txt
..\bin\x64\x65 AddrMode_65816.s -cpu=65816 -lst >>results\unittest.txt
if %errorlevel% EQU 0 goto addrmode_pass
:addrmode_fail
echo Force Addressing Mode failed
goto exit
:addrmode_pass
echo Merlin Macro Test >>unittest.txt
echo ----------------- >>unittest.txt
..\bin\x64\x65 merlin_macro.s merlin_macro.bin -bin -org=$1000 -merlin -lst >>unittest.txt
echo 65816 Local Label Symbol Test >>results\unittest.txt
..\bin\x64\x65 local_label.s -cpu=65816 -lst >>results\unittest.txt
if %errorlevel% EQU 0 goto locallabel_pass
:locallabel_feil
echo Local Label Symbol Test failed
goto exit
:locallabel_pass
echo 65816 OpCodes Test >>results\unittest.txt
..\bin\x64\x65 Test65816_OpCodes.s -cpu=65816 -lst >>results\unittest.txt
if %errorlevel% EQU 0 goto opcodes_65816_pass
:opcodes_65816_fail
echo 65816 OpCodes failed
goto exit
:opcodes_65816_pass
echo Merlin Macro Test >>results\unittest.txt
echo ----------------- >>results\unittest.txt
..\bin\x64\x65 merlin_macro.s results\merlin_macro.bin -bin -org=$1000 -merlin -lst >>results\unittest.txt
if %errorlevel% GTR 0 goto mermac_fail
fc /B compare\merlin_macro_cmp.bin merlin_macro.bin >>unittest.txt
fc /B compare\merlin_macro_cmp.bin results\merlin_macro.bin >>results\unittest.txt
if %errorlevel% EQU 0 goto mermac_pass
:mermac_fail
echo Merlin macro test failed
goto exit
:mermac_pass
echo 8BitDiff Test >>unittest.txt
echo ------------- >>unittest.txt
..\bin\x64\x65 8BitDiff_6502.s 8BitDiff_6502.prg -kickasm -sym 8BitDiff_6502.sym -lst >>unittest.txt
echo 8BitDiff Test >>results\unittest.txt
echo ------------- >>results\unittest.txt
..\bin\x64\x65 8BitDiff_6502.s results\8BitDiff_6502.prg -kickasm -sym results\8BitDiff_6502.sym -lst >>results\unittest.txt
if %errorlevel% GTR 0 goto 8BitDiff_6502_fail
fc /B compare\8BitDiff_6502_cmp.prg 8BitDiff_6502.prg >>unittest.txt
fc /B compare\8BitDiff_6502_cmp.prg results\8BitDiff_6502.prg >>results\unittest.txt
if %errorlevel% EQU 0 goto 8BitDiff_6502_pass
:8BitDiff_6502_fail
echo 8BitDiff_6502 test failed
goto exit
:8BitDiff_6502_pass
echo Alias Test >>unittest.txt
echo ---------- >>unittest.txt
..\bin\x64\x65 alias_test.s alias_test.prg -sym alias_test.sym -lst >>unittest.txt
echo Alias Test >>results\unittest.txt
echo ---------- >>results\unittest.txt
..\bin\x64\x65 alias_test.s results\alias_test.prg -sym results\alias_test.sym -lst >>results\unittest.txt
if %errorlevel% GTR 0 goto alias_test_fail
fc /B compare\alias_test_cmp.prg alias_test.prg >>unittest.txt
fc /B compare\alias_test_cmp.prg results\alias_test.prg >>results\unittest.txt
if %errorlevel% EQU 0 goto alias_test_pass
:alias_test_fail
echo Alias test failed
goto exit
:alias_test_pass
echo x65macro.i Test >>unittest.txt
echo --------------- >>unittest.txt
..\bin\x64\x65 x65macro_test.s x65macro_test.prg -org=$1000 -sym x65macro_test.sym -lst >>unittest.txt
echo x65macro.i Test >>results\unittest.txt
echo --------------- >>results\unittest.txt
..\bin\x64\x65 x65macro_test.s results\x65macro_test.prg -org=$1000 -sym results\x65macro_test.sym -lst >>results\unittest.txt
if %errorlevel% GTR 0 goto x65macro_test_fail
fc /B compare\x65macro_test_cmp.prg x65macro_test.prg >>unittest.txt
fc /B compare\x65macro_test_cmp.prg results\x65macro_test.prg >>results\unittest.txt
if %errorlevel% EQU 0 goto x65macro_test_pass
:x65macro_test_fail
echo x65macro.i test failed
goto exit
:x65macro_test_pass
echo Merlin LUP Test >>unittest.txt
echo --------------- >>unittest.txt
..\bin\x64\x65 merlin_lup.s merlin_lup.bin -bin -org=$1000 -merlin -lst >>unittest.txt
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
if %errorlevel% GTR 0 goto merlup_fail
fc /B compare\merlin_lup_cmp.bin merlin_lup.bin >>unittest.txt
fc /B compare\merlin_lup_cmp.bin results\merlin_lup.bin >>results\unittest.txt
if %errorlevel% EQU 0 goto merlup_pass
:merlup_fail
echo Merlin LUP test failed

25
x65.cpp
View File

@ -5372,6 +5372,23 @@ StatusCode Asm::GetAddressMode(strref line, bool flipXY, uint32_t &validModes, A
} else {
addrMode = AMB_ZP; validModes &= AMM_ZP;
}
} else if (c == '<') {
validModes &= AMM_ZP | AMM_ZP_X | AMM_ZP_REL_X | AMM_ZP_Y_REL |
AMM_ZP_REL | AMM_ZP_ABS | AMM_ZP_REL_L | AMM_ZP_REL_Y_L | AMM_FLIPXY;
} else if( c == '|' || c == '!' ) {
++line; line.trim_whitespace();
strref suffix = line.after( ',' ); suffix.skip_whitespace();
expression = line.before_or_full( ',' ); expression.trim_whitespace();
addrMode = AMB_NON;
if( suffix ) {
if( suffix.get_first() == 'x' || suffix.get_first() == 'X' ) {
addrMode = AMB_ABS_X; validModes &= AMM_ABS_X;
} else if( suffix.get_first() == 'y' || suffix.get_first() == 'Y' ) {
addrMode = AMB_ABS_Y; validModes &= AMM_ABS_Y;
}
} else {
addrMode = AMB_ABS; validModes &= AMM_ABS;
}
} else if( c == '>' ) {
++line; line.trim_whitespace();
strref suffix = line.after( ',' ); suffix.skip_whitespace();
@ -5385,20 +5402,16 @@ StatusCode Asm::GetAddressMode(strref line, bool flipXY, uint32_t &validModes, A
else {
addrMode = AMB_ABS_L; validModes &= AMM_ABS_L;
}
} else if (c == '#') {
++line;
addrMode = AMB_IMM;
validModes &= AMM_IMM;
validModes &= AMM_IMM | AMM_IMM_DBL_A | AMM_IMM_DBL_XY;
expression = line;
} else if (c == '<') {
validModes &= AMM_ZP | AMM_ZP_X | AMM_ZP_REL_X | AMM_ZP_Y_REL |
AMM_ZP_REL | AMM_ZP_ABS | AMM_ZP_REL_L | AMM_ZP_REL_Y_L | AMM_FLIPXY;
} else if (line) {
if (line[0]=='.' && strref::is_ws(line[2])) {
switch (strref::tolower(line[1])) {
case 'z': force_zp = true; line += 3; need_more = true; len = 1; break;
case 'b': line += 3; need_more = true; len = 1; break;
case 'b': line += 3; need_more = true; len = 1; validModes &= ~(AMM_IMM_DBL_A | AMM_IMM_DBL_XY); break;
case 'w': line += 3; need_more = true; len = 2; break;
case 'l': force_24 = true; line += 3; need_more = true; len = 3; break;
case 'a': force_abs = true; line += 3; need_more = true; break;