ctr

DeMon48_128k

Intel 8049 (8048, 8748, 8749, 8035, 8039) / MCS-48 Hardware-Debugger & Monitor

Online-Documentation - Chapter 7


7.0.0 Appendix

7.1.0 Instruction set of 8035,8039,8048,8049,8748,8749,8040,8050 µCs

MnemonicCyclesBytesFlags
ADD A,Rr11AC,CY
ADD A,@Ri11AC,CY
ADD A,#data22AC,CY
ADDC A,Rr11AC,CY
ADDC A,@Ri11AC,CY
ADDC A,#data22AC,CY
ANL A,Rr11-
ANL A,@Ri11-
ANL A,#data22-
ANL BUS,#data(*)22-
ANL Pp,#data22-
ANLD Pp,A21-
CALL address22SP
CLR A11-
CLR C11CY
CLR F011F0
CLR F111F1
CPL A11-
CPL C11CY
CPL F011F0
CPL F111F1
DA A11AC,CY
DEC A11-
DEC Rr11-
DIS I11-
DIS TCNTI11-
DJNZ Rr,address22-
EN I11-
EN TCNTI11-
ENT0 CLK11-
IN A,Pp21-
INC A11-
INC Rr11-
INC @Ri11-
INS A,BUS (*)21-
JBb address22-
JC address22-
JF0 address22-
JF1 address22-
JMP address22-
JMPP @A21-
JNC address22-
JNI address22-
JNT0 address22-
JNT1 address22-
JNZ address22-
JTF address22-
JT0 address22-
MnemonicCyclesBytesFlags
JT1 address22-
JZ address22-
MOV A,#data22-
MOV A,PSW11-
MOV A,Rr11-
MOV A,@Ri11-
MOV A,T11-
MOV PSW,A11-
MOV Rr,A11-
MOV Rr,#data22-
MOV @Ri,A11-
MOV @Ri,#data22-
MOV T,A11-
MOVD A,Pp21-
MOVD Pp,A21-
MOVP A,@A21-
MOVP3 A,@A21-
MOVX A,@Ri21-
MOVX @Ri,A21-
NOP11-
ORL A,Rr11-
ORL A,@Ri11-
ORL A,#data22-
ORL BUS,#data (*)22-
ORL Pp,#data22-
ORLD Pp,A21-
OUTL BUS,A (*)21-
OUTL Pp,A21-
RET21SP
RETR21SP,PSW
RL A11-
RLC A11CY
RR A11-
RRC A11CY
SEL MB011-
SEL MB111-
SEL RB011BS
SEL RB111BS
STOP TCNT11-
STRT CNT11-
STRT T11-
SWAP A11-
XCH A,Rr11-
XCH A,@Ri11-
XCHD A,@Ri11-
XRL A,Rr11-
XRL A,@Ri11-
XRL A,#data22-
(*) Must not be used with an external program memory (see chapter 2.6.0).

SymbolDefinition
ACAuxiliary Carry Flag in PSW
BSRegister-Bank-Select Flag in PSW
CYCarry Flag in PSW
F0User Flag 0 in PSW
F1User Flag 1
PpPort (p = 1, 2 or p = 4...7)
PSWProgram Status Word
RiIndex Register (i = 0, 1)
RrWork Register (r = 0...7)
SPStack-Pointer in PSW

7.2.0 DeMon48_128k Serial Interface Protocol

CommandDescription
0x00Transmit DevID, VerMajor, VerMinor and VerRevision
0x01Load ROM Testroutine
0x02Transmit a 256byte page from RAM
0x03MCS48Run
0x04Transmit and Receive Monitor Options
0x05Reset MCS48 µC
0x06Receive modified internal MCS-48 µC registers
0x07Receive internal RAM locations 0x01 to 0x7F
0x08Receive MCS-48 port contents and bits
0x09Step And Read
0x0ARead Only
0x0BReceive a 256byte RAM page
0x0CTransmit Hardware Status
0x0DExecute with multiple Soft-BreakPoints
0x0EReceive n-bytes for external RAM
0x0FExecute with HardwareBreakPoint
0x10Transmit ALE Cycle Counter contents
0x11Reset ALE Cycle Counter
0x12Fill area in external RAM with single value
0x13Prepare Reception/Fill
0x14Execute single command in direct mode
0x15Write to the Debug-µC's internal EEPROM
0x16Read from the Debug-µC's internal EEPROM
0x17Set Single Step Delay Time (5µs increments)
0x18XEEPROM_Write single Byte
0x19XEEPROM_Read single Byte
0x1AXEEPROM_CopyFromRAM copy a 4kB page from RAM to XEEPROM
0x1BXEEPROM_CopyToRAM copy a 4kB page from XEEPROM to RAM
0x1CTransmit AutoLoad dataset
0x1DReceive AutoLoad dataset

