Hardware Reference
In-Depth Information
Assembly Instruction
Mnemonic
Machine
Code
Meaning
ld
ld
ld
and
bnz
inc
dbnz
addr, #val
ptr, #data16
A, @ptr
A, #val
addr, offset
addr
addr, offset
75
90
E0
54
70
05
D5
aa xx
yyyy
Load the 8-bit value (val) into memory location at addr.
Load the 16-bit value (data16) into the register ptr.
Load the contents of memory location pointed to by ptr into A.
And the 8-bit value (val) with A and leave the result in A.
Branch to a location that is offset from the next instruction if the value at addr is not zero.
Increment the contents of memory location at addr.
Decrement the contents of memory location at addr and branch if the result is not
zero. The branch distance is offset.
xx
zz
aa
aa
zz
Note:
aa: an 8-bit value that represent an 8-bit address.
xx: an 8-bit value.
yyyy: a 16-bit value.
zz: distance of branch from the first byte of the instruction after the branch instruction.
Machine codes are expressed in hex format.
Table 1.2 The instruction set of the processor X
1.6.4 Instruction Sequence Example
Assume that the following instruction sequence is stored in the program memory starting
from address 0 so that it will be executed immediately after a power-on or reset:
ld 0x20,#0 ; place 0 in data memory located at address 0x20
ld 0x21,#20 ; place 20 in data memory located at address 0x21
ld ptr,#0x2000 ; load 0x2000 into the register ptr
loop: ld A,@ptr ; load the memory contents pointed to by ptr into A
and A,#0x03 ; and the value 0x03 with A and leave the result in A
bnz next ; branch if the result in A is not 0
inc 0x20 ; increment the memory location at 0x20 by 1
next: dbnz 0x21,loop ; decrement the memory location at 0x21 and branch if
; the result is not 0
The corresponding machine code of the given instruction sequence is shown in Table 1.3.
The next section explains the process of instruction execution.
1.6.5 Instruction Execution Process
Processor X executes the instruction sequence given in Table 1.3 as follows:
Instruction ld 0x20,#0 (machine code 75 20 00)
When the processor comes out of a reset or power-on process, the program counter is
forced to 0 and this instruction will be fetched and executed. The execution of this instruction
involves the following steps:
Step 1
The value in the PC (0x0000) is placed on the address bus of the program memory with a
request to read the contents of that location.
 
Search WWH ::




Custom Search