Embodiment
Embodiment: following will be that example is described in further details the present invention in conjunction with the accompanying drawings with emulation 51 series monolithics.
As shown in Figure 1, the present invention downloads to external program memory and synchronous pre-service storer by emulation monitoring and communication interface circuit with the ownership goal code.The address wire of pre-service storer is identical with external program memory synchronously, and the pre-service storer is used to store the operand of each bar instruction except that operational code synchronously.Start emulation CPU by the emulation supervisory circuit and begin to carry out program in the external program memory.Instruction is replaced with port and is remake circuit monitoring when emulation CPU is about to read the operational code of new instruction, judge that according to the operand of synchronous pre-service memory stores whether this new instruction is the instruction of data bus mouth or address bus mouth being carried out input and output (I/O), if, replace with other instruction immediately by the instruction replacement circuit, and remake at port under the control of circuit, finish identical input and output (I/O) operation by remaking port.
Emulation CPU only requires to have data bus mouth, the address bus mouth that is used to move external program and get the finger control line, but emulation CPU itself can not have the port or the hardware circuit of the emulation of being specifically designed to.
The device with instruction replacement realization one-chip machine simulation as shown in Figures 2 and 3 comprises a kind of with instructing the device of replacing the realization one-chip machine simulation, and described device comprises that emulation CPU, external program memory, synchronous pre-service storer, instruction replacement remake circuit, emulation monitoring and communication interface circuit, user's plate emulation interface with port; Described emulation CPU refers to that control line, address data bus mouth, address bus mouth and instruction are replaced and remakes the link to each other line data of going forward side by side of circuit with port and exchange by getting; Described external program memory is replaced by data line, read-write control line, address wire and instruction and is remake the link to each other line data of going forward side by side of circuit with port and exchange; User's plate emulation interface is connected with other port that remakes port and emulation CPU that port remakes the circuit generation, and described other port is meant that emulation CPU goes up all of the port except that address bus mouth, address data bus mouth.
As shown in Figure 4, in the order set of 51 series monolithics, the instruction relevant with P0, P2 mouth has 50, wherein PX represents P0 or P2 mouth, PX.X represents one of P0.0, P0.1, P0.2, P0.3, P0.4, P0.5, P0.6, P0.7, P2.0, P2.1, P2.2, P2.3, P2.4, P2.5, P2.6, P2.7, and Ri represents one of R0, R1, R2, R3, R4, R5, R6, R7.
To be described in detail the instruction replacement process of each bar instruction among Fig. 4 below:
1. instruct for SETB PX.X:
Replace with following instruction:
MOV A, 0E0H; Putting simultaneously and remaking port PX.X is 1
2. instruct for CLR PX.X:
Replace with following instruction:
MOV A, 0E0H; Putting simultaneously and remaking port PX.X is 0
3. instruct for CPL PX.X:
Replace with following instruction:
MOV A, 0E0H; To remake port PX.X negate simultaneously
4. for MOV PX.X, C instructs:
Replace with following instruction:
JBC EA, REL1; Putting and remaking port PX.X is 1
USER1:JC USER1-1; C turned back to user program at 1 o'clock
SJMP USER1-1; Putting and remaking port PX.X is 0, turns back to user program
REL1:JC USER1-1; C turned back to user program at 1 o'clock
SETB EA; Putting and remaking port PX.X is 0
SJMP USER1-1; Turn back to user program
5. for MOV C, PX.X instructs:
If PX.X is 1, replace with following instruction:
SETB 0D7H
If PX.X is 0, replace with following instruction:
CLR 0D7H
6. for ANL C, PX.X instructs:
If PX.X is 1, replace with following instruction:
MOV A,0E0H
If PX.X is 0, replace with following instruction:
CLR 0D7H
7. for ANL C ,/PX.X instructs:
If PX.X is 1, replace with following instruction:
CLR 0D7H
If PX.X is 0, replace with following instruction:
MOV A,0E0H
8. for ORL C, PX.X instructs:
If PX.X is 1, replace with following instruction:
SETB 0D7H
If PX.X is 0, replace with following instruction:
MOV A,0E0H
9. for ORL C ,/PX.X instructs:
If PX.X is 1, replace with following instruction:
MOV A,0E0H
If PX.X is 0, replace with following instruction:
SETB 0D7H
10. for JBC PX.X, REL instructs:
If PX.X is 1, replace with following instruction:
SJMP 01H; Putting simultaneously and remaking port PX.X is 0
If PX.X is 0, replace with following instruction:
SJMP REL+1
11. for JB PX.X, the REL instruction:
If PX.X is 1, replace with following instruction:
SJMP 01H
If PX.X is 0, replace with following instruction:
SJMP REL+1
12. for JNB PX.X, the REL instruction:
If PX.X is 0, replace with following instruction:
SJMP REL+1
If PX.X is 1, replace with following instruction:
SJMP 01
13. for MOV PX, the #DATA instruction, replace with following instruction:
MOV 0E0H, 0E0H; To remake port PX assignment simultaneously is DATA
14. for MOV PX, the A instruction, replace with following instruction:
JBC EA,REL2
USER2:MOVC A , @A+PC; Obtain the value (being made as VALUE) of A, will remake port PX assignment simultaneously is VALUE
When carrying out MOVC A , @A+PC instruction, instruction is replaced and port weighs
Make circuit according to the address at this instruction place and the address of being tabled look-up, can
Calculate the value of A, down together)
MOV A, #VALUE; Recover the value of A
SJMP USER2-1; Return user program
REL2:MOVC A , @A+PC; Obtain the value (being made as VALUE) of A, will remake port PX assignment simultaneously is VALUE
MOV A, #VALUE; Recover the value of A
SETB EA
SJMP USER2-1; Return user program
15. for MOV PX, the DIRECT instruction, replace with following instruction:
JBC EA,REL3
USER3:MOVC A , @A+PC; Obtain the value (being made as VALUE1) of A
MOV A,DIRECT
MOVC A , @A+PC; Obtain the value (being made as VALUE2) of A, will remake port simultaneously
The PX assignment is VALUE2
MOV A, #VALUE1; Recover the value of A
SJMP USER3; Return user program
REL3:MOVC A , @A+PC; Obtain the value (being made as VALUE1) of A
MOV A,DIRECT
MOVC A , @A+PC; Obtain the value (being made as VALUE2) of A, will remake end simultaneously
Mouth PX assignment is VALUE2
MOV A, #VALUE1; Recover the value of A
SETB EA
SJMP USER3; Return user program
16., replace with following instruction for MOV PX , @R0 instruction:
JBC EA,REL4
USER4:MOVC A , @A+PC; Obtain the value (being made as VALUE1) of A
MOV A,@R0
MOVC A , @A+PC; Obtain the value (being made as VALUE2) of A, will remake end simultaneously
Mouth PX assignment is VALUE2
MOV A, #VALUE1; Recover the value of A
SJMP USER4-1; Return user program
REL4:MOVC A , @A+PC; Obtain the value (being made as VALUE1) of A
MOV A,@R0
MOVC A , @A+PC; Obtain the value (being made as VALUE2) of A, will remake end simultaneously
Mouth PX assignment is VALUE2
MOV A, #VALUE1; Recover the value of A
SETB EA
SJMP USER4-1; Return user program
17., replace with following instruction for MOV PX , @R1 instruction:
JBC EA,REL5
USER5:MOVC A , @A+PC; Obtain the value (being made as VALUE1) of A
MOV A,@R1
MOVC A , @A+PC; Obtain the value (being made as VALUE2) of A, will remake simultaneously
Port PX assignment is VALUE2
MOV A, #VALUE1; Recover the value of A
SJMP USER5-1; Return user program
REL5:MOVC A , @A+PC; Obtain the value (being made as VALUE1) of A
MOV A,@R1
MOVC A , @A+PC; Obtain the value (being made as VALUE2) of A, will remake simultaneously
Port PX assignment is VALUE2
MOV A, #VALUE1; Recover the value of A
SETB EA
SJMP USER5-1; Return user program
18. for MOV A, the PX instruction, replace with following instruction:
MOV A, #VALUE; Obtain the value (being made as VALUE) that remakes port PX
19. for MOV DIRECT, the PX instruction, replace with following instruction:
MOV DIRECT, #VALUE; Obtain the value (being made as VALUE) that remakes port PX
20. for MOV @R0, the PX instruction, replace with following instruction:
MOV @R0, #VALUE; Obtain the value (being made as VALUE) that remakes port PX
21. for MOV @R1, the PX instruction, replace with following instruction:
MOV @R1, #VALUE; Obtain the value (being made as VALUE) that remakes port PX
22. for MOV P0, the P2 instruction, replace with following instruction:
MOV 0E0H, 0E0H; Obtain the value that remakes port P2, and assignment is to remaking port P0
23. for MOVX @DPTR, the A instruction, replace with following instruction:
MOVX @DPTR, A; With address data bus with remake port and be communicated with, finish write operation
24., replace with following instruction for MOVX A , @DPTR instruction:
MOVX A , @DPTR; With address data bus with remake port and be communicated with, finish read operation
25., replace with following instruction for MOVX A , @R0 instruction:
MOVX A , @R0; With address data bus with remake port and be communicated with, finish read operation
26., replace with following instruction for MOVX A , @R1 instruction:
MOVX A , @R1; With address data bus with remake port and be communicated with, finish read operation
27. for MOVX @R0, the A instruction, replace with following instruction:
MOVX @R0, A; With address data bus with remake port and be communicated with, finish write operation
28. for MOVX @R1, the A instruction, replace with following instruction:
MOVX @R1, A; With address data bus with remake port and be communicated with, finish write operation
29. for MOV Ri, the PX instruction, replace with following instruction:
MOV Ri, #VALUE; Obtain the value (being made as VALUE) that remakes port PX
30. for MOV PX, the Ri instruction, replace with following instruction:
JBC EA,REL6
USER60:MOVC A , @A+PC; Obtain the value (being made as VALUE1) of A
MOV A,Ri
MOVC A , @A+PC; Obtain the value (being made as VALUE2) of A, simultaneously will
Remaking port PX assignment is VALUE2
MOV A, #VALUE1; Recover the value of A
SJMP USER60-1; Return user program
REL6:MOVC A , @A+PC; Obtain the value (being made as VALUE1) of A
MOV A,Ri
MOVC A , @A+PC; Obtain the value (being made as VALUE2) of A, simultaneously will
Remaking port PX assignment is VALUE2
MOV A, #VALUE1; Recover the value of A
SETB EA
SJMP USER60-1; Return user program
31. for DJNZ PX, the REL instruction, replace with following instruction:
If remake port PX is 01H, with as the replacement that gives an order:
SJMP 01; Putting simultaneously and remaking port PXX is 00H
If remake port PX, with as giving an order replacement for 01H:
SJMP REL+1; The value that will remake port PXX simultaneously subtracts 1
32. for CJNE A, PX, the REL instruction, replace with following instruction:
CJNE A, #VALUE, REL; Obtain the value (being made as VALUE) that remakes port PX
33. for ADD A, the PX instruction, replace with following instruction:
ADD A, #VALUE; Obtain the value (being made as VALUE) that remakes port PX
34. for ADDC A, the PX instruction, replace with following instruction:
ADDC A, #VALUE; Obtain the value (being made as VALUE) that remakes port PX
35. for SUBB A, the PX instruction, replace with following instruction:
SUBB A, #VALUE; Obtain the value (being made as VALUE) that remakes port PX
36. for ANL PX, the #DATA instruction, replace with following instruction:
MOV 0E0H, 0E0H; The value and the DATA that remake port PX make logical and
37. for ORL PX, the #DATA instruction, replace with following instruction:
MOV 0E0H, 0E0H; The value and the DATA that remake port PX make logical OR
38. for ANL A, the PX instruction, replace with following instruction:
ANL A, #VALUE; Obtain the value (being made as VALUE) that remakes port PX
39. for ANL PX, the A instruction, replace with following instruction:
JBC EA,REL7
USER7:MOVC A , @A+PC; Obtain the value (being made as VALUE) of A, remake port
PX and A make logical and, and assignment is to remaking port PX
MOV A, #VALUE; Recover the value of A
SJMP USER7-1; Return user program
REL7:MOVC A , @A+PC; Obtain the value (being made as VALUE) of A, remake port
PX and A make logical and, and assignment is to remaking port PX
MOV A, #VALUE; Recover the value of A
SETB EA
SJMP USER7-1; Return user program
40. for ORL A, the PX instruction, replace with following instruction:
ORL A, #VALUE; Obtain the value (being made as VALUE) that remakes port PX
41. for ORL PX, the A instruction, replace with following instruction:
JBC EA,REL8
USER8:MOVC A , @A+PC; Obtain the value (being made as VALUE) of A, remake port
PX and A make logical OR, and assignment is to remaking port
PX
MOV A, #VALUE; Recover the value of A
SJMP USER8-1; Return user program
REL8:MOVC A , @A+PC; Obtain the value (being made as VALUE) of A, remake port
PX and A make logical OR, and assignment is to remaking port
PX
MOV A, #VALUE; Recover the value of A
SETB EA
SJMP USER8-1; Return user program
42. for XRL A, the PX instruction, replace with following instruction:
XRL A, #VALUE; Obtain the value (being made as VALUE) that remakes port PX
43. for XRL PX, the A instruction, replace with following instruction:
JBC EA,REL9
USER9:MOVC A , @A+PC; Obtain the value (being made as VALUE) of A, remake port
PX and VALUE make the logic XOR, and assignment is remake
Port PX
MOV A, #VALUE; Recover the value of A
SJMP USER9-1; Return user program
REL9:MOVC A , @A+PC; Obtain the value (being made as VALUE) of A, remake port
PX and VALUE make the logic XOR, and assignment is remake
Port PX
MOV A, #VALUE; Recover the value of A
SETB EA
SJMP USER9-1; Return user program
44. for XRL PX, the #DATA instruction, replace with following instruction:
MOV 0E0H, 0E0H; Remake after the value of port PX and DATA make the logic XOR
Compose to give and remake port PX
45. for XCH A, the PX instruction, replace with following instruction:
JBC EA,REL10
USER10:MOVC A , @A+PC; Obtain the value (being made as VALUE1) of A
MOV A, #VALUE2; Obtain the value (being made as VALUE2) that remakes port PX,
And the VALUE1 assignment given remake port PX
SJMP USER10-1; Return user program
REL10:MOVC A , @A+PC; Obtain the value (being made as VALUE1) of A
MOV A, #VALUE2; Obtain the value (being made as VALUE2) that remakes port PX,
And the VALUE1 assignment given remake port PX
SETB EA
SJMP USER10-1; Return user program
46., replace with following instruction for DEC PX instruction:
MOV A, 0E0H; The value that remakes port PX is subtracted 1 back assignment to remaking port PX
47., replace with following instruction for INC PX instruction:
MOV A, 0E0H; The value that remakes port PX is added 1 back assignment to remaking port PX
48., replace with following instruction for PUSH PX instruction:
JBC EA,REL11
USER11:MOVC A , @A+PC; Obtain the value (being made as VALUE1) of A, obtain and remake
The value of port PX (being made as VALUE2)
MOV A,#VALUE2
PUSH ACC
MOV A, #VALUE1; Recover the value of A
SJMP USER11-1; Return user program
REL11:MOVC A , @A+PC; Obtain the value (being made as VALUE1) of A, obtain and remake end
The value (being made as VALUE2) of mouth PX
MOV A, #VALUE2; Return user program
PUSH ACC
MOV A, #VALUE1; Recover the value of A
SETB EA
SJMP USER11-1 returns user program
49., replace with following instruction for POP PX instruction:
JBC EA,REL12
USER12:MOVC A , @A+PC; Obtain the value (being made as VALUE1) of A
POP ACC
MOVC A , @A+PC; Obtain the value of A, and assignment is to remaking port PX
MOV A, #VALUE1; Recover the value of A
SJMP USER12-1; Return user program
REL12:MOVC A , @A+PC; Obtain the value (being made as VALUE1) of A
POP ACC
MOVC A , @A+PC; Obtain the value of A, and assignment is to remaking port PX
MOV A, #VALUE1; Recover the value of A
SETB EA
SJMP USER12-1; Return user program
50. for MOV P2, the P0 instruction, replace with following instruction:
MOV 0E0H, 0E0H; Obtain the value that remakes port P0, and assignment is to remaking port P2