0x00 Transmit DevID, VerMajor, VerMinor and VerRevision

PCDir.DeMon48Notes
0x00>
<0x00
<Device ID
<Version Major
<Version Minor
<Version Revision
"PC" = Personal Computer

0x01 Load ROM Testroutine

PCDir.DeMon48Notes
0x01>
<0x01
Testroutine #>
"PC" = Personal Computer

0x02 Transmit a 256byte page from RAM

PCDir.DeMon48Notes
0x02>
<0x02
StartAddrW>A16
StartAddrH>A15...A8
<Data256 bytes
"PC" = Personal Computer

0x03 MCS48Run

PCDir.DeMon48Notes
0x03>
<0x03
"PC" = Personal Computer

After execution of this command, the MCS48 µC controls A0...A16, D0...D7, RAM_OE, RAM_WE.
RESETOUT=H, nDBG_ACT=H.

0x04 Transmit and Receive Monitor Options

PCDir.DeMon48Notes
0x04>
<0x04
<Options(*)
Options(*)>
"PC" = Personal Computer

(*) Bit2=StartCnt,Bit1=StartT,Bit0=StopTCnt

0x05 Reset MCS-48 µC

PCDir.DeMon48Notes
0x05>
<0x05
"PC" = Personal Computer

0x06 Receive modified internal MCS-48 µC registers

PCDir.DeMon48Notes
0x06>
<0x06
<Status0x00=Monitor is active
DBG_PC_H>
DBG_PC_L>
DBG_A>
DBG_T>
DBG_PSW>
DBG_R0RB0>
LoadT>Bit0 is set to load new value in T-register
"PC" = Personal Computer

0x07 Receive internal RAM locations 0x01 to 0x7F

PCDir.DeMon48Notes
0x07>
<0x07
<Status0x00=Monitor is active
Data>127 bytes
"PC" = Personal Computer

0x08 Receive MCS-48 port contents and bits

PCDir.DeMon48Notes
0x08>
<0x08
<Status0x00=Monitor is active
DBG_P1>
DBG_P2>
DBG_BITS>Bit2=F1, Bit4=SEL MB0 pending, Bit5=SEL MB1 pending
DBG_PBR>
DBG_DBR>
"PC" = Personal Computer

0x09 Step And Read

PCDir.DeMon48Notes
0x09>
<0x09
<DBG_PC_H
<DBG_PC_L
<DBG_A
<DBG_T
<DBG_PSW
<DBG_R0RB0
<DBG_P1
<DBG_P2
<DBG_BITS
<DBG_PBR
<DBG_DBR
<DBG_NextInstr0
<DBG_NextInstr1
<DataInternal MCS-48 µC RAM 0x01...0x7F
"PC" = Personal Computer

0x0A Read Only

PCDir.DeMon48Notes
0x0A>
<0x0A
<DBG_PC_H
<DBG_PC_L
<DBG_A
<DBG_T
<DBG_PSW
<DBG_R0RB0
<DBG_P1
<DBG_P2
<DBG_BITS
<DBG_PBR
<DBG_DBR
<DBG_NextInstr0
<DBG_NextInstr1
<DataInternal MCS-48 µC RAM 0x01...0x7F
"PC" = Personal Computer

0x0B Receive a 256byte RAM page

PCDir.DeMon48Notes
0x0B>
<0x0B
StartAddrW>A16
StartAddrH>A15...A8
Data>256 bytes
"PC" = Personal Computer

0x0C Transmit Hardware Status

PCDir.DeMon48Notes
0x0C>
<0x0C
<StatusBit1=SingleStep active, Bit2=Monitor active
"PC" = Personal Computer

