Skip to content

Commit

Permalink
[WIP] [P8051] Support P8051
Browse files Browse the repository at this point in the history
  • Loading branch information
tgtakaoka committed May 11, 2024
1 parent 977c1e1 commit a8644fa
Show file tree
Hide file tree
Showing 38 changed files with 13,339 additions and 2,156 deletions.
6 changes: 6 additions & 0 deletions debugger/i8051/compile_flags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-O
-Wall
-std=c++14
-I..
-I../.pio/libdeps/teensy41/libcli/src
-I../.pio/libdeps/teensy41/libasm/src
58 changes: 58 additions & 0 deletions debugger/i8051/devs_i8051.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#include "devs_i8051.h"
#include <string.h>
#include "debugger.h"
#include "i8251.h"

namespace debugger {
namespace i8051 {

DevsI8051 Devs;

void DevsI8051::reset() {
USART.reset();
USART.setBaseAddr(USART_BASE);
}

void DevsI8051::begin() {
enableDevice(USART);
}

void DevsI8051::loop() {
USART.loop();
}

bool DevsI8051::isSelected(uint32_t addr) const {
return USART.isSelected(addr);
}

uint16_t DevsI8051::read(uint32_t addr) const {
return USART.read(addr);
}

void DevsI8051::write(uint32_t addr, uint16_t data) const {
USART.write(addr, data);
}

Device &DevsI8051::parseDevice(const char *name) const {
if (strcasecmp(name, USART.name()) == 0)
return USART;
return Devs::nullDevice();
}

void DevsI8051::enableDevice(Device &dev) {
USART.enable(&dev == &USART);
}

void DevsI8051::printDevices() const {
printDevice(USART);
}

} // namespace i8051
} // namespace debugger

// Local Variables:
// mode: c++
// c-basic-offset: 4
// tab-width: 4
// End:
// vim: set ft=cpp et ts=4 sw=4:
35 changes: 35 additions & 0 deletions debugger/i8051/devs_i8051.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#ifndef __DEVS_I8051_H__
#define __DEVS_I8051_H__

#include "devs.h"

#define USART_BASE 0xFC

namespace debugger {
namespace i8051 {

struct DevsI8051 final : Devs {
void begin() override;
void reset() override;
void loop() override;
bool isSelected(uint32_t addr) const override;
uint16_t read(uint32_t addr) const override;
void write(uint32_t addr, uint16_t data) const override;

Device &parseDevice(const char *name) const override;
void enableDevice(Device &dev) override;
void printDevices() const override;
};

extern struct DevsI8051 Devs;

} // namespace i8051
} // namespace debugger
#endif /* __DEVS_I8051H__ */

