#include "reg8051.h"
#include "cpu8051.h"
#include "memory.h"
+#include "psw.h"
#include "disasm.h"
+#include "options.h"
#include "instructions_8051.h"
+extern struct options_t options;
+
/* Check if the address is a breakpoint */
int
IsBreakpoint(unsigned int address)
return 0;
}
+/* Check if the address is a stop point */
+int
+IsStoppoint(unsigned int address)
+{
+ if ((options.stop_address != 0) && (options.stop_address == address))
+ return 1;
+ else
+ return 0;
+}
+
/* Show Breakpoints list */
void
ShowBreakpoints(void)
uint8_t GATE, uint32_t TimerCounter)
{
unsigned int tmp;
+ unsigned int prescaler;
switch (mode) {
case 0:
- /* Mode 0, 13-bits counter. */
- tmp = cpu8051_ReadD(th) * 0x100 + cpu8051_ReadD(tl);
- tmp++;
- tmp &= 0x1FFF; /* We keep only 13 bits */
-
- if (tmp == 0) /* If overflow set TF0 */
- cpu8051_WriteD(_TCON_, cpu8051_ReadD(_TCON_) | tf_mask);
- cpu8051_WriteD(_TH0_, tmp / 0x100);
- cpu8051_WriteD(_TL0_, tmp & 0xFF);
+ /* Mode 0, 8-bit timer "TH" with "TL" as 5-bit prescaler. */
+ prescaler = cpu8051_ReadD(tl);
+ prescaler++;
+ prescaler &= 0x1F; /* We keep only 5 bits */
+ cpu8051_WriteD(tl, prescaler);
+
+ if (prescaler == 0) {
+ /* If overflow, increment TH */
+ tmp = cpu8051_ReadD(th);
+ tmp++;
+ tmp &= 0xFF; /* We keep only 8 bits */
+
+ if (tmp == 0) /* If overflow set TF */
+ cpu8051_WriteD(_TCON_, cpu8051_ReadD(_TCON_) | tf_mask);
+
+ cpu8051_WriteD(th, tmp);
+ }
break;
case 1:
/* Mode 1, 16-bits counter */
tmp &= 0xFFFF; /* We keep only 16 bits */
if (tmp == 0) /* If overflow set TF0 */
cpu8051_WriteD(_TCON_, cpu8051_ReadD(_TCON_) | tf_mask);
- cpu8051_WriteD(_TH0_, (tmp / 0x100));
- cpu8051_WriteD(_TL0_, (tmp & 0xFF));
+ cpu8051_WriteD(th, (tmp / 0x100));
+ cpu8051_WriteD(tl, (tmp & 0xFF));
break;
case 2:
/* Mode 2, 8-bits counter with Auto-Reload */
cpu8051.pc++;
insttiming = (*opcode_table[opcode])(); /* Function callback. */
+ /*
+ * Parity bit (p): is automatically set or cleared in each machine
+ * cycle to establish even parity in the accumulator.
+ */
+ psw_compute_parity_bit();
+
for (i = 0; i < insttiming; i++) {
cpu8051_CheckInterrupts();
cpu8051_DoTimers();
return InstSizesTbl[opcode];
}
-/* Display instruction menmonic. */
+/* Display instruction mnemonic. */
void
cpu8051_disasm_mnemonic(unsigned char OpCode, char *buf)
{
for (; len < 17;)
len += sprintf(&Text[len], " ");
- /* Display instruction menmonic. */
+ /* Display instruction mnemonic. */
len += sprintf(&Text[len], "%s ",
InstTextTbl[InstTypesTbl[OpCode]]);
ArgTblOfs = OpCode << 2;