0x0D Execute with multiple Soft-BreakPoints

PCDir.DeMon48Notes
0x0D>
<0x0D
Soft_BP0_H>A15...A8
Soft_BP0_L>A7...A0
Soft_BP1_H>A15...A8
Soft_BP1_L>A7...A0
Soft_BP2_H>A15...A8
Soft_BP2_L>A7...A0
Soft_BP3_H>A15...A8
Soft_BP3_L>A7...A0
Soft_BP4_H>A15...A8
Soft_BP4_L>A7...A0
Soft_BP5_H>A15...A8
Soft_BP5_L>A7...A0
Soft_BP6_H>A15...A8
Soft_BP6_L>A7...A0
Soft_BP7_H>A15...A8
Soft_BP7_L>A7...A0
Soft_BP_Enable>Bit0=Enable BP0 ... Bit7=Enable BP7
"PC" = Personal Computer

When a breakpoint-match is detected, 0xAA is sent to the PC.

When the "Break"-button in the GUI is clicked, 0x55 is sent to DeMon48 and program execution in breakpoint mode is aborted.

0x0E Receive n-bytes for external RAM

PCDir.DeMon48Notes
0x0E>
<0x0E
<0x55Synchronization byte
StartAddrW>A16
StartAddrH>A15...A8
StartAddrL>A7...A0
ByteCountH>Number of bytes - H (Bit15...Bit8)
ByteCountL>Number of bytes - L (Bit7...Bit0)
Data>n-bytes
"PC" = Personal Computer

0x0F Execute with HardwareBreakPoint

PCDir.DeMon48Notes
0x0F>
<0x0F
Hard_BP_H>A15...A8
Hard_BP_L>A7...A0
"PC" = Personal Computer

When a breakpoint-match is detected, 0xAA is sent to the PC.

When the "Break"-button in the GUI is clicked, 0x55 is sent to DeMon48 and program execution in breakpoint mode is aborted.

0x10 Transmit ALE Cycle Counter contents

PCDir.DeMon48Notes
0x10>
<0x10
<Count_XD31...D24
<Count_WD23...D16
<Count_HD15...D8
<Count_LD7...D0
"PC" = Personal Computer

0x11 Reset ALE Cycle Counter

PCDir.DeMon48Notes
0x11>
<0x11
"PC" = Personal Computer

0x12 Fill area in external RAM with single value

PCDir.DeMon48Notes
0x12>
<0x12
StartAddrW>A16
StartAddrH>A15...A8
StartAddrL>A7...A0
ByteCountH>Number of bytes - H (Bit15...Bit8)
ByteCountL>Number of bytes - L (Bit7...Bit0)
FillValue>
"PC" = Personal Computer

0x13 Prepare Reception/Fill

PCDir.DeMon48Notes
0x13>
<0x13
"PC" = Personal Computer

0x14 Execute single command in direct mode

PCDir.DeMon48Notes
0x14>
<0x14
Command0>
Command1>
Flags>Bit0=1/2byte, Bit1=PC is changed by command
"PC" = Personal Computer

0x15 Write to the Debug-µC's internal EEPROM

PCDir.DeMon48Notes
0x15>
<0x15
Data>
Address>
"PC" = Personal Computer

0x16 Read from the Debug-µC's internal EEPROM

PCDir.DeMon48Notes
0x16>
<0x16
Address>
<Data
"PC" = Personal Computer

0x17 Set Single Step Delay Time (5µs increments)

PCDir.DeMon48Notes
0x17>
<0x17
DelayW>D23...D16
DelayH>D15...D8
DelayL>D7...D0
"PC" = Personal Computer

0x18 XEEPROM_Write single Byte

PCDir.DeMon48Notes
0x18>
<0x18
AddrH>A15...A8
AddrL>A7...A0
Data>
"PC" = Personal Computer

0x19 XEEPROM_Read single Byte

PCDir.DeMon48Notes
0x19>
<0x19
AddrH>A15...A8
AddrL>A7...A0
<Data
"PC" = Personal Computer

0x1A XEEPROM_CopyFromRAM

PCDir.DeMon48Notes
0x1A>
<0x1A
RAM_Block>4kB block number in RAM
EEPROM_Block>4kB block number in XEEPROM
<Flags
"PC" = Personal Computer

