Added .asize and .isize pseudo variables

These pseudo variables will return the size of the accumulator/index
in bits.

For the 65816 instruction set .ASIZE/.ISIZE will return either 8 or 16,
depending on the current size of the operand in immediate addressing
mode.

For all other CPU instruction sets, .ASIZE/.ISIZE will always return 8.

For example:

	; Reverse Subtract with Accumulator
	; A = memory - A
	.macro rsb param
		.if .asize = 8
			eor	#$ff
		.else
			eor	#$ffff
		.endif
		sec
		adc	param
	.endmacro
This commit is contained in:
Marcus Rowe
2015-10-20 09:30:25 +10:00
parent f4335eca87
commit 67cd0c2197
5 changed files with 66 additions and 0 deletions

View File

@@ -1099,6 +1099,15 @@ static ExprNode* Factor (void)
N = Function (FuncAddrSize);
break;
case TOK_ASIZE:
if (GetCPU() != CPU_65816) {
N = GenLiteralExpr (8);
} else {
N = GenLiteralExpr (ExtBytes [AM65I_IMM_ACCU] * 8);
}
NextTok ();
break;
case TOK_BLANK:
N = Function (FuncBlank);
break;
@@ -1132,6 +1141,15 @@ static ExprNode* Factor (void)
N = Function (FuncIsMnemonic);
break;
case TOK_ISIZE:
if (GetCPU() != CPU_65816) {
N = GenLiteralExpr (8);
} else {
N = GenLiteralExpr (ExtBytes [AM65I_IMM_INDEX] * 8);
}
NextTok ();
break;
case TOK_LOBYTE:
N = Function (FuncLoByte);
break;

View File

@@ -1967,6 +1967,7 @@ static CtrlDesc CtrlCmdTab [] = {
{ ccNone, DoUnexpected }, /* .ADDRSIZE */
{ ccNone, DoAlign },
{ ccNone, DoASCIIZ },
{ ccNone, DoUnexpected }, /* .ASIZE */
{ ccNone, DoAssert },
{ ccNone, DoAutoImport },
{ ccNone, DoUnexpected }, /* .BANK */
@@ -2041,6 +2042,7 @@ static CtrlDesc CtrlCmdTab [] = {
{ ccNone, DoIncBin },
{ ccNone, DoInclude },
{ ccNone, DoInterruptor },
{ ccNone, DoUnexpected }, /* .ISIZE */
{ ccNone, DoUnexpected }, /* .ISMNEMONIC */
{ ccNone, DoInvalid }, /* .LEFT */
{ ccNone, DoLineCont },

View File

@@ -139,6 +139,7 @@ struct DotKeyword {
{ ".ALIGN", TOK_ALIGN },
{ ".AND", TOK_BOOLAND },
{ ".ASCIIZ", TOK_ASCIIZ },
{ ".ASIZE", TOK_ASIZE },
{ ".ASSERT", TOK_ASSERT },
{ ".AUTOIMPORT", TOK_AUTOIMPORT },
{ ".BANK", TOK_BANK },
@@ -224,6 +225,7 @@ struct DotKeyword {
{ ".INCBIN", TOK_INCBIN },
{ ".INCLUDE", TOK_INCLUDE },
{ ".INTERRUPTOR", TOK_INTERRUPTOR },
{ ".ISIZE", TOK_ISIZE },
{ ".ISMNEM", TOK_ISMNEMONIC },
{ ".ISMNEMONIC", TOK_ISMNEMONIC },
{ ".LEFT", TOK_LEFT },

View File

@@ -126,6 +126,7 @@ typedef enum token_t {
TOK_ADDRSIZE,
TOK_ALIGN,
TOK_ASCIIZ,
TOK_ASIZE,
TOK_ASSERT,
TOK_AUTOIMPORT,
TOK_BANK,
@@ -200,6 +201,7 @@ typedef enum token_t {
TOK_INCBIN,
TOK_INCLUDE,
TOK_INTERRUPTOR,
TOK_ISIZE,
TOK_ISMNEMONIC,
TOK_LEFT,
TOK_LINECONT,