Skip to content

Commit

Permalink
fix some issues to retain compatibility with v1.0, fixes some test ca…
Browse files Browse the repository at this point in the history
…ses in fadden's suite. 3000 still fails because 1.0 outputs the DP value in lda ^DP instead of 0 for the bank. Optimized some checks to use integer checks instead of string compares.
  • Loading branch information
lroathe-quicken committed Dec 3, 2019
1 parent 4bf2f72 commit 3767ca5
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 16 deletions.
5 changes: 3 additions & 2 deletions Source/Dc_Library.c
Original file line number Diff line number Diff line change
Expand Up @@ -3933,8 +3933,8 @@ int64_t EvalExpressionAsInteger(char *expression_param, char *buffer_error_rtn,
strcpy(buffer_error_rtn,"");
*byte_count_rtn = (BYTE)(current_line->nb_byte - 1); /* Size of the Operand */
*expression_address_rtn = 0xFFFFFFFF; /* This is not a long address */
is_pea_opcode = !my_stricmp(current_line->opcode_txt,"PEA");
is_mvn_opcode = (!my_stricmp(current_line->opcode_txt,"MVN") || !my_stricmp(current_line->opcode_txt,"MVP"));
is_pea_opcode = current_line->opcode_byte == 0xF4 /*PEA*/;
is_mvn_opcode = (current_line->opcode_byte == 0x54 /*MVN*/ || current_line->opcode_byte == 0x44 /*MVP*/);

/** We will treat the # < > ^ | from the very beginning **/
int has_hash = (expression_param[0] == '#') ? 1 : 0;
Expand Down Expand Up @@ -4356,6 +4356,7 @@ int64_t EvalExpressionAsInteger(char *expression_param, char *buffer_error_rtn,
/* Code Line */
if(current_line->type == LINE_CODE)
{
/* @TODO: ^ should always return bank, regardless of operand or mode! */
/* Number of Bytes to Relocate */
if((has_hash == 1 || is_pea_opcode == 1) && has_exp == 1) /* # ^ = 1 or 2 Byte relocate */
{
Expand Down
13 changes: 9 additions & 4 deletions Source/a65816_Code.c
Original file line number Diff line number Diff line change
Expand Up @@ -2148,7 +2148,7 @@ static void BuildOneCodeLineOperand(struct source_line *current_line, int *has_e

/** Calculate the value of the Operand **/
next_sep = strchr(param->buffer_operand,',');
if((!my_stricmp(current_line->opcode_txt,"MVN") || !my_stricmp(current_line->opcode_txt,"MVP")) && next_sep != NULL)
if((current_line->opcode_byte == 0x54 /*MVN*/ || current_line->opcode_byte == 0x44 /*MVP*/) && next_sep != NULL)
{
/** NOTE: MVN / MVP have two expressions **/
*next_sep = '\0';
Expand Down Expand Up @@ -2191,7 +2191,12 @@ static void BuildOneCodeLineOperand(struct source_line *current_line, int *has_e
/* Want the high word of the value? */
if( current_line->operand_txt[0] == '^' )
{
operand_value_64 = (operand_value_64 >> 16); /* move down so bank and page are all that we have left */
/* @TODO: EvalExpressionAsInteger should always return bank for ^ usage, regardless of operand or mode! When fixed, remove this if code! */
// do not need to do this for PEA, it's already the bank value
if( current_line->opcode_byte != 0xF4 )
{
operand_value_64 = (operand_value_64 >> 16); /* move down so bank is all that we have left */
}
}
else if( current_line->operand_txt[0] == '<' )
{
Expand Down Expand Up @@ -2659,7 +2664,7 @@ static int GetOperandNbByte(char *operand, struct source_line *current_line, int
has_long_addr = 1;

/* Copy of Block? (MVN, MVP) */
if(!my_stricmp(current_line->opcode_txt,"MVN") || !my_stricmp(current_line->opcode_txt,"MVP"))
if(current_line->opcode_byte == 0x54 /*MVN*/ || current_line->opcode_byte == 0x44 /*MVP*/)
is_block_copy = 1;

/** Process the # < > ^ | **/
Expand Down Expand Up @@ -2797,7 +2802,7 @@ static int GetOperandNbByte(char *operand, struct source_line *current_line, int
{
/* > */
current_line->no_direct_page = 1;
nb_max_byte = 2;
nb_max_byte = 3;
}
else if(has_pipe == 1) /*@TODO: this may be a bug as it allows !, which should be "NOT" and not LONG...?) */
{
Expand Down
2 changes: 1 addition & 1 deletion Source/version.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#ifndef MERLIN_VERSION
#define MERLIN_VERSION "v1.1.7"
#define MERLIN_VERSION "v1.1.8"
#endif
62 changes: 53 additions & 9 deletions Test/main.s
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,11 @@ _LFT ds 1 ;Window edge 0..39
* Program Entry

;Issue #26 - This should start at the ORG in the linkscript, not at the last ORG in the DUM sections.
START
TEST_START

; PUT current issue here, so it's the first thing assembled.
; The rest below are unit tests to make sure future changes don't break existing code!

;CR/LF test (requires reformatting this file)
hex 0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a

asl
asl
asl
asl

; START OF TESTS KNOWN TO HAVE PASSED IN PREVIOUS BUILDS

; --- Test all instructions in all their modes, with as many variants as possible ---
Expand Down Expand Up @@ -221,5 +213,57 @@ L00BC bit L00BC
;:COUNTL DB $00
;:COUNTH DB $00

xc
xc
org $018200

bank02 equ $020000
bank03 equ $030000
dp equ $A5
long equ $020304

mx %00
start nop
pea ^start
pea start
mvn bank02,bank03
mvp bank03,bank02

lda dp
lda <dp
lda >dp
lda ^dp
lda |dp

lda #long
lda #<long
lda #>long
lda #^long

lda long
lda <long
lda >long
lda ^long

pea #long
pea #<long
pea #>long
pea #^long

pea long
pea <long
pea >long
pea ^long

org

;CR/LF test (requires reformatting this file)
hex 0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a

asl
asl
asl
asl


]XCODEEND ; Keep this at the end and put your code above this

0 comments on commit 3767ca5

Please sign in to comment.