0x1B XEEPROM_CopyToRAM

PCDir.DeMon48Notes
0x1B>
<0x1B
RAM_Block>4kB block number in RAM
EEPROM_Block>4kB block number in XEEPROM
<Flags
"PC" = Personal Computer

0x1C Transmit AutoLoad dataset

PCDir.DeMon48Notes
0x1C>
<0x1C
Dataset number>0...9
<BlockEnable0 (*)
<BlockEnable1 (*)
<Destination0 (**)EEPROM block 0 and 1
<Destination1 (**)EEPROM block 2 and 3
<Destination2 (**)EEPROM block 4 and 5
<Destination3 (**)EEPROM block 6 and 7
<Destination4 (**)EEPROM block 8 and 9
<Destination5 (**)EEPROM block A and B
<Destination6 (**)EEPROM block C and D
<Destination7 (**)EEPROM block E and F
"PC" = Personal Computer

(*) Byte0,Bit7 = Enable Load for 4kB block #00; Byte1,Bit0 = Enable Load for 4kB block #0F

(**) Bit7...Bit4 = Lower 4k-EEPROM block, Bit3...Bit0 = Upper 4k-EEPROM block

0x1D Receive AutoLoad dataset

PCDir.DeMon48Notes
0x1D>
<0x1D
Dataset number>0...9
BlockEnable0(*)>
BlockEnable1(*)>
Destination0 (**)>EEPROM block 0 and 1
Destination1 (**)>EEPROM block 2 and 3
Destination2 (**)>EEPROM block 4 and 5
Destination3 (**)>EEPROM block 6 and 7
Destination4 (**)>EEPROM block 8 and 9
Destination5 (**)>EEPROM block A and B
Destination6 (**)>EEPROM block C and D
Destination7 (**)>EEPROM block E and F
"PC" = Personal Computer

(*) Byte0,Bit7 = Enable Load for 4kB block #00; Byte1,Bit0 = Enable Load for 4kB block #0F

(**) Bit7...Bit4 = Lower 4k-EEPROM block, Bit3...Bit0 = Upper 4k-EEPROM block

7.3.0 MCS-48 code example "DeMon48_128k RAM Test"

"DeMon48_128k RAM Test" for MCS-48 µCs uses the MMU to write to the entire DeMon48_128k RAM, reading back the stored value and comparing it with the previously written value:

  1. Test memory area 0x1FFFF...0x10000
  2. Test memory area 0x0FFFF...0x00100
  3. Copy program from page 0 (start address 0x00000) to page 1 (start address 0x00100)
  4. Test memory area 0x000FF...0x00000
  5. Copy program from page 1 (start address 0x00100) to page 0 (start address 0x00000)

If there is a difference between the written and read value, the error-counter is incremented. If T0 is set to logic high, the test loop then stops until it is resumed by a high-to-low transition at *INT.

If T1 is set to logic low, an I/O area enabled by the jumper configuration (see "5.0.0 Memory configurations") is disabled via the MMU's expansion register (EXP) before a new test run is started.

If low potential is applied to input P2.4, the contents of the error counter are displayed on P1, and if high potential is applied, the contents of the test counter are displayed.

High potential at output P2.5 indicates that one or more errors have been detected, high potential at output P2.6 indicates that the current test has been stopped after an error, and high potential at output P2.7 indicates that all 256 test runs have been completed.

    ;DeMon48_128k RAM Test V1.1.1
    ;
    ;Tests its entire 128kB RAM 256 times and displays the number of verify
    ;errors or test runs on P1 and various status signals on P2.7 ... P2.5
    ;
    ;V1.0.0 Inital release
    ;V1.0.1 Uses a more sophisticated test pattern by toggling
    ;       inversion of the written value every 256 bytes and between
    ;       successive runs
    ;V1.1.0 Improved test pattern, status displays on P2 and error / test
    ;       counter display on P1
    ;V1.1.1 Makes use of the "DIS_P2_L" bit in the "EXP" register
    ;
    ;(c)2024, 2025 M. Schmoll * www.controller-designs.de
    ;
    ;T0   : 1=Stop on verify error / 0=Don't stop on verify error
    ;T1   : 1=Enable I/O address range / 0=Disable I/O address range
    ;*INT : Continue after stop (H->L)
    ;P2.7 : Test is complete (Output)
    ;P2.6 : Stopped after error (Output)
    ;P2.5 : Error(s) detected (Output)
    ;P2.4 : 1=Display test counter, 0=Display error counter (Input)
    ;R7 : Loop counter (DBL)
    ;R6 : Loop counter (DBH)
    ;R5 : Temporary register
    ;R4 : Test counter
    ;R3 : Error counter
    ;R0 : Loop counter, index register
    CPU 8039
    ORG 000H
    CLR A
    MOV R4,A            ;Initialize Test counter
    MOV R3,A            ;Initialize Error counter
    ORL A,#00010000B    ;P2.4 = Input
    OUTL P2,A
