Implemented new .PUSHCPU and .POPCPU commands.
git-svn-id: svn://svn.cc65.org/cc65/trunk@4644 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
@@ -3125,6 +3125,21 @@ Here's a list of all control commands and a description, what they do:
|
|||||||
name=".PSC02"></tt> and <tt><ref id=".P816" name=".P816"></tt>
|
name=".PSC02"></tt> and <tt><ref id=".P816" name=".P816"></tt>
|
||||||
|
|
||||||
|
|
||||||
|
<sect1><tt>.POPCPU</tt><label id=".POPCPU"><p>
|
||||||
|
|
||||||
|
Pop the last CPU setting from the stack, and activate it.
|
||||||
|
|
||||||
|
This command will switch back to the CPU that was last pushed onto the CPU
|
||||||
|
stack using the <tt><ref id=".PUSHCPU" name=".PUSHCPU"></tt> command, and
|
||||||
|
remove this entry from the stack.
|
||||||
|
|
||||||
|
The assembler will print an error message if the CPU stack is empty when
|
||||||
|
this command is issued.
|
||||||
|
|
||||||
|
See: <tt><ref id=".CPU" name=".CPU"></tt>, <tt><ref id=".PUSHCPU"
|
||||||
|
name=".PUSHCPU"></tt>, <tt><ref id=".SETCPU" name=".SETCPU"></tt>
|
||||||
|
|
||||||
|
|
||||||
<sect1><tt>.POPSEG</tt><label id=".POPSEG"><p>
|
<sect1><tt>.POPSEG</tt><label id=".POPSEG"><p>
|
||||||
|
|
||||||
Pop the last pushed segment from the stack, and set it.
|
Pop the last pushed segment from the stack, and set it.
|
||||||
@@ -3183,6 +3198,22 @@ Here's a list of all control commands and a description, what they do:
|
|||||||
name=".PC02"></tt> and <tt><ref id=".P816" name=".P816"></tt>
|
name=".PC02"></tt> and <tt><ref id=".P816" name=".P816"></tt>
|
||||||
|
|
||||||
|
|
||||||
|
<sect1><tt>.PUSHCPU</tt><label id=".PUSHCPU"><p>
|
||||||
|
|
||||||
|
Push the currently active CPU onto a stack. The stack has a size of 8
|
||||||
|
entries.
|
||||||
|
|
||||||
|
<tt/.PUSHCPU/ allows together with <tt><ref id=".POPCPU"
|
||||||
|
name=".POPCPU"></tt> to switch to another CPU and to restore the old CPU
|
||||||
|
later, without knowledge of the current CPU setting.
|
||||||
|
|
||||||
|
The assembler will print an error message if the CPU stack is already full,
|
||||||
|
when this command is issued.
|
||||||
|
|
||||||
|
See: <tt><ref id=".CPU" name=".CPU"></tt>, <tt><ref id=".POPCPU"
|
||||||
|
name=".POPCPU"></tt>, <tt><ref id=".SETCPU" name=".SETCPU"></tt>
|
||||||
|
|
||||||
|
|
||||||
<sect1><tt>.PUSHSEG</tt><label id=".PUSHSEG"><p>
|
<sect1><tt>.PUSHSEG</tt><label id=".PUSHSEG"><p>
|
||||||
|
|
||||||
Push the currently active segment onto a stack. The entries on the stack
|
Push the currently active segment onto a stack. The entries on the stack
|
||||||
|
|||||||
@@ -956,9 +956,9 @@ int main (int argc, char* argv [])
|
|||||||
/* Assemble the input */
|
/* Assemble the input */
|
||||||
Assemble ();
|
Assemble ();
|
||||||
|
|
||||||
/* If we didn't have any errors, check the segment stack */
|
/* If we didn't have any errors, check the pseudo insn stacks */
|
||||||
if (ErrorCount == 0) {
|
if (ErrorCount == 0) {
|
||||||
SegStackCheck ();
|
CheckPseudo ();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we didn't have any errors, check the unnamed labels */
|
/* If we didn't have any errors, check the unnamed labels */
|
||||||
|
|||||||
@@ -44,6 +44,7 @@
|
|||||||
#include "bitops.h"
|
#include "bitops.h"
|
||||||
#include "cddefs.h"
|
#include "cddefs.h"
|
||||||
#include "coll.h"
|
#include "coll.h"
|
||||||
|
#include "intstack.h"
|
||||||
#include "symdefs.h"
|
#include "symdefs.h"
|
||||||
#include "tgttrans.h"
|
#include "tgttrans.h"
|
||||||
#include "xmalloc.h"
|
#include "xmalloc.h"
|
||||||
@@ -86,6 +87,9 @@
|
|||||||
/* Keyword we're about to handle */
|
/* Keyword we're about to handle */
|
||||||
static StrBuf Keyword = STATIC_STRBUF_INITIALIZER;
|
static StrBuf Keyword = STATIC_STRBUF_INITIALIZER;
|
||||||
|
|
||||||
|
/* CPU stack */
|
||||||
|
static IntStack CPUStack = STATIC_INTSTACK_INITIALIZER;
|
||||||
|
|
||||||
/* Segment stack */
|
/* Segment stack */
|
||||||
#define MAX_PUSHED_SEGMENTS 16
|
#define MAX_PUSHED_SEGMENTS 16
|
||||||
static Collection SegStack = STATIC_COLLECTION_INITIALIZER;
|
static Collection SegStack = STATIC_COLLECTION_INITIALIZER;
|
||||||
@@ -1412,6 +1416,21 @@ static void DoPageLength (void)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void DoPopCPU (void)
|
||||||
|
/* Pop an old CPU setting from the CPU stack */
|
||||||
|
{
|
||||||
|
/* Must have a CPU on the stack */
|
||||||
|
if (IS_IsEmpty (&CPUStack)) {
|
||||||
|
ErrorSkip ("CPU stack is empty");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set the CPU to the value popped from stack */
|
||||||
|
SetCPU (IS_Pop (&CPUStack));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void DoPopSeg (void)
|
static void DoPopSeg (void)
|
||||||
/* Pop an old segment from the segment stack */
|
/* Pop an old segment from the segment stack */
|
||||||
{
|
{
|
||||||
@@ -1486,6 +1505,21 @@ static void DoPSC02 (void)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void DoPushCPU (void)
|
||||||
|
/* Push the current CPU setting onto the CPU stack */
|
||||||
|
{
|
||||||
|
/* Can only push a limited size of segments */
|
||||||
|
if (IS_IsFull (&CPUStack)) {
|
||||||
|
ErrorSkip ("CPU stack overflow");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get the current segment and push it */
|
||||||
|
IS_Push (&CPUStack, GetCPU ());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void DoPushSeg (void)
|
static void DoPushSeg (void)
|
||||||
/* Push the current segment onto the segment stack */
|
/* Push the current segment onto the segment stack */
|
||||||
{
|
{
|
||||||
@@ -1865,7 +1899,7 @@ static CtrlDesc CtrlCmdTab [] = {
|
|||||||
{ ccNone, DoUnexpected }, /* .MAX */
|
{ ccNone, DoUnexpected }, /* .MAX */
|
||||||
{ ccNone, DoInvalid }, /* .MID */
|
{ ccNone, DoInvalid }, /* .MID */
|
||||||
{ ccNone, DoUnexpected }, /* .MIN */
|
{ ccNone, DoUnexpected }, /* .MIN */
|
||||||
{ ccNone, DoNull },
|
{ ccNone, DoNull },
|
||||||
{ ccNone, DoOrg },
|
{ ccNone, DoOrg },
|
||||||
{ ccNone, DoOut },
|
{ ccNone, DoOut },
|
||||||
{ ccNone, DoP02 },
|
{ ccNone, DoP02 },
|
||||||
@@ -1873,9 +1907,11 @@ static CtrlDesc CtrlCmdTab [] = {
|
|||||||
{ ccNone, DoPageLength },
|
{ ccNone, DoPageLength },
|
||||||
{ ccNone, DoUnexpected }, /* .PARAMCOUNT */
|
{ ccNone, DoUnexpected }, /* .PARAMCOUNT */
|
||||||
{ ccNone, DoPC02 },
|
{ ccNone, DoPC02 },
|
||||||
|
{ ccNone, DoPopCPU },
|
||||||
{ ccNone, DoPopSeg },
|
{ ccNone, DoPopSeg },
|
||||||
{ ccNone, DoProc },
|
{ ccNone, DoProc },
|
||||||
{ ccNone, DoPSC02 },
|
{ ccNone, DoPSC02 },
|
||||||
|
{ ccNone, DoPushCPU },
|
||||||
{ ccNone, DoPushSeg },
|
{ ccNone, DoPushSeg },
|
||||||
{ ccNone, DoUnexpected }, /* .REFERENCED */
|
{ ccNone, DoUnexpected }, /* .REFERENCED */
|
||||||
{ ccNone, DoReloc },
|
{ ccNone, DoReloc },
|
||||||
@@ -1944,11 +1980,14 @@ void HandlePseudo (void)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void SegStackCheck (void)
|
void CheckPseudo (void)
|
||||||
/* Check if the segment stack is empty at end of assembly */
|
/* Check if the stacks are empty at end of assembly */
|
||||||
{
|
{
|
||||||
if (CollCount (&SegStack) != 0) {
|
if (CollCount (&SegStack) != 0) {
|
||||||
Error ("Segment stack is not empty");
|
Warning (1, "Segment stack is not empty");
|
||||||
|
}
|
||||||
|
if (!IS_IsEmpty (&CPUStack)) {
|
||||||
|
Warning (1, "CPU stack is not empty");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* */
|
/* */
|
||||||
/* pseudo.h */
|
/* pseudo.h */
|
||||||
/* */
|
/* */
|
||||||
/* Pseudo instructions for the ca65 macroassembler */
|
/* Pseudo instructions for the ca65 macroassembler */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 1998-2008 Ullrich von Bassewitz */
|
/* (C) 1998-2010, Ullrich von Bassewitz */
|
||||||
/* Roemerstrasse 52 */
|
/* Roemerstrasse 52 */
|
||||||
/* D-70794 Filderstadt */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@cc65.org */
|
/* EMail: uz@cc65.org */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* This software is provided 'as-is', without any expressed or implied */
|
/* This software is provided 'as-is', without any expressed or implied */
|
||||||
@@ -61,8 +61,8 @@ extern unsigned OpenIfs;
|
|||||||
void HandlePseudo (void);
|
void HandlePseudo (void);
|
||||||
/* Handle a pseudo instruction */
|
/* Handle a pseudo instruction */
|
||||||
|
|
||||||
void SegStackCheck (void);
|
void CheckPseudo (void);
|
||||||
/* Check if the segment stack is empty at end of assembly */
|
/* Check if the stacks are empty at end of assembly */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -251,9 +251,11 @@ struct DotKeyword {
|
|||||||
{ ".PAGELENGTH", TOK_PAGELENGTH },
|
{ ".PAGELENGTH", TOK_PAGELENGTH },
|
||||||
{ ".PARAMCOUNT", TOK_PARAMCOUNT },
|
{ ".PARAMCOUNT", TOK_PARAMCOUNT },
|
||||||
{ ".PC02", TOK_PC02 },
|
{ ".PC02", TOK_PC02 },
|
||||||
|
{ ".POPCPU", TOK_POPCPU },
|
||||||
{ ".POPSEG", TOK_POPSEG },
|
{ ".POPSEG", TOK_POPSEG },
|
||||||
{ ".PROC", TOK_PROC },
|
{ ".PROC", TOK_PROC },
|
||||||
{ ".PSC02", TOK_PSC02 },
|
{ ".PSC02", TOK_PSC02 },
|
||||||
|
{ ".PUSHCPU", TOK_PUSHCPU },
|
||||||
{ ".PUSHSEG", TOK_PUSHSEG },
|
{ ".PUSHSEG", TOK_PUSHSEG },
|
||||||
{ ".REF", TOK_REFERENCED },
|
{ ".REF", TOK_REFERENCED },
|
||||||
{ ".REFERENCED", TOK_REFERENCED },
|
{ ".REFERENCED", TOK_REFERENCED },
|
||||||
@@ -345,7 +347,7 @@ static void DoneCharSource (void)
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* InputFile functions */
|
/* InputFile functions */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void IFMarkStart (CharSource* S)
|
static void IFMarkStart (CharSource* S)
|
||||||
|
|||||||
@@ -6,10 +6,10 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 2007 Ullrich von Bassewitz */
|
/* (C) 2007-2010, Ullrich von Bassewitz */
|
||||||
/* Roemerstrasse 52 */
|
/* Roemerstrasse 52 */
|
||||||
/* D-70794 Filderstadt */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@cc65.org */
|
/* EMail: uz@cc65.org */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* This software is provided 'as-is', without any expressed or implied */
|
/* This software is provided 'as-is', without any expressed or implied */
|
||||||
@@ -217,9 +217,11 @@ typedef enum Token {
|
|||||||
TOK_PAGELENGTH,
|
TOK_PAGELENGTH,
|
||||||
TOK_PARAMCOUNT,
|
TOK_PARAMCOUNT,
|
||||||
TOK_PC02,
|
TOK_PC02,
|
||||||
|
TOK_POPCPU,
|
||||||
TOK_POPSEG,
|
TOK_POPSEG,
|
||||||
TOK_PROC,
|
TOK_PROC,
|
||||||
TOK_PSC02,
|
TOK_PSC02,
|
||||||
|
TOK_PUSHCPU,
|
||||||
TOK_PUSHSEG,
|
TOK_PUSHSEG,
|
||||||
TOK_REFERENCED,
|
TOK_REFERENCED,
|
||||||
TOK_RELOC,
|
TOK_RELOC,
|
||||||
|
|||||||
Reference in New Issue
Block a user