Use register variables

git-svn-id: svn://svn.cc65.org/cc65/trunk@1646 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz
2002-11-25 17:19:49 +00:00
parent ea06b7286e
commit fbe913e1db

View File

@@ -305,7 +305,7 @@ BreakPoint* DbgIsBreak (unsigned Addr);
static void DrawFrame (FrameDesc* F, char Active) static void DrawFrame (register FrameDesc* F, char Active)
/* Draw one window frame */ /* Draw one window frame */
{ {
TextDesc* T; TextDesc* T;
@@ -386,7 +386,7 @@ static void ActivateFrame (int Num, unsigned char Clear)
/* Activate a new frame, deactivate the old one */ /* Activate a new frame, deactivate the old one */
{ {
unsigned char y; unsigned char y;
FrameDesc* F; register FrameDesc* F;
if (ActiveFrame != Num) { if (ActiveFrame != Num) {
@@ -400,9 +400,9 @@ static void ActivateFrame (int Num, unsigned char Clear)
F = Frames [ActiveFrame]; F = Frames [ActiveFrame];
/* Clear the frame if requested */ /* Clear the frame if requested */
if (Clear) { if (Clear) {
for (y = F->fd_y1+1; y < F->fd_y2; ++y) { for (y = F->fd_y1+1; y < F->fd_y2; ++y) {
cclearxy (F->fd_x1+1, y, F->fd_width); cclearxy (F->fd_x1+1, y, F->fd_width);
} }
} }
DrawFrame (F, 1); DrawFrame (F, 1);
} }
@@ -416,7 +416,7 @@ static void ActivateFrame (int Num, unsigned char Clear)
/*****************************************************************************/ /*****************************************************************************/
/* Prompt line */ /* Prompt line */
/*****************************************************************************/ /*****************************************************************************/
@@ -621,7 +621,7 @@ static void DbgSetTmpBreak (unsigned Addr)
static void DbgToggleUserBreak (unsigned Addr) static void DbgToggleUserBreak (unsigned Addr)
/* Set a breakpoint */ /* Set a breakpoint */
{ {
BreakPoint* B = DbgIsBreak (Addr); register BreakPoint* B = DbgIsBreak (Addr);
if (B) { if (B) {
/* We have a breakpoint, remove it */ /* We have a breakpoint, remove it */
@@ -634,13 +634,13 @@ static void DbgToggleUserBreak (unsigned Addr)
} else { } else {
/* Test if we can set a breakpoint at that address */ /* Test if we can set a breakpoint at that address */
if (!DbgIsRAM (Addr)) { if (!DbgIsRAM (Addr)) {
BreakInRomError (); BreakInRomError ();
} else { } else {
/* Set the breakpoint */ /* Set the breakpoint */
B = DbgGetBreakSlot (); B = DbgGetBreakSlot ();
B->bk_addr = Addr; B->bk_addr = Addr;
B->bk_use = BRK_USER; B->bk_use = BRK_USER;
++DbgBreakCount; ++DbgBreakCount;
} }
} }
} }
@@ -658,7 +658,7 @@ static void DbgResetTmpBreaks (void)
if (B->bk_use == BRK_TMP) { if (B->bk_use == BRK_TMP) {
B->bk_use = BRK_EMPTY; B->bk_use = BRK_EMPTY;
} }
++B; ++B;
} }
} }
@@ -673,11 +673,11 @@ static unsigned char DbgTmpBreaksOk (void)
BreakPoint* B = DbgBreaks; BreakPoint* B = DbgBreaks;
for (i = 0; i < MAX_USERBREAKS; ++i) { for (i = 0; i < MAX_USERBREAKS; ++i) {
if (B->bk_use == BRK_TMP && !DbgIsRAM (B->bk_addr)) { if (B->bk_use == BRK_TMP && !DbgIsRAM (B->bk_addr)) {
BreakInRomError (); BreakInRomError ();
DbgResetTmpBreaks (); DbgResetTmpBreaks ();
return 0; return 0;
} }
++B; ++B;
} }
return 1; return 1;
} }
@@ -685,7 +685,7 @@ static unsigned char DbgTmpBreaksOk (void)
/*****************************************************************************/ /*****************************************************************************/
/* Assembler window stuff */ /* Assembler window stuff */
/*****************************************************************************/ /*****************************************************************************/
@@ -708,17 +708,17 @@ static unsigned AsmBack (unsigned mem, unsigned char lines)
adr [in] = cur; adr [in] = cur;
in = (in + 1) & 0x1F; in = (in + 1) & 0x1F;
if (cur >= mem) { if (cur >= mem) {
if (cur == mem || offs == 12) { if (cur == mem || offs == 12) {
/* Found */ /* Found */
return adr [(in - lines - 1) & 0x1F]; return adr [(in - lines - 1) & 0x1F];
} else { } else {
/* The requested address is inside an instruction, go back /* The requested address is inside an instruction, go back
* one more byte and try again. * one more byte and try again.
*/ */
++offs; ++offs;
break; break;
} }
} }
} }
} }
} }
@@ -736,22 +736,22 @@ static unsigned UpdateAsm (void)
unsigned m = AsmBack (AsmAddr, 2); unsigned m = AsmBack (AsmAddr, 2);
for (y = AsmFrame.fd_y1+1; y < AsmFrame.fd_y2; ++y) { for (y = AsmFrame.fd_y1+1; y < AsmFrame.fd_y2; ++y) {
len = DbgDisAsm (m, buf, width); len = DbgDisAsm (m, buf, width);
if (m == brk_pc) { if (m == brk_pc) {
buf [4] = '-'; buf [4] = '-';
buf [5] = '>'; buf [5] = '>';
} }
if (DbgIsBreak (m)) { if (DbgIsBreak (m)) {
buf [5] = '*'; buf [5] = '*';
} }
if (m == AsmAddr) { if (m == AsmAddr) {
revers (1); revers (1);
cputsxy (1, y, buf); cputsxy (1, y, buf);
revers (0); revers (0);
} else { } else {
cputsxy (1, y, buf); cputsxy (1, y, buf);
} }
m += len; m += len;
} }
return m; return m;
} }
@@ -771,33 +771,33 @@ static void AsmFollow (void)
{ {
switch (*(unsigned char*) AsmAddr) { switch (*(unsigned char*) AsmAddr) {
case OPC_JMP: case OPC_JMP:
case OPC_JSR: case OPC_JSR:
AsmAddr = AsmArg16 (); AsmAddr = AsmArg16 ();
break; break;
case OPC_JMPIND: case OPC_JMPIND:
AsmAddr = *(unsigned*)AsmArg16 (); AsmAddr = *(unsigned*)AsmArg16 ();
break; break;
case OPC_BPL: case OPC_BPL:
case OPC_BMI: case OPC_BMI:
case OPC_BVC: case OPC_BVC:
case OPC_BVS: case OPC_BVS:
case OPC_BCC: case OPC_BCC:
case OPC_BCS: case OPC_BCS:
case OPC_BNE: case OPC_BNE:
case OPC_BEQ: case OPC_BEQ:
AsmAddr = AsmAddr + 2 + *(signed char*)(AsmAddr+1); AsmAddr = AsmAddr + 2 + *(signed char*)(AsmAddr+1);
break; break;
case OPC_RTS: case OPC_RTS:
AsmAddr = (*(unsigned*) (DbgSP + 0x101) + 1); AsmAddr = (*(unsigned*) (DbgSP + 0x101) + 1);
break; break;
case OPC_RTI: case OPC_RTI:
AsmAddr = *(unsigned*) (DbgSP + 0x102); AsmAddr = *(unsigned*) (DbgSP + 0x102);
break; break;
} }
} }
@@ -832,23 +832,23 @@ static char AsmHandler (void)
/* Update the window contents */ /* Update the window contents */
Last = UpdateAsm (); Last = UpdateAsm ();
/* Read and handle input */ /* Read and handle input */
switch (c = GetKeyUpdate ()) { switch (c = GetKeyUpdate ()) {
case '+': case '+':
AsmAddr = Last; AsmAddr = Last;
break; break;
case '-': case '-':
AsmAddr = AsmBack (AsmAddr, AsmFrame.fd_height); AsmAddr = AsmBack (AsmAddr, AsmFrame.fd_height);
break; break;
case 't': case 't':
#ifdef CH_F2 #ifdef CH_F2
case CH_F2: case CH_F2:
#endif #endif
DbgToggleUserBreak (AsmAddr); DbgToggleUserBreak (AsmAddr);
break; break;
case 'f': case 'f':
AsmFollow (); AsmFollow ();
@@ -929,7 +929,7 @@ static char RegHandler (void)
/*****************************************************************************/ /*****************************************************************************/
/* Stack window stuff */ /* Stack window stuff */
/*****************************************************************************/ /*****************************************************************************/
@@ -943,10 +943,10 @@ static unsigned UpdateStack (void)
unsigned char y; unsigned char y;
for (y = StackFrame.fd_y2-1; y > StackFrame.fd_y1; --y) { for (y = StackFrame.fd_y2-1; y > StackFrame.fd_y1; --y) {
gotoxy (x1, y); gotoxy (x1, y);
cputhex8 (mem); cputhex8 (mem);
gotoxy (x2, y); gotoxy (x2, y);
cputhex8 (* (unsigned char*) (mem + 0x100)); cputhex8 (* (unsigned char*) (mem + 0x100));
++mem; ++mem;
} }
return mem; return mem;
@@ -979,35 +979,35 @@ static char StackHandler (void)
while (1) { while (1) {
/* Read and handle input */ /* Read and handle input */
switch (c = GetKeyUpdate ()) { switch (c = GetKeyUpdate ()) {
case '+': case '+':
StackAddr += BytesPerPage; StackAddr += BytesPerPage;
break; break;
case '-': case '-':
StackAddr -= BytesPerPage; StackAddr -= BytesPerPage;
break; break;
case 'o': case 'o':
StackHome (); StackHome ();
break; break;
case CH_CURS_UP: case CH_CURS_UP:
--StackAddr; --StackAddr;
break; break;
case CH_CURS_DOWN: case CH_CURS_DOWN:
++StackAddr; ++StackAddr;
break; break;
default: default:
return c; return c;
} }
/* Update the window contents */ /* Update the window contents */
UpdateStack (); UpdateStack ();
} }
} }
@@ -1028,9 +1028,9 @@ static unsigned UpdateCStack (void)
unsigned char y; unsigned char y;
for (y = CStackFrame.fd_y2-1; y > CStackFrame.fd_y1; --y) { for (y = CStackFrame.fd_y2-1; y > CStackFrame.fd_y1; --y) {
gotoxy (x, y); gotoxy (x, y);
cputhex16 (* (unsigned*)mem); cputhex16 (* (unsigned*)mem);
mem += 2; mem += 2;
} }
cputsxy (CStackFrame.fd_x1+1, CStackFrame.fd_y2-1, "->"); cputsxy (CStackFrame.fd_x1+1, CStackFrame.fd_y2-1, "->");
return mem; return mem;
@@ -1063,35 +1063,35 @@ static char CStackHandler (void)
while (1) { while (1) {
/* Read and handle input */ /* Read and handle input */
switch (c = GetKeyUpdate ()) { switch (c = GetKeyUpdate ()) {
case '+': case '+':
CStackAddr += BytesPerPage; CStackAddr += BytesPerPage;
break; break;
case '-': case '-':
CStackAddr -= BytesPerPage; CStackAddr -= BytesPerPage;
break; break;
case 'o': case 'o':
CStackHome (); CStackHome ();
break; break;
case CH_CURS_UP: case CH_CURS_UP:
CStackAddr -= 2; CStackAddr -= 2;
break; break;
case CH_CURS_DOWN: case CH_CURS_DOWN:
CStackAddr += 2; CStackAddr += 2;
break; break;
default: default:
return c; return c;
} }
/* Update the window contents */ /* Update the window contents */
UpdateCStack (); UpdateCStack ();
} }
} }
@@ -1099,7 +1099,7 @@ static char CStackHandler (void)
/*****************************************************************************/ /*****************************************************************************/
/* Dump window stuff */ /* Dump window stuff */
/*****************************************************************************/ /*****************************************************************************/
@@ -1114,8 +1114,8 @@ static unsigned UpdateDump (void)
unsigned char* p = (unsigned char*) mem; unsigned char* p = (unsigned char*) mem;
for (y = DumpFrame.fd_y1+1; y < DumpFrame.fd_y2; ++y) { for (y = DumpFrame.fd_y1+1; y < DumpFrame.fd_y2; ++y) {
cputsxy (x, y, DbgMemDump (mem, Buf, DUMP_BYTES)); cputsxy (x, y, DbgMemDump (mem, Buf, DUMP_BYTES));
mem += DUMP_BYTES; mem += DUMP_BYTES;
} }
return mem; return mem;
} }
@@ -1138,37 +1138,37 @@ static char DumpHandler (void)
while (1) { while (1) {
/* Read and handle input */ /* Read and handle input */
switch (c = GetKeyUpdate ()) { switch (c = GetKeyUpdate ()) {
case '+': case '+':
DumpAddr += BytesPerPage; DumpAddr += BytesPerPage;
break; break;
case '-': case '-':
DumpAddr -= BytesPerPage; DumpAddr -= BytesPerPage;
break; break;
case 'g': case 'g':
InputGoto (&DumpAddr); InputGoto (&DumpAddr);
break; break;
case 'o': case 'o':
DumpHome (); DumpHome ();
break; break;
case CH_CURS_UP: case CH_CURS_UP:
DumpAddr -= 8; DumpAddr -= 8;
break; break;
case CH_CURS_DOWN: case CH_CURS_DOWN:
DumpAddr += 8; DumpAddr += 8;
break; break;
default: default:
return c; return c;
} }
/* Update the window contents */ /* Update the window contents */
UpdateDump (); UpdateDump ();
@@ -1178,7 +1178,7 @@ static char DumpHandler (void)
/*****************************************************************************/ /*****************************************************************************/
/* Help window stuff */ /* Help window stuff */
/*****************************************************************************/ /*****************************************************************************/
@@ -1206,7 +1206,7 @@ static char HelpHandler (void)
/*****************************************************************************/ /*****************************************************************************/
/* Singlestep */ /* Singlestep */
/*****************************************************************************/ /*****************************************************************************/
@@ -1242,49 +1242,49 @@ static void SingleStep (char StepInto)
switch (*(unsigned char*) brk_pc) { switch (*(unsigned char*) brk_pc) {
case OPC_JMP: case OPC_JMP:
/* Set breakpoint at target */ /* Set breakpoint at target */
DbgSetTmpBreak (GetArg16 ()); DbgSetTmpBreak (GetArg16 ());
return; return;
case OPC_JMPIND: case OPC_JMPIND:
/* Indirect jump, ignore CPU error when crossing page */ /* Indirect jump, ignore CPU error when crossing page */
DbgSetTmpBreak (*(unsigned*)GetArg16 ()); DbgSetTmpBreak (*(unsigned*)GetArg16 ());
return; return;
case OPC_BPL: case OPC_BPL:
case OPC_BMI: case OPC_BMI:
case OPC_BVC: case OPC_BVC:
case OPC_BVS: case OPC_BVS:
case OPC_BCC: case OPC_BCC:
case OPC_BCS: case OPC_BCS:
case OPC_BNE: case OPC_BNE:
case OPC_BEQ: case OPC_BEQ:
/* Be sure not to set the breakpoint twice if this is a jump to /* Be sure not to set the breakpoint twice if this is a jump to
* the following instruction. * the following instruction.
*/ */
Offs = *(signed char*)(brk_pc+1); Offs = *(signed char*)(brk_pc+1);
if (Offs) { if (Offs) {
DbgSetTmpBreak (brk_pc + Offs + 2); DbgSetTmpBreak (brk_pc + Offs + 2);
} }
break; break;
case OPC_RTS: case OPC_RTS:
/* Set a breakpoint at the return target */ /* Set a breakpoint at the return target */
SetRTSBreak (); SetRTSBreak ();
return; return;
case OPC_RTI: case OPC_RTI:
/* Set a breakpoint at the return target */ /* Set a breakpoint at the return target */
DbgSetTmpBreak (GetStack16 (1)); DbgSetTmpBreak (GetStack16 (1));
return; return;
case OPC_JSR: case OPC_JSR:
if (StepInto) { if (StepInto) {
/* Set breakpoint at target */ /* Set breakpoint at target */
DbgSetTmpBreak (GetArg16 ()); DbgSetTmpBreak (GetArg16 ());
return; return;
} }
break; break;
} }
/* Place a breakpoint behind the instruction */ /* Place a breakpoint behind the instruction */
@@ -1294,7 +1294,7 @@ static void SingleStep (char StepInto)
/*****************************************************************************/ /*****************************************************************************/
/* High level window handling */ /* High level window handling */
/*****************************************************************************/ /*****************************************************************************/
@@ -1378,7 +1378,7 @@ static char GetKeyUpdate (void)
/*****************************************************************************/ /*****************************************************************************/
/* Externally visible functions */ /* Externally visible functions */
/*****************************************************************************/ /*****************************************************************************/
@@ -1392,15 +1392,15 @@ void DbgEntry (void)
/* If this is the first call, setup the display */ /* If this is the first call, setup the display */
if (FirstTime) { if (FirstTime) {
FirstTime = 0; FirstTime = 0;
/* Draw the window, default active frame is ASM frame */ /* Draw the window, default active frame is ASM frame */
RedrawStatic (WIN_ASM); RedrawStatic (WIN_ASM);
InitAsm (); InitAsm ();
InitReg (); InitReg ();
InitStack (); InitStack ();
InitCStack (); InitCStack ();
UpdateDump (); UpdateDump ();
} }
/* Only initialize variables here, don't do a display update. The actual /* Only initialize variables here, don't do a display update. The actual
@@ -1415,24 +1415,24 @@ void DbgEntry (void)
done = 0; done = 0;
while (!done) { while (!done) {
c = Frames [ActiveFrame]->fd_func (); c = Frames [ActiveFrame]->fd_func ();
switch (c) { switch (c) {
case '1': case '1':
case '2': case '2':
case '3': case '3':
case '4': case '4':
case '5': case '5':
ActivateFrame (c - '1', 0); ActivateFrame (c - '1', 0);
break; break;
case '?': case '?':
#ifdef CH_F1 #ifdef CH_F1
case CH_F1: case CH_F1:
#endif #endif
HelpHandler (); HelpHandler ();
break; break;
case 'u': case 'u':
#ifdef CH_F3 #ifdef CH_F3
case CH_F3: case CH_F3:
#endif #endif
@@ -1441,7 +1441,7 @@ void DbgEntry (void)
done = 1; done = 1;
break; break;
case 'h': case 'h':
#ifdef CH_F4 #ifdef CH_F4
case CH_F4: case CH_F4:
#endif #endif
@@ -1463,7 +1463,7 @@ void DbgEntry (void)
} }
break; break;
case '\n': case '\n':
#ifdef CH_F8 #ifdef CH_F8
case CH_F8: case CH_F8:
#endif #endif
@@ -1500,3 +1500,4 @@ void DbgEntry (void)
} }