RAMTEST128K:
    CALL READ_SWITCHES_AND_DISPLAY
    MOV A,#00000100B    ;Disable D-FF on P2.0...P2.3 (DIS_P2_L=1)
    JT1 RAMTEST_EXP_WRITE ;Enable I/O, if T1 = 1
    MOV A,#00001100B    ;Disable I/O, if T1 = 0 (DIS_IO=1)
RAMTEST_EXP_WRITE:
    MOVD P7,A           ;EXP = A, DA16 = H
U64K_TEST:
    ;Test 0x1FFFF...0x10000
    MOV R6,#10H
U64K_LOOP2:
    MOV A,R6
    DEC A
    MOVD P5,A           ;DBH = A, DA16 = H
    MOV R7,#10H
U64K_LOOP1:
    MOV A,R7
    DEC A
    MOVD P4,A           ;DBL = A, DA16 = H
    CALL TEST256BYT
    CALL READ_SWITCHES_AND_DISPLAY
    DJNZ R7,U64K_LOOP1
    DJNZ R6,U64K_LOOP2
L64K_TEST:
    ;Test 0x0FFFF...0x00100
    MOV R6,#10H
L64K_LOOP2:
    MOV A,R6
    DEC A
    ORLD P5,A           ;DBH = A, DA16 = L
    MOV R7,#10H
L64K_LOOP1:
    MOV A,R7
    DEC A
    ORLD P4,A           ;DBL = A, DA16 = L
    CALL TEST256BYT
    CALL READ_SWITCHES_AND_DISPLAY
    MOV A,#02H
    XRL A,R7            ;DBL = 0x1 ?
    JNZ L64K_CONT
    MOV A,#01H
    XRL A,R6            ;DBH = 0x0 ?
    JZ L64K_EXIT        ;Yes, exit before writing to page 0
L64K_CONT:
    DJNZ R7,L64K_LOOP1
    DJNZ R6,L64K_LOOP2
L64K_EXIT:
    ;Prepare 256Byte copy from page 0 to page 1
    MOV R7,#01          ;Destination page
    MOV R6,#00          ;Source page
    CALL COPY256BYT
    JMP TEST_P0 + 0100H ;Jump to page 1
TEST_P0:
    ;Test 0x000FF...0x00000
    CLR A
    ORLD P5,A           ;DBH = A, DA16 = L
    ORLD P4,A           ;DBL = A, DA16 = L
    CALL TEST256BYT + 0100H ;Call to page 1
    CALL READ_SWITCHES_AND_DISPLAY + 0100H
    ;Prepare 256Byte copy from page 1 to page 0
    MOV R7,#00          ;Destination page
    MOV R6,#01          ;Source page
    CALL COPY256BYT + 0100H ;Call to page 1
    CPL F0              ;Toggle invert/non-invert bit for next run
    DJNZ R4,RAMTEST128K_NEXT
RAMTEST128K_FINISH:
    IN A,P2             ;Set "Test finished" output
    ORL A,#10010000B
    OUTL P2,A
RAMTEST128K_FINISH_L0:
    CALL READ_SWITCHES_AND_DISPLAY
    JMP RAMTEST128K_FINISH_L0
RAMTEST128K_NEXT:
    JMP RAMTEST128K     ;Jump to page 0
    ;------------------------------------------------------------------------
TEST256BYT:
    ;Test a 256Byte page selected by DBH and DBL
    ;Destroys : A,R0,R5,P1
    MOV R0,#00
