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:
@@ -44,6 +44,7 @@
|
||||
#include "bitops.h"
|
||||
#include "cddefs.h"
|
||||
#include "coll.h"
|
||||
#include "intstack.h"
|
||||
#include "symdefs.h"
|
||||
#include "tgttrans.h"
|
||||
#include "xmalloc.h"
|
||||
@@ -86,6 +87,9 @@
|
||||
/* Keyword we're about to handle */
|
||||
static StrBuf Keyword = STATIC_STRBUF_INITIALIZER;
|
||||
|
||||
/* CPU stack */
|
||||
static IntStack CPUStack = STATIC_INTSTACK_INITIALIZER;
|
||||
|
||||
/* Segment stack */
|
||||
#define MAX_PUSHED_SEGMENTS 16
|
||||
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)
|
||||
/* 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)
|
||||
/* Push the current segment onto the segment stack */
|
||||
{
|
||||
@@ -1865,7 +1899,7 @@ static CtrlDesc CtrlCmdTab [] = {
|
||||
{ ccNone, DoUnexpected }, /* .MAX */
|
||||
{ ccNone, DoInvalid }, /* .MID */
|
||||
{ ccNone, DoUnexpected }, /* .MIN */
|
||||
{ ccNone, DoNull },
|
||||
{ ccNone, DoNull },
|
||||
{ ccNone, DoOrg },
|
||||
{ ccNone, DoOut },
|
||||
{ ccNone, DoP02 },
|
||||
@@ -1873,9 +1907,11 @@ static CtrlDesc CtrlCmdTab [] = {
|
||||
{ ccNone, DoPageLength },
|
||||
{ ccNone, DoUnexpected }, /* .PARAMCOUNT */
|
||||
{ ccNone, DoPC02 },
|
||||
{ ccNone, DoPopCPU },
|
||||
{ ccNone, DoPopSeg },
|
||||
{ ccNone, DoProc },
|
||||
{ ccNone, DoPSC02 },
|
||||
{ ccNone, DoPushCPU },
|
||||
{ ccNone, DoPushSeg },
|
||||
{ ccNone, DoUnexpected }, /* .REFERENCED */
|
||||
{ ccNone, DoReloc },
|
||||
@@ -1944,11 +1980,14 @@ void HandlePseudo (void)
|
||||
|
||||
|
||||
|
||||
void SegStackCheck (void)
|
||||
/* Check if the segment stack is empty at end of assembly */
|
||||
void CheckPseudo (void)
|
||||
/* Check if the stacks are empty at end of assembly */
|
||||
{
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user