// Local Variables:
// mode: c++
// c-basic-offset: 4
// tab-width: 4
// End:
// vim: set ft=cpp et ts=4 sw=4:
258 changes: 258 additions & 0 deletions debugger/i8051/i8051.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,258 @@
op mnemo operand # ~
-- ----- --------- - -
00 NOP 0 1
01 AJMP a11 2
02 LJMP a16 3
03 RR A 1
04 INC A 1
05 INC a8 2
06 INC @R0 1
07 INC @R1 1
08 INC R0 1
09 INC R1 1
0A INC R2 1
0B INC R3 1
0C INC R4 1
0D INC R5 1
0E INC R6 1
0F INC R7 1
10 JBC b8,r8 3
11 ACALL a11 2
12 LCALL a16 3
13 RRC A 1
14 DEC A 1
15 DEC a8 2
16 DEC @R0 1
17 DEC @R1 1
18 DEC R0 1
19 DEC R1 1
1A DEC R2 1
1B DEC R3 1
1C DEC R4 1
1D DEC R5 1
1E DEC R6 1
1F DEC R7 1
20 JB b8,r8 3
21 AJMP a11 2
22 RET - 1
23 RL A 1
24 ADD A,#n8 2
25 ADD A,a8 2
26 ADD A,@R0 1
27 ADD A,@R1 1
28 ADD A,R0 1
29 ADD A,R1 1
2A ADD A,R2 1
2B ADD A,R3 1
2C ADD A,R4 1
2D ADD A,R5 1
2E ADD A,R6 1
2F ADD A,R7 1
30 JNB b8,r8 3
31 ACALL a11 2
32 RETI - 1
33 RLC A 1
34 ADDC A,#n8 2
35 ADDC A,a8 2
36 ADDC A,@R0 1
37 ADDC A,@R1 1
38 ADDC A,R0 1
39 ADDC A,R1 1
3A ADDC A,R2 1
3B ADDC A,R3 1
3C ADDC A,R4 1
3D ADDC A,R5 1
3E ADDC A,R6 1
3F ADDC A,R7 1
40 JC r8 2
41 AJMP a11 2
42 ORL a8,A 2
43 ORL a8,#n8 3
44 ORL A,#n8 2
45 ORL A,a8 2
46 ORL A,@R0 1
47 ORL A,@R1 1
48 ORL A,R0 1
49 ORL A,R1 1
4A ORL A,R2 1
4B ORL A,R3 1
4C ORL A,R4 1
4D ORL A,R5 1
4E ORL A,R6 1
4F ORL A,R7 1
50 JNC r8 2
51 ACALL a11 2
52 ANL a8,A 2
53 ANL a8,#n8 3
54 ANL A,#n8 2
55 ANL A,a8 2
56 ANL A,@R0 1
57 ANL A,@R1 1
58 ANL A,R0 1
59 ANL A,R1 1
5A ANL A,R2 1
5B ANL A,R3 1
5C ANL A,R4 1
5D ANL A,R5 1
5E ANL A,R6 1
5F ANL A,R7 1
60 JZ r8 2
61 AJMP a11 2
62 XRL a8,A 2
63 XRL a8,#n8 3
64 XRL A,#n8 2
65 XRL A,a8 2
66 XRL A,@R0 1
67 XRL A,@R1 1
68 XRL A,R0 1
69 XRL A,R1 1
6A XRL A,R2 1
6B XRL A,R3 1
6C XRL A,R4 1
6D XRL A,R5 1
6E XRL A,R6 1
6F XRL A,R7 1
70 JNZ r8 2
71 ACALL a11 2
72 ORL C,b8 2
73 JMP @A+DPTR 1
74 MOV A,#n8 2
75 MOV a8,#n8 3
76 MOV @R0,#n8 2
77 MOV @R1,#n8 2
78 MOV R0,#n8 2
79 MOV R1,#n8 2
7A MOV R2,#n8 2
7B MOV R3,#n8 2
7C MOV R4,#n8 2
7D MOV R5,#n8 2
7E MOV R6,#n8 2
7F MOV R7,#n8 2
80 SJMP r8 2
81 AJMP a11 2
82 ANL C,b8 2
83 MOVC A,@A+PC 1
84 DIV AB 1
85 MOV a8,a8 3
86 MOV a8,@R0 2
87 MOV a8,@R1 2
88 MOV a8,R0 2
89 MOV a8,R1 2
8A MOV a8,R2 2
8B MOV a8,R3 2
8C MOV a8,R4 2
8D MOV a8,R5 2
8E MOV a8,R6 2
8F MOV a8,R7 2
90 MOV DPTR,#16 3
91 ACALL a11 2
92 MOV b8,C 2
93 MOVC A,@A+DPTR 1
94 SUBB A,#n8 2
95 SUBB A,a8 2
96 SUBB A,@R0 1
97 SUBB A,@R1 1
98 SUBB A,R0 1
99 SUBB A,R1 1
9A SUBB A,R2 1
9B SUBB A,R3 1
9C SUBB A,R4 1
9D SUBB A,R5 1
9E SUBB A,R6 1
9F SUBB A,R7 1
A0 ORL C,/b8 2
A1 AJMP a11 2
A2 MOV C,b8 2
A3 INC DPTR 1
A4 MUL AB 1
A5 - - -
A6 MOV @R0,a8 2
A7 MOV @R1,a8 2
A8 MOV R0,a8 2
A9 MOV R1,a8 2
AA MOV R2,a8 2
AB MOV R3,a8 2
AC MOV R4,a8 2
AD MOV R5,a8 2
AE MOV R6,a8 2
AF MOV R7,a8 2
B0 ANL C,/b8 2
B1 ACALL a11 2
B2 CPL C,b8 2
B3 CPL C 1
B4 CJNE A,#n8,r8 3
B5 CJNE A,a8,r8 3
B6 CJNE @R0,#n8,r8 3
B7 CJNE @R1,#n8,r8 3
B8 CJNE R0,#n8,r8 3
B9 CJNE R1,#n8,r8 3
BA CJNE R2,#n8,r8 3
BB CJNE R3,#n8,r8 3
BC CJNE R4,#n8,r8 3
BD CJNE R5,#n8,r8 3
BE CJNE R6,#n8,r8 3
BF CJNE R7,#n8,r8 3
C0 PUSH a8 2
C1 AJMP a11 2
C2 CLR b8 2
C3 CLR C 1
C4 SWAP A 1
C5 XCH A,a8 2
C6 XCH A,@R0 1
C7 XCH A,@R1 1
C8 XCH A,R0 1
C9 XCH A,R1 1
CA XCH A,R2 1
CB XCH A,R3 1
CC XCH A,R4 1
CD XCH A,R5 1
CE XCH A,R6 1
CF XCH A,R7 1
D0 POP a8 2
D1 ACALL a11 2
D2 SETB C,b8 2
D3 SETB C 1
D4 DA A 1
D5 DJNZ a8,r8 3
D6 XCHD A,@R0 1
D7 XCHD A,@R1 1
D8 DJNZ R0,r8 2
D9 DJNZ R1,r8 2
DA DJNZ R2,r8 2
DB DJNZ R3,r8 2
DC DJNZ R4,r8 2
DD DJNZ R5,r8 2
DE DJNZ R6,r8 2
DF DJNZ R7,r8 2
E0 MOVX A,@DPTR 1
E1 AJMP a11 2
E2 MOVX A,@R0 1
E3 MOVX A,@R1 1
E4 CLR A 1
E5 MOV A,a8 2
E6 MOV A,@R0 1
E7 MOV A,@R1 1
E8 MOV A,R0 1
E9 MOV A,R1 1
EA MOV A,R2 1
EB MOV A,R3 1
EC MOV A,R4 1
ED MOV A,R5 1
EE MOV A,R6 1
EF MOV A,R7 1
F0 MOVX @DPTR,A 1
F1 ACALL a11 2
F2 MOVX @R0,A 1
F3 MOVX @R1,A 1
F4 CPL A 1
F5 MOV a8,A 2
F6 XCHD A,@R0 1
F7 XCHD A,@R1 1
F8 MOV R0,A 1
F9 MOV R1,A 1
FA MOV R2,A 1
FB MOV R3,A 1
FC MOV R4,A 1
FD MOV R5,A 1
FE MOV R6,A 1
FF MOV R7,A 1
Loading

0 comments on commit a8644fa

Please sign in to comment.