TEST256BYT_L0:
    MOV A,R0
    JF0 TEST256BYT_L1
    CPL A               ;Invert write value, if F0 = 0
TEST256BYT_L1:
    ADD A,R4            ;Add Test counter value
    MOV R5,A            ;Save write value
    MOVX @R0,A          ;Write
    MOVX A,@R0          ;Read
    XRL A,R5            ;Verify
    JZ TEST256BYT_L5    ;Verify ok
    INC R3              ;Increment Error counter
    IN A,P2             ;Set "Error(s) detected" output
    ORL A,#00110000B
    OUTL P2,A
    CALL READ_SWITCHES_AND_DISPLAY
    JNT0 TEST256BYT_L4  ;Don't stop on error, if T0 = 0
    IN A,P2             ;Set "Test stopped" output
    ORL A,#01010000B
    OUTL P2,A
TEST256BYT_L2:
    ;Wait for *INT=H
    CALL READ_SWITCHES_AND_DISPLAY
    JNI TEST256BYT_L2
    MOV R5,#00H         ;Debounce
    NOP
    NOP
    NOP
    DJNZ R5,$-3
    CLR C
TEST256BYT_L3:
    ;Wait for *INT=L
    CALL READ_SWITCHES_AND_DISPLAY
    JNI TEST256BYT_L4
    JNC TEST256BYT_L3
TEST256BYT_L4:
    MOV R5,#00H         ;Delay after verify error
    NOP
    NOP
    NOP
    DJNZ R5,$-3
    IN A,P2             ;Clear "Test stopped" output
    ANL A,#10111111B
    ORL A,#00010000B    ;P2.4 = Input
    OUTL P2,A
TEST256BYT_L5:
    DJNZ R0,TEST256BYT_L0
    CPL F0              ;Toggle invert/non-invert bit for next 256 bytes
    RET
    ;------------------------------------------------------------------------
COPY256BYT:
    ;Copy a 256Byte page in 4kB-Bank 0
    ;R7 = Destination page
    ;R6 = Source page
    ;Destroys : A,R0,R5,DBL,DBH,DA16
    CLR A
    ORLD P5,A           ;DBH = A, DA16 = L
    MOV R0,A            ;Init loop counter
COPY256BYT_L:
    MOV A,R6            ;Source page
    ORLD P4,A           ;DBL = A, DA16 = L
    MOV A,R0
    MOVX A,@R0
    MOV R5,A
    MOV A,R7            ;Destination page
    ORLD P4,A           ;DBL = A, DA16 = L
    MOV A,R5
    MOVX @R0,A
    DJNZ R0,COPY256BYT_L
    RET
    ;------------------------------------------------------------------------
READ_SWITCHES_AND_DISPLAY:
    ;P2.4 : 1=Display test counter, 0=Display error counter (Input)
    ;R4 : Test counter
    ;R3 : Error counter
    IN A,P2
    ANL A,#00010000B
    JZ READ_SWITCHES_AND_DISPLAY_L
    MOV A,R4            ;Test counter
    CPL A
    INC A
    OUTL P1,A
    RET
READ_SWITCHES_AND_DISPLAY_L:
    MOV A,R3            ;Error counter
    OUTL P1,A
    RET

MCS-48 code example "DeMon48_128k RAM Test" in Intel-Hex-Format:

:1000000027ACAB43103A14AB2304560E230C3FBE6F
:1000100010FE073DBF10FF073C145F14ABEF16EE58
:1000200011BE10FE078DBF10FF078C145F14AB23A9
:1000300002DF96392301DEC63DEF28EE23BF01BE65
:1000400000149C2445278D8C345F34ABBF00BE0167
:10005000349C95EC5D0A43903A14AB04590406B8FD
:1000600000F8B665376CAD9080DDC6981B0A43304A
:100070003A14AB268B0A43503A14AB8679BD000084
:100080000000ED7F9714AB868BE685BD0000000075
:10009000ED8D0A53BF43103AE8619583278DA8FE82
:1000A0008CF880ADFF8CFD90E89F830A5310C6B595
:0800B000FC37173983FB39838B
:00000001FF


DeMon48_128k Breadboard