mirror of
https://github.com/cc65/cc65.git
synced 2024-12-23 19:29:37 +00:00
Support for the .BANKBYTES, .LOBYTES and .HIBYTES pseudo functions contributed
by Kevin Schuetz <scrapdog@runbox.com>. git-svn-id: svn://svn.cc65.org/cc65/trunk@3965 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
37e08cac59
commit
8e8993de7e
@ -139,6 +139,7 @@ Thanks to
|
||||
Joerg Schwedes <joerg.schwedes@siemens.com>
|
||||
John Weidman <jweidman@slip.net>
|
||||
Jonathan Wright <jonathan.wright@adtran.com>
|
||||
Kevin Schuetz <scrapdog@runbox.com>
|
||||
Mark Nasgowitz <MNasgowitz@NAZdesign.com>
|
||||
Peter Karlsson <peter@softwolves.pp.se>
|
||||
Peter Wendrich <pwsoft@syntiac.com>
|
||||
|
109
doc/ca65.sgml
109
doc/ca65.sgml
@ -1767,6 +1767,34 @@ Here's a list of all control commands and a description, what they do:
|
||||
.autoimport + ; Switch on auto import
|
||||
</verb></tscreen>
|
||||
|
||||
<sect1><tt>.BANKBYTES</tt><label id=".BANKBYTES"><p>
|
||||
|
||||
Define byte sized data by extracting only the bank byte (that is, bits 16-23) from
|
||||
each expression. This is equivalent to <tt><ref id=".BYTE" name=".BYTE"></tt> with
|
||||
the operator '^' prepended to each expression in its list.
|
||||
|
||||
Example:
|
||||
|
||||
<tscreen><verb>
|
||||
.define MyTable TableItem0, TableItem1, TableItem2, TableItem3
|
||||
|
||||
TableLookupLo: .lobytes MyTable
|
||||
TableLookupHi: .hibytes MyTable
|
||||
TableLookupBank: .bankbytes MyTable
|
||||
</verb></tscreen>
|
||||
|
||||
which is equivalent to
|
||||
|
||||
<tscreen><verb>
|
||||
TableLookupLo: .byte <TableItem0, <TableItem1, <TableItem2, <TableItem3
|
||||
TableLookupHi: .byte >TableItem0, >TableItem1, >TableItem2, >TableItem3
|
||||
TableLookupBank: .byte ^TableItem0, ^TableItem1, ^TableItem2, ^TableItem3
|
||||
</verb></tscreen>
|
||||
|
||||
See also: <tt><ref id=".BYTE" name=".BYTE"></tt>,
|
||||
<tt><ref id=".HIBYTES" name=".HIBYTES"></tt>,
|
||||
<tt><ref id=".LOBYTES" name=".LOBYTES"></tt>
|
||||
|
||||
|
||||
<sect1><tt>.BSS</tt><label id=".BSS"><p>
|
||||
|
||||
@ -2424,6 +2452,46 @@ Here's a list of all control commands and a description, what they do:
|
||||
.globalzp foo, bar
|
||||
</verb></tscreen>
|
||||
|
||||
<sect1><tt>.HIBYTES</tt><label id=".HIBYTES"><p>
|
||||
|
||||
Define byte sized data by extracting only the high byte (that is, bits 8-15) from
|
||||
each expression. This is equivalent to <tt><ref id=".BYTE" name=".BYTE"></tt> with
|
||||
the operator '>' prepended to each expression in its list.
|
||||
|
||||
Example:
|
||||
|
||||
<tscreen><verb>
|
||||
.lobytes $1234, $2345, $3456, $4567
|
||||
.hibytes $fedc, $edcb, $dcba, $cba9
|
||||
</verb></tscreen>
|
||||
|
||||
which is equivalent to
|
||||
|
||||
<tscreen><verb>
|
||||
.byte $34, $45, $56, $67
|
||||
.byte $fe, $ed, $dc, $cb
|
||||
</verb></tscreen>
|
||||
|
||||
Example:
|
||||
|
||||
<tscreen><verb>
|
||||
.define MyTable TableItem0, TableItem1, TableItem2, TableItem3
|
||||
|
||||
TableLookupLo: .lobytes MyTable
|
||||
TableLookupHi: .hibytes MyTable
|
||||
</verb></tscreen>
|
||||
|
||||
which is equivalent to
|
||||
|
||||
<tscreen><verb>
|
||||
TableLookupLo: .byte <TableItem0, <TableItem1, <TableItem2, <TableItem3
|
||||
TableLookupHi: .byte >TableItem0, >TableItem1, >TableItem2, >TableItem3
|
||||
</verb></tscreen>
|
||||
|
||||
See also: <tt><ref id=".BYTE" name=".BYTE"></tt>,
|
||||
<tt><ref id=".LOBYTES" name=".LOBYTES"></tt>,
|
||||
<tt><ref id=".BANKBYTES" name=".BANKBYTES"></tt>
|
||||
|
||||
|
||||
<sect1><tt>.I16</tt><label id=".I16"><p>
|
||||
|
||||
@ -2745,6 +2813,47 @@ Here's a list of all control commands and a description, what they do:
|
||||
</verb></tscreen>
|
||||
|
||||
|
||||
<sect1><tt>.LOBYTES</tt><label id=".LOBYTES"><p>
|
||||
|
||||
Define byte sized data by extracting only the low byte (that is, bits 0-7) from
|
||||
each expression. This is equivalent to <tt><ref id=".BYTE" name=".BYTE"></tt> with
|
||||
the operator '<' prepended to each expression in its list.
|
||||
|
||||
Example:
|
||||
|
||||
<tscreen><verb>
|
||||
.lobytes $1234, $2345, $3456, $4567
|
||||
.hibytes $fedc, $edcb, $dcba, $cba9
|
||||
</verb></tscreen>
|
||||
|
||||
which is equivalent to
|
||||
|
||||
<tscreen><verb>
|
||||
.byte $34, $45, $56, $67
|
||||
.byte $fe, $ed, $dc, $cb
|
||||
</verb></tscreen>
|
||||
|
||||
Example:
|
||||
|
||||
<tscreen><verb>
|
||||
.define MyTable TableItem0, TableItem1, TableItem2, TableItem3
|
||||
|
||||
TableLookupLo: .lobytes MyTable
|
||||
TableLookupHi: .hibytes MyTable
|
||||
</verb></tscreen>
|
||||
|
||||
which is equivalent to
|
||||
|
||||
<tscreen><verb>
|
||||
TableLookupLo: .byte <TableItem0, <TableItem1, <TableItem2, <TableItem3
|
||||
TableLookupHi: .byte >TableItem0, >TableItem1, >TableItem2, >TableItem3
|
||||
</verb></tscreen>
|
||||
|
||||
See also: <tt><ref id=".BYTE" name=".BYTE"></tt>,
|
||||
<tt><ref id=".HIBYTES" name=".HIBYTES"></tt>,
|
||||
<tt><ref id=".BANKBYTES" name=".BANKBYTES"></tt>
|
||||
|
||||
|
||||
<sect1><tt>.LOCAL</tt><label id=".LOCAL"><p>
|
||||
|
||||
This command may only be used inside a macro definition. It declares a
|
||||
|
@ -319,7 +319,7 @@ static ExprNode* Symbol (SymEntry* S)
|
||||
|
||||
|
||||
|
||||
static ExprNode* FuncBankByte (void)
|
||||
ExprNode* FuncBankByte (void)
|
||||
/* Handle the .BANKBYTE builtin function */
|
||||
{
|
||||
return BankByte (Expression ());
|
||||
@ -393,7 +393,7 @@ static ExprNode* FuncDefined (void)
|
||||
|
||||
|
||||
|
||||
static ExprNode* FuncHiByte (void)
|
||||
ExprNode* FuncHiByte (void)
|
||||
/* Handle the .HIBYTE builtin function */
|
||||
{
|
||||
return HiByte (Expression ());
|
||||
@ -409,7 +409,7 @@ static ExprNode* FuncHiWord (void)
|
||||
|
||||
|
||||
|
||||
static ExprNode* FuncLoByte (void)
|
||||
ExprNode* FuncLoByte (void)
|
||||
/* Handle the .LOBYTE builtin function */
|
||||
{
|
||||
return LoByte (Expression ());
|
||||
|
@ -146,6 +146,14 @@ void ExprGuessedAddrSize (const ExprNode* Expr, unsigned char AddrSize);
|
||||
* and mark these symbols accordingly.
|
||||
*/
|
||||
|
||||
ExprNode* FuncBankByte (void);
|
||||
/* Handle the .BANKBYTE builtin function */
|
||||
|
||||
ExprNode* FuncLoByte (void);
|
||||
/* Handle the .LOBYTE builtin function */
|
||||
|
||||
ExprNode* FuncHiByte (void);
|
||||
/* Handle the .HIBYTE builtin function */
|
||||
|
||||
|
||||
/* End of expr.h */
|
||||
|
@ -482,6 +482,20 @@ static void DoAutoImport (void)
|
||||
}
|
||||
|
||||
|
||||
static void DoBankBytes (void)
|
||||
/* Define bytes, extracting the bank byte from each expression in the list */
|
||||
{
|
||||
while (1) {
|
||||
EmitByte (FuncBankByte ());
|
||||
if (Tok != TOK_COMMA) {
|
||||
break;
|
||||
} else {
|
||||
NextTok ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void DoBss (void)
|
||||
/* Switch to the BSS segment */
|
||||
@ -991,6 +1005,20 @@ static void DoGlobalZP (void)
|
||||
}
|
||||
|
||||
|
||||
static void DoHiBytes (void)
|
||||
/* Define bytes, extracting the hi byte from each expression in the list */
|
||||
{
|
||||
while (1) {
|
||||
EmitByte (FuncHiByte ());
|
||||
if (Tok != TOK_COMMA) {
|
||||
break;
|
||||
} else {
|
||||
NextTok ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void DoI16 (void)
|
||||
/* Switch the index registers to 16 bit mode (assembler only) */
|
||||
@ -1221,6 +1249,20 @@ static void DoList (void)
|
||||
|
||||
|
||||
|
||||
static void DoLoBytes (void)
|
||||
/* Define bytes, extracting the lo byte from each expression in the list */
|
||||
{
|
||||
while (1) {
|
||||
EmitByte (FuncLoByte ());
|
||||
if (Tok != TOK_COMMA) {
|
||||
break;
|
||||
} else {
|
||||
NextTok ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void DoListBytes (void)
|
||||
/* Set maximum number of bytes to list for one line */
|
||||
{
|
||||
@ -1725,6 +1767,7 @@ static CtrlDesc CtrlCmdTab [] = {
|
||||
{ ccNone, DoAssert },
|
||||
{ ccNone, DoAutoImport },
|
||||
{ ccNone, DoUnexpected }, /* .BANKBYTE */
|
||||
{ ccNone, DoBankBytes },
|
||||
{ ccNone, DoUnexpected }, /* .BLANK */
|
||||
{ ccNone, DoBss },
|
||||
{ ccNone, DoByte },
|
||||
@ -1768,6 +1811,7 @@ static CtrlDesc CtrlCmdTab [] = {
|
||||
{ ccNone, DoGlobal },
|
||||
{ ccNone, DoGlobalZP },
|
||||
{ ccNone, DoUnexpected }, /* .HIBYTE */
|
||||
{ ccNone, DoHiBytes },
|
||||
{ ccNone, DoUnexpected }, /* .HIWORD */
|
||||
{ ccNone, DoI16 },
|
||||
{ ccNone, DoI8 },
|
||||
@ -1795,6 +1839,7 @@ static CtrlDesc CtrlCmdTab [] = {
|
||||
{ ccNone, DoList },
|
||||
{ ccNone, DoListBytes },
|
||||
{ ccNone, DoUnexpected }, /* .LOBYTE */
|
||||
{ ccNone, DoLoBytes },
|
||||
{ ccNone, DoUnexpected }, /* .LOCAL */
|
||||
{ ccNone, DoLocalChar },
|
||||
{ ccNone, DoUnexpected }, /* .LOWORD */
|
||||
|
@ -146,6 +146,7 @@ struct DotKeyword {
|
||||
{ ".ASSERT", TOK_ASSERT },
|
||||
{ ".AUTOIMPORT", TOK_AUTOIMPORT },
|
||||
{ ".BANKBYTE", TOK_BANKBYTE },
|
||||
{ ".BANKBYTES", TOK_BANKBYTES },
|
||||
{ ".BITAND", TOK_AND },
|
||||
{ ".BITNOT", TOK_NOT },
|
||||
{ ".BITOR", TOK_OR },
|
||||
@ -199,6 +200,7 @@ struct DotKeyword {
|
||||
{ ".GLOBAL", TOK_GLOBAL },
|
||||
{ ".GLOBALZP", TOK_GLOBALZP },
|
||||
{ ".HIBYTE", TOK_HIBYTE },
|
||||
{ ".HIBYTES", TOK_HIBYTES },
|
||||
{ ".HIWORD", TOK_HIWORD },
|
||||
{ ".I16", TOK_I16 },
|
||||
{ ".I8", TOK_I8 },
|
||||
@ -226,6 +228,7 @@ struct DotKeyword {
|
||||
{ ".LIST", TOK_LIST },
|
||||
{ ".LISTBYTES", TOK_LISTBYTES },
|
||||
{ ".LOBYTE", TOK_LOBYTE },
|
||||
{ ".LOBYTES", TOK_LOBYTES },
|
||||
{ ".LOCAL", TOK_LOCAL },
|
||||
{ ".LOCALCHAR", TOK_LOCALCHAR },
|
||||
{ ".LOWORD", TOK_LOWORD },
|
||||
|
@ -127,6 +127,7 @@ typedef enum Token {
|
||||
TOK_ASSERT,
|
||||
TOK_AUTOIMPORT,
|
||||
TOK_BANKBYTE,
|
||||
TOK_BANKBYTES,
|
||||
TOK_BLANK,
|
||||
TOK_BSS,
|
||||
TOK_BYTE,
|
||||
@ -170,6 +171,7 @@ typedef enum Token {
|
||||
TOK_GLOBAL,
|
||||
TOK_GLOBALZP,
|
||||
TOK_HIBYTE,
|
||||
TOK_HIBYTES,
|
||||
TOK_HIWORD,
|
||||
TOK_I16,
|
||||
TOK_I8,
|
||||
@ -197,6 +199,7 @@ typedef enum Token {
|
||||
TOK_LIST,
|
||||
TOK_LISTBYTES,
|
||||
TOK_LOBYTE,
|
||||
TOK_LOBYTES,
|
||||
TOK_LOCAL,
|
||||
TOK_LOCALCHAR,
|
||||
TOK_LOWORD,
|
||||
|
Loading…
Reference in New Issue
Block a user