Hardware Reference
In-Depth Information
Assembly Instruction
Mnemonic
Address
Machine Code
Comment
ld
ld
ld
ld
and
bnz
inc
dbnz
0x20,#0
0x21,#20
ptr,#0x2000
A,@ptr
A,#0x03
next
0x20
0x21,loop
0x0000
0x0003
0x0006
0x0009
0x000A
0x000C
0x000E
0x0010
75 20 00
75 21 14
90 20 00
E0
54 03
70 02
05 20
D5 21 0A
loop:
02 is the branch offset.
next:
0A is the branch offset.
Note:
1. The user uses a label to specify the instruction to branch to and the assembler needs to
figure out the branch offset.
2. The assembler figures out that the label next is 2 bytes away from the inc 0x20
instruction.
3. The assembler figures out that the label
is 10 (0A) bytes away from the first byte
after the “next: dbnz 0x21,loop” instruction.
loop
Table 1.3 The processor X instruction sequence to be executed
Step 2
The 8-bit value at the location 0x0000 is the instruction opcode 0x75. At the end of this
read cycle, the PC is incremented to 0x0001. The opcode byte 0x75 is fetched. Figure 1.5
shows the opcode read cycle.
Step 3
Control unit recognizes that this version of the ld instruction requires one read cycle
to fetch the direct address and another cycle to read the data operand. These 2 bytes are
stored immediately after the opcode byte. Two more read cycles to program memory are
performed to access the data memory address 0 x 20 (held in IR) and the value 0 x 00 (held in
IR). After these two read cycles, the PC is incremented to 0x0003.
Step 4
Control unit places 0x0020 on the data memory address bus and the value 0x00 on the
data memory data bus to perform a write operation. The value 0x00 is to be stored at data
memory location 0x0020, as shown in Figure 1.6.
Instruction ld 0x21,#20 (machine code 75 21 14)
The execution of this instruction is identical to that of the previous instruction. After the
execution of this instruction, the PC is incremented to 0x0006 and the data memory location
0x21 receives the value of 20.
Instruction ld ptr,#0x2000 (machine code 90 20 00)
Step 1
The value in the PC (0x0006) is placed on the program memory address bus with a request
to read the contents of that location.
Step 2
The 8-bit value at the location 0x0006 is the instruction opcode 0x90. At the end of this
read cycle, the PC is incremented to 0x0007. The opcode byte 0x90 is fetched. Figure 1.7
shows the opcode read cycle.
 
 
Search WWH ::




Custom Search