W77IE58
- 40 -
MOVX Instruction
The W77IE58, like the standard 8032, uses the MOVX instruction to access external Data Memory.
This Data Memory includes both off-chip memory as well as memory mapped peripherals. While the
results of the MOVX instruction are the same as in the standard 8032, the operation and the timing of
the strobe signals have been modified in order to give the user much greater flexibility.
The MOVX instruction is of two types, the MOVX @Ri and MOVX @DPTR. In the MOVX @Ri, the
address of the external data comes from two sources. The lower 8-bits of the address are stored in
the Ri register of the selected working register bank. The upper 8-bits of the address come from the
port 2 SFR. In the MOVX @DPTR type, the full 16-bit address is supplied by the Data Pointer.
Since the W77IE58 has two Data Pointers, DPTR and DPTR1, the user has to select between the two
by setting or clearing the DPS bit. The Data Pointer Select bit (DPS) is the LSB of the DPS SFR,
which exists at location 86h. No other bits in this SFR have any effect, and they are set to 0. When
DPS is 0, then DPTR is selected, and when set to 1, DPTR1 is selected. The user can switch between
DPTR and DPTR1 by toggling the DPS bit. The quickest way to do this is by the INC instruction. The
advantage of having two Data Pointers is most obvious while performing block move operations. The
accompanying code shows how the use of two separate Data Pointers speeds up the execution time
for code performing the same task.
Block Move with single Data Pointer:
; SH and SL are the high and low bytes of Source Address
; DH and DL are the high and low bytes of Destination Address
; CNT is the number of bytes to be moved
Machine cycles of W77IE58
#
MOV R2, #CNT ; Load R2 with the count value 2
MOV R3, #SL ; Save low byte of Source Address in R3 2
MOV R4, #SH ; Save high byte of Source address in R4 2
MOV R5, #DL ; Save low byte of Destination Address in R5 2
MOV R6, #DH ; Save high byte of Destination address in R6 2
LOOP:
MOV DPL, R3 ; Load DPL with low byte of Source address 2
MOV DPH, R4 ; Load DPH with high byte of Source address 2
MOVX A, @DPTR ; Get byte from Source to Accumulator 2
INC DPTR ; Increment Source Address to next byte 2
MOV R3, DPL ; Save low byte of Source address in R3 2
MOV R4, DPH ; Save high byte of Source Address in R4 2
MOV DPL, R5 ; Load low byte of Destination Address in DPL 2
MOV DPH, R6 ; Load high byte of Destination Address in DPH 2
MOVX @DPTR, A ; Write data to destination 2
INC DPTR ; Increment Destination Address 2
MOV DPL, R5 ; Save low byte of new destination address in R5 2
MOV DPH, R6 ; Save high byte of new destination address in R6 2
DJNZ R2, LOOP ; Decrement count and do LOOP again if count <> 0 2
Machine cycles in standard 8032 = 10 + (26 * CNT)
Machine cycles in W77IE58 = 10 + (26 * CNT)
W77IE58
Publication Release Date: October 20, 2005
- 41 - Revision A5
If CNT = 50
Clock cycles in standard 8032 = ((10 + (26 *50)) * 12 = (10 + 1300) * 12 = 15720
Clock cycles in W77IE58 = ((10 + (26 * 50)) * 4 = (10 + 1300) * 4 = 5240
Block Move with Two Data Pointers in W77IE58:
; SH and SL are the high and low bytes of Source Address
; DH and DL are the high and low bytes of Destination Address
; CNT is the number of bytes to be moved
Machine cycles of W77IE58
#
MOV R2, #CNT ; Load R2 with the count value 2
MOV DPS, #00h ; Clear DPS to point to DPTR 2
MOV DPTR, #DHDL ; Load DPTR with Destination address 3
INC DPS ; Set DPS to point to DPTR1 2
MOV DPTR, #SHSL ; Load DPTR1 with Source address 3
LOOP:
MOVX A, @DPTR ; Get data from Source block 2
INC DPTR ; Increment source address 2
DEC DPS ; Clear DPS to point to DPTR 2
MOVX @DPTR, A ; Write data to Destination 2
INC DPTR ; Increment destination address 2
INC DPS ; Set DPS to point to DPTR1 2
DJNZ R2, LOOP ; Check if all done 3
Machine cycles in W77IE58 = 12 + (15 * CNT)
If CNT = 50
Clock cycles in W77IE58 = (12 + (15 * 50)) * 4 = (12 + 750) * 4 = 3048
We can see that in the first program the standard 8032 takes 15720 cycles, while the W77IE58 takes
only 5240 cycles for the same code. In the second program, written for the W77IE58, program
execution requires only 3048 clock cycles. If the size of the block is increased then the saving is even
greater.
External Data Memory Access Timing
The timing for the MOVX instruction is another feature of the W77IE58. In the standard 8032, the
MOVX instruction has a fixed execution time of 2 machine cycles. However in the W77IE58, the
duration of the access can be varied by the user.
The instruction starts off as a normal op-code fetch of 4 clocks. In the next machine cycle, the
W77IE58 puts out the address of the external Data Memory and the actual access occurs here. The
user can change the duration of this access time by setting the STRETCH value. The Clock Control
SFR (CKCON) has three bits that control the stretch value. These three bits are M2-0 (bits 2-0 of
CKCON). These three bits give the user 8 different access time options. The stretch can be varied
from 0 to 7, resulting in MOVX instructions that last from 2 to 9 machine cycles in length. Note that the
stretching of the instruction only results in the elongation of the MOVX instruction, as if the state of the
CPU was held for the desired period. There is no effect on any other instruction or its timing. By
default, the Stretch value is set at 1, giving a MOVX instruction of 3 machine cycles. If desired by the
user the stretch value can be set to 0 to give the fastest MOVX instruction of only 2 machine cycles.
W77IE58
- 42 -
Table 4. Data Memory Cycle Stretch Values
M2 M1 M0
MACHINE
CYCLES
RD OR WR STROBE
WIDTH IN CLOCKS
RD OR WR STROBE
WIDTH @ 25 MHZ
0 0 0 2 2 80 nS
0 0 1 3(default) 4 160 nS
0 1 0 4 8 320 nS
0 1 1 5 12 480 nS
1 0 0 6 16 640 nS
1 0 1 7 20 800 nS
1 1 0 8 24 960 nS
1 1 1 9 28 1120 nS
Next Instruction
Machine Cycle
Second
Machine cycle
First
Machine cycle
Last Cycle
of Previous
Instruction
C4
PORT 2
PORT 0
WR
PSEN
ALE
CLK
C3C2
D0-D7
A0-A7
D0-D7
A0-A7
D0-D7A0-A7
D0-D7
A15-A8
A15-A8A15-A8A15-A8
A0-A7
C1 C4C3C2C1 C4C3C2C1 C4C3C2C1
MOVX instruction cycle
Next Inst. Read
Next Inst.
Address
MOVX Data out
MOVX Data
Address
MOVX Inst.
Address
MOVX Inst
.
Figure 8. Data Memory Write with Stretch Value = 0

W77I058A25PL

Mfr. #:
Manufacturer:
Description:
IC MCU 8BIT 32KB FLASH 44PLCC
Lifecycle:
New from this manufacturer.
Delivery:
DHL FedEx Ups TNT EMS
Payment:
T/T Paypal Visa MoneyGram Western Union

Products related to this Datasheet