MCS51 Bit Manipulation
CLR C
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|--------------|-----------|----|----|-----|-----|----|---|---|
| 1 | 2 | CLR C | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | X | | | | | | | |
Clear Carry Flag or change the Carry Flag bit to 0.
CLR bit
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|--------------|-----------|----|----|-----|-----|----|---|---|
| 1 | 2 | CLR Bit | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Clear bits or change the bits in the Internal RAM or bit addressable registers to 0.
Example:
Clr P1.2
SETB C
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|--------------|-----------|----|----|-----|-----|----|---|---|
| 2 | 3 | SETB C | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | X | | | | | | | |
Set Carry Flag or change the Carry Flag bit to 1.
SETB bit
| Siklus | Jumlah Byte | | Instruksi | | | | | | |
|--------|--------------|---|-----------|----|-----|-----|----|---|---|
| 2 | 2 | | SETB bit | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Set bits or change bits in Internal RAM or bit addressable registers to 1.
Example:
Setb A.7
The 7th bit of accumulator A is changed to 1, if previously the value of accumulator A was 02H or 00000010b then after this instruction is executed, the value of accumulator A will be 82H or 10000010b.
CPL C
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|--------------|-----------|----|----|-----|-----|----|---|---|
| 2 | 2 | CPL C | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | X | | | | | | | |
Complementing the carry flag bit, if previously the carry flag bit was 0, then after this instruction is executed the carry flag bit will be in the set or 1 position and vice versa.
CPL bit
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|--------------|-----------|----|----|-----|-----|----|---|---|
| 1 | 1 | CPL bit | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Performs complement on bits in a register or memory that can be addressed bit by bit. If previously the bit in the memory or register was 0, then after this instruction is executed, the bit in the memory or register will be in the set or 1 position and vice versa.
ANL C,bit
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|--------------|-----------|----|----|-----|-----|----|---|---|
| 2 | 2 | ANL C,bit | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | X | | | | | | | |
Performs an AND operation between the carry flag bit and a bit in a bit-addressable register or memory.
ANL C,/bit
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|--------------|------------|----|----|-----|-----|----|---|---|
| 2 | 2 | ANL C,/bit | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | X | | | | | | | |
Performs an AND operation between the carry flag bit and the complement of a bit in a bit-addressable register or memory.
Example:
ANL C,/A.7
If previously the carry flag bit was 0 and the value of accumulator A was 80H or 10000000b, then the 0 in the carry flag bit will be ANDed with the 1 in the seventh bit of accumulator A and produce 0. The result of this AND is stored in the carry flag bit, so that the value of the carry flag after this instruction is executed remains 0.
ORL C,bit
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|--------------|------------|----|----|-----|-----|----|---|---|
| 2 | 2 | ORL C,/bit | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | X | | | | | | | |
Performs an OR operation between the carry flag bit and the complement of a bit in a bit-addressable register or memory.
Example:
ORL C,/A.7
If previously the carry flag bit was 0 and the value of accumulator A was 80H or 10000000b, then the 0 in the carry flag bit will be ORed with the 1 in the seventh bit of accumulator A and produce 0. The result of this OR is stored in the carry flag bit, so the value of the carry flag after this instruction is executed remains 0.
MOV C,bit
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|--------------|-----------|----|----|-----|-----|----|---|---|
| 1 | 2 | MOV C,bit | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Performs a transfer from a bit in a register or memory that can be addressed bit by bit (bit addressable) to the carry flag bit.
Example:
Mov C,A.0
If the value of accumulator A is 01H or 00000001 then bit 0 of accumulator A, namely 0, will be moved to the carry flag bit so that the value of this bit is 0.
MOV bit,C
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|--------------|-----------|----|----|-----|-----|----|---|---|
| 2 | 2 | MOV bit,C | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Transferring from the carry flag bit to a bit in a register or memory that can be addressed bit by bit (bit addressable).
Example:
Mov A.1,C
If the value of accumulator A is 01H or 00000001b and the value of the carry flag bit is 1 or set, then the value 1 in the carry flag bit will be moved to bit 1 of accumulator A, so that the value of accumulator A will change to 03H or 00000011b.
JC rel
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|--------------|-----------|----|----|-----|-----|----|---|---|
| 2 | 2 | JC rel | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Jump to a defined address when the carry flag is set. If the carry flag is clear, the program will execute the next instruction.
Example:
Jc Alamat1
Mov A,#05H
Address1:
Mov R1,#00H
If the carry flag is set, the program will jump to address label 1 and execute the Mov R1,#00H instruction, but if the carry flag is clear, the program will execute the Mov A,#05H instruction first before executing the instruction at address label 1.
JNC rail
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|--------------|-----------|----|----|-----|-----|----|---|---|
| 2 | 2 | JNC rel | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Jump to a defined address when the carry flag is clear. If the carry flag is set, the program will execute the next instruction.
Example:
Jnc Alamat1
Mov A,#05H
Address1:
Mov R1,#00H
If the carry flag is clear, the program will jump to address label 1 and execute the Mov R1,#00H instruction, but if the carry flag is set, the program will execute the Mov A,#05H instruction first before executing the instruction at address label 1.
JB bit,rel
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|--------------|------------|----|----|-----|-----|----|---|---|
| 2 | 3 | JB bit,rel | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Jump to a defined address when a bit of a register or memory that can be addressed bitwise (bit addressable) is set. If the bit is clear, the program will execute the next instruction.
Example:
Jb P1.0,Alamat1
Mov A,#05H
Address1:
Mov R1,#00H
If the bit is set, the program will jump to address label 1 and execute the Mov R1,#00H instruction, but if the bit is clear, the program will execute the Mov A,#05H instruction first before executing the instruction at address label 1.
JNB bit,rel
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|--------------|-------------|----|----|-----|-----|----|---|---|
| 2 | 3 | JNB bit,rel | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Jump to a defined address when a bit of a register or memory that can be addressed bitwise (bit addressable) is clear. If the bit is set, the program will execute the next instruction.
Example:
JNB P1.0,Alamat1
Mov A,#05H
Address1:
Mov R1,#00H
If the bit is clear, the program will jump to address label 1 and execute the Mov R1,#00H instruction, but if the bit is set, the program will execute the Mov A,#05H instruction first before executing the instruction at address label 1.
JBC bit,rel
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|-------------|-------------|----|----|-----|-----|----|---|---|
| 2 | 3 | JBC bit,rel | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Same as the Jb bit,rel instruction, but there is a clear process on the bit after the jump is performed.
Example:
JBC A.7,Alamat1
If the seventh bit of accumulator A is set, then jump to address 1 and simultaneously change the condition of the seventh bit of accumulator A to clear.
Assembly Program Outputs Binary Data to Port
Assembly Program Outputs Binary Data to Port
$mod51
;------------------------------------
; MENGELUARKAN DATA BINER KE PORT 1
;------------------------------------
Main:
MOV P1,#00000001B ; Port 0 sebagai Output dan diisi 1 pada bit 0
LCALL DELAY500MS
MOV P1,#00000010B ; Port 0 sebagai Output dan diisi 1 pada bit 1
LCALL DELAY500MS
MOV P1,#00000100B ; Port 0 sebagai Output dan diisi 1 pada bit 2
LCALL DELAY500MS
MOV P1,#00001000B ; Port 0 sebagai Output dan diisi 1 pada bit 3
LCALL DELAY500MS
MOV P1,#00010000B ; Port 0 sebagai Output dan diisi 1 pada bit 4
LCALL DELAY500MS
MOV P1,#00100000B ; Port 0 sebagai Output dan diisi 1 pada bit 5
LCALL DELAY500MS
MOV P1,#01000000B ; Port 0 sebagai Output dan diisi 1 pada bit 6
LCALL DELAY500MS
MOV P1,#10000000B ; Port 0 sebagai Output dan diisi 1 pada bit 7
LCALL DELAY500MS
SJMP Main ; Kembali ke Main
;---------------
; delay 500 ms
;---------------
DELAY500MS:
PUSH ACC
PUSH 00H
MOV A,#032H ; 500 milli second
X10MS: CALL DELAY10MS
DJNZ ACC,X10MS
POP 00H
POP ACC
RET
;-------------
; DELAY 10 ms
;-------------
DELAY10MS:
PUSH ACC
PUSH 00H
MOV 00H,#050H
D10MS1: MOV A,#0C8H
DJNZ ACC,$
DJNZ R0,D10MS1
POP 00H
POP ACC
RET
END
Hope this is useful & happy learning!
Temperature Control Assembly Program
Assembly Control Program Temperature / Temperature
Part 1
org 0h
hundreds equ 30h
tens equ 31h
ones equ 32h
start: call ADC
call Bin2Dec
call Display2SevenSegmen
sjmp start
;
;=================================================
;this subroutine is used to take data from ADC and
;keep to Accumulator;=================================================
ADC: mov A,P0
nop
nop
ret
;
;========================================================
;this subroutine is used to convert binary data from ADC
;become decimal 3 digit
;========================================================
Bin2Dec: mov b,#100d
div ab
mov hundreds,a
mov a,b
mov b,#10d
div ab
mov tens,a
mov ones,b
ret
;===============================================
;this subroutine is used to convert data ADC to
;8 x 7 segmen
;===============================================
Display2SevenSegmen:
Mov P2,#11111111b
mov A, Hundreds
mov DPTR,#Data7segmen
movc A,@A+DPTR
mov P0,A
clr P1.5
call delay
;
mov A,tens
mov DPTR,#Data7segmen
movc A,@A+DPTR
setb P1.5
mov P0,A
clr P2.6
call delay
;
mov A,ones
mov DPTR,#Data7segmen
movc A,@A+DPTR
setb P1.6
mov P0,A
clr P2.7
call delay
ret
;
delay: mov R0,#0
delay1: mov R2,#0fh
djnz R2,$
djnz R0,delay1
ret
;
Data7segmen: db 11000000b,11111001b,10100100b,10110000b,10011001b
db 10010010b,10000010b,11111000b,10000000b,10010000b
end
Part 2
org 0h
ratusan equ 30h
puluhan equ 31h
satuan equ 32h
start: call ADC
call Bin2Dec
call Display2SevenSegmen
sjmp start
;
;=================================================
;this subroutine is used to take data from ADC and
;keep to Accumulator
;=================================================
ADC: mov A,P1
nop
nop
ret
;
;========================================================
;this subroutine is used to convert binary data from ADC
;become decimal 3 digit
;========================================================
Bin2Dec:
mov b,#100d
div ab
mov ratusan,a
mov a,b
mov b,#10d
div ab
mov puluhan,a
mov satuan,b
ret
;
;===============================================
;this subroutine is used to convert data ADC to
;8 x 7 segmen
;===============================================
Display2SevenSegmen:
;Mov P2,#11111111b
mov A, ratusan
mov DPTR,#Data7segmen
movc A,@A+DPTR
setb P3.2
mov P2,A
clr P3.0
call delay
;
mov A,puluhan
mov DPTR,#Data7segmen
movc A,@A+DPTR
setb P3.0
mov P2,A
clr P3.1
call delay
;
mov A,satuan
mov DPTR,#Data7segmen
movc A,@A+DPTR
setb P3.1
mov P2,A
clr P3.2
call delay
ret
;
delay: mov R0,#0
delay1: mov R2,#01h
djnz R2,$
djnz R0,delay1
ret
;
Data7segmen:
db 00111111b,00000110b,01011011b,01001111b,01100110b
db 01101101b,01111101b,00000111b,01111111b,01101111b
end
Part 3
org 0h
ratusan equ 30h
puluhan equ 31h
satuan equ 32h
;=============
;Program Utama
;=============
start: call ADC
call Bin2Dec
call Tampil
sjmp start
;===========
; Fungsi ADC
;===========
ADC: mov A,P3
nop
nop
ret
;=========================
;Pengubah ke digit desimal
;=========================
Bin2Dec:mov b,#100d
div ab
mov ratusan,a
mov a,b
mov b,#10d
div ab
mov puluhan,a
mov satuan,b
ret
;======================
;tampilkan ke 7-segment
;======================
Tampil: Mov P2,#11111111b
mov A, ratusan
mov DPTR,#Data7segmen
movc A,@A+DPTR
mov P0,A
clr P2.7
call delay
mov A,puluhan
mov DPTR,#Data7segmen
movc A,@A+DPTR
setb P2.7
mov P0,A
clr P2.6
call delay
mov A,satuan
mov DPTR,#Data7segmen
movc A,@A+DPTR
setb P2.6
mov P0,A
clr P2.5
call delay
setb P2.5
mov P0,#10011100b
clr P2.4
call delay
setb P2.4
mov P0,#1000110b
clr P2.3
call delay
ret
;======
;Tunda
;======
delay: mov R0,#0
delay1: mov R2,#0fh
djnz R2,$
djnz R0,delay1
ret
Data7segmen: db 11000000b,11111001b,10100100b,10110000b,10011001b
db 10010010b,10000010b,11111000b,10000000b,10010000b
end
Hope this is useful & happy learning!
Assembly Programming Editor & Compiler Software
1. Compiler MIDE Studio
M-IDE Studio is one of the ways used to run compilation for MCS-51 devices. M-IDE Studio has several features that can be used to edit, compile, and debug files.
The M-IDE Studio can also be used to write programs in C language. By using this software, we can see errors in the LST file report.
Figure 1.19. M-IDE Studio
If you look at the toolbar menu and the options menu, it looks disabled. This is because the file has not been created. To create a file, do the following steps:
1. Create a New File
To create a new file, click on the File menu or shortcut as shown in the image, so that a blank page will appear.
Figure 1.20. New file with blank page
2. Write a program
Write the assembly program on a blank page, and save the file. When the file has been saved, the colorful instruction text will appear. As shown in Figure 3.
Figure 1.21 File storage menu
3. Compilation
In order for the file with the ASM extension to be loaded into the microcontroller, it is necessary to compile the ASM file to HEX.
Figure 1.22 Compiling files
4. Debug
Figure 1.23 Debug file
2. ATMEL Microcontroller ISP Software
Download: http://www.atmel.com/
Atmel Microcontroller ISP Software is the primary means of performing in-system programming (ISP) for Atmel devices. It provides an intuitive interface for in-system programming that can be run from your personal computer. Atmel ISP Software has a feature set that allows you to view, program, and erase data from Atmel ISP devices.
Figure 1 - Atmel Microcontroller ISP Software
Atmel Microcontroller ISP Software also allows you to load a hex file containing the code you want to add to the device. Using the software, you can manipulate this code, verify it with the code on the device, and program the code into the device.
You will notice that most of the toolbar buttons and menu options are disabled. This is because the device is not selected. To select a device, do the following:
- Make sure the board is connected to your computer's LPT port with an Atmel ISP cable and that the board is powered on.
- Select the LPT port connected to the board by choosing Select Port from the Options menu (you can also press the select port toolbar button).
Figure 2 - Port Select Dialog
- You can then select the device by choosing Select Device from the Options menu or by clicking on the toolbar. You should see a dialog box similar to the one in Figure 3.
Figure 3 - Device Select Dialog
- Select the device you want to program from the tree control by clicking on the desired device.
- Next select whether you want to read and write from the device in page mode (read/write a page at a time) or in byte mode (read/write byte by byte).
- Enter the external clock frequency (MHz) assigned to the device in the text box.
- Select OK.
Once you have finished selecting the device, you will see one or two windows appear depending on whether the device has internal data memory or not. The window(s) will look something like Figure 4. Each window represents a buffer. There are two types of buffers, code buffers and data buffers. The code buffer corresponds to the chip's programmable flash memory and the data buffer corresponds to the chip's internal data memory.
Figure 4 - Buffer Window
Once you have determined whether the device is programmable or not, it is time to load the program you wish to encode onto the chip into the software. The Atmel Microcontroller ISP Programming software can be loaded into a program that is in the Intel Hex file format.
To load in a program from disk:
- Select Load Buffer from the File menu or click on the toolbar. You will see a dialog similar to Figure 4.
Figure 5. Load Buffer Dialog
- Select the HEX file containing the program you want to encode to the chip and click Open.
File 6. Open file Hex dialog
- The buffers will then be updated with the hex contents.
Figure 7. Update buffer data
4. Initialize Target
Initialization Command Sets the device to programming mode. This is required when swapping devices after selecting the device in Atmel ISP Software. Also, it is required when setting up the device from run mode. This command can also be activated by clicking on the toolbar.
Figure 8. Initialiazed Device
5. Programming the Device
Once the program is loaded into the buffer, the easiest way to program the device is to select Auto Program from the Instructions menu (you can also press the toolbar). Auto Program performs all the most common tasks when programming the device.
Figure 9. Auto Programming sub menu
Automatic programming performs the following commands:
- Removing a device
- Writing buffer to device
- Checking the programmed device with buffer contents
- Prompts user for lockbit settings (if supported by device)
- Prompts user for fusebit settings (if supported by device)
After selecting Auto Program you will see a progress dialog similar to the one shown in Figure 10.
Figure 10 Progress Dialog
6. Lockbit Settings
The Lockbit Settings command allows the user to set the lockbit protection mode for the current device. A dialog box, similar to Figure 11, showing the protection modes supported by the current device is displayed to the user. After selecting a protection mode, the software sets the device to the specified mode.
Figure 11. Lockbit Manager Dialog
Figure 12. Auto Programming Dialog
7. Run Target
The Run Target command removes the device from programming mode and sets it to the run state. When the device is in this state, programming commands cannot be sent to the device. Most commands in the Atmel ISP Software are disabled during this state. To return to the programming state, the Initialize Target command must be executed.
Figure 13. Run Target Instruction
8. Troubleshooting
This section covers some common problems you may encounter while using the software and what to do when you encounter them. The program reports that the device is locked even after the Chip Erase command has been run. The software is most likely having difficulty communicating with the device. Check the cable connections and make sure the device is on. Then run the Initialize Target command from the Options menu.
Figure 14. Error according to device error
The program reports a write failure when trying to write the buffer to the chip. This usually occurs when the XTAL frequency is not set to the correct value in software. To set the XTAL choose Select Device from the Options menu and enter the correct XTAL frequency that is being used by the device. Then run the Initialize Target command from the Options menu.
The software reports "...Atmel ISP Cable is not connected..." but the cable and device appear to be connected properly. Make sure the correct port is selected in the software. This is done by selecting Select Port from the Options menu.
Figure 15. Error according to cable connection.
ADD, SUB & Logical Operations
| SMKN 2 YOGYAKARTA | Kompetensi | Kode : 07/PDTM/KL10/SR |
|-----------------------------------|------------------------------------|-----------------------------------|
| Prog. Keahlian : Tek. Audio Video | OPERASI ADD, SUB DAN OPERASI LOGIK | Waktu : menit |
| Prog. Diklat : PDTM | | Nama Siswa : |
| Kelas : 10 AV | | Tanggal : |
ADD, SUB and Logical Operations
Performance Criteria:
- Performing addition operations (Adder) with a microprocessor.
- Performing subtraction operations with a microprocessor.
- Knowing the logical operations that exist in microprocessors
- Perform logical operations AND, OR and XOR with a microprocessor.
Adder Operation (ADD)
Adder/Adder is an operation used to add two hexadecimal data that are in a register with a register or data in a register with data in memory. The requirement to add two hexadecimal data is that one of the data must be in the Accumulator, while the other data is in one of the registers. The result of adding the two data is in the Accumulator.
Format : ADD r
Dimana ADD : perintah tambahkan Accumulator
r : nama register
Example:
- In register C, data 21 H is stored and in register L, data 12 H is stored.
- Add the data in register C with the data in register L.
Answer:
Program Structure,
| Mengisi register C dengan data 21 |
|---------------------------------------------------------|
| Mengisi register L dengan data 12 |
| Pindahkan ke Accumulator data dari register C |
| Tambahkan data di Accumulator dengan data di register L |
| Akhir program |
Program,
| Alamat Memori | Bahasa | | Keterangan |
|---------------|----------|---------|---------------------------------------------------------|
| | Assembly | Mesin | |
| 1800 | LD C,21 | 0E 21 | Mengisi register C dengan data 21 |
| 1802 | LD L,12 | 2E 12 | Mengisi register L dengan data 12 |
| 1804 | LD A,C | 79 | Pindahkan ke Accumulator data dari register C |
| 1805 | ADD L | 85 | Tambahkan data di Accumulator dengan data di register L |
| 1806 | RST 0038 | FF | Akhir program |
Run the program by pressing the RST-PC-GO buttons. View the results by pressing the REG button followed by the register name.
Results:
- Register C = ......
- Register L = ......
- Accumulator = ......
Subtractor Operation (SUB)
The SUB/subtraction operation is used to subtract two hexadecimal data in a register with a register or data in a register with data in memory. The requirement for the subtraction operation of two hexadecimal data is that the subtracted data must be in the Accumulator, while the subtracted data must be in one of the registers. The results of the operation are stored in the Accumulator.
Format : ADD r
Dimana SUB : perintah kurangi Accumulator
r : nama register
Example: In register D is stored data 0E hexadecimal, in register E is stored data 05 hexadecimal. Subtract the data in register D with the data in register E. Store the result of the operation in register H.
Answer:
Program Structure,
| Mengisi register D dengan data 0E |
|-------------------------------------------------------|
| Mengisi register E dengan data 05 |
| Pindahkan ke Accumulator data dari register D |
| Kurangi data di Accumulator dengan data di register E |
| Pindahkan/copy ke register H data dari Accumulator |
| Akhir program |
Program,
| Alamat Memori | Bahasa | | Keterangan |
|---------------|----------|---------|-------------------------------------------------------|
| | Assembly | Mesin | |
| 1800 | LD D,0E | 16 0E | Mengisi register D dengan data 0E |
| 1802 | LD E,05 | 1E 05 | Mengisi register E dengan data 05 |
| 1804 | LD A,D | 7A | Pindahkan ke Accumulator data dari register D |
| 1805 | SUB E | 93 | Kurangi data di Accumulator dengan data di register E |
| 1806 | LD H,A | 67 | Pindahkan/copy ke register H data dari Accumulator |
| 1807 | RST 0038 | FF | Akhir program |
Run the program by pressing the RST-PC-GO buttons. View the results by pressing the REG button followed by the register name.
Results:
- Register D = ......
- Register E = ......
- Accumulator = ......
- Register H = ......
Notes
For adder (ADD) or subtractor (SUB) operations whose data is taken from a memory address, the memory address is designated using the HL register pair. So to run an Adder (ADD) or subtractor (SUB) operation is:
ADD (HL) : tambahkan Accumulator dengan data pada alamat memori yang ditunjuk oleh pasangan registr HL
SUB (HL) : kurangi Accumulator dengan data pada alamat memori yang ditunjuk oleh pasangan registr HL.
Logical Operations AND, OR and XOR
The logical operations owned by the microprocessor are AND, OR and XOR logical operations, where each of these three logical operations has its own function, namely:
AND operation: is a logical operation where if one of the bits of the input of two hexadecimal data is logical 0, then the result of the operation is logical 0.
Accumulator = DF : 10111111
Register H = 0F : 00001111
-------------------------------------- AND
Accumulator = 0F : 00001111
Format : AND r
Dimana AND: perintah AND-kan Accumulator
r : nama register
OR operation: is a logical operation where if one of the bits of the input of two hexadecimal data is logical 1, then the result of the operation is logical 1.
Accumulator = DF : 10111111
Register H = 0F : 00001111
-------------------------------------- OR
Accumulator = DF : 10111111
Format : OR r
Dimana OR : perintah OR-kan Accumulator
r : nama register
XOR operation: is a logical operation where if the input of two hexadecimal data has the same logical bits, then the result of the operation is logical 0.
Accumulator = DF : 10111111
Register H = 0F : 00001111
-------------------------------------- XOR
Accumulator = D0 : 10110000
Format : XOR r
Dimana XOR: perintah XOR-kan Accumulator
r : nama register
Task:
1. Create a Z-80 microprocessor program to fill the H register with data 03 H, register E stores data 02 H. Data 05 H is stored at address 1A00.
- add the data at address 1A00 to the data in register E.
- add the data in register H with the result of the addition above (question a).
2. In the Accu, data 26 H is stored, in register B, data 06 H is stored, in register pair DE, data 0320 H is stored.
- add the data in register B with the data in register D.
- subtract the data in Accu from the data in register E.
- Subtract the answer to question a from the answer to question b.
3. At memory address 1C00 is stored data 62 H.
- OR the data at memory address 1C00 with the Hexadecimal data 8C, store the result at memory address 1C01.
- AND the result of the operation on question a with the BA Hexadecimal data, save the result at memory address 1C02.
- XOR the result of the operation on question b with the Hexadecimal AA data, save the result at memory address 1C03.
INC, DEC & JUMP Operations
| SMKN 2 YOGYAKARTA | Kompetensi | Kode : 06/PDTM/KL10/SR |
|-----------------------------------|---------------------------|-----------------------------------|
| Prog. Keahlian : Tek. Audio Video | OPERASI INC, DEC DAN JUMP | Waktu : menit |
| Prog. Diklat : PDTM | | Nama Siswa : |
| Kelas : 10 AV | | Tanggal : |
INC, DEC and JUMP operations
Performance Criteria:
- Performs an increment by one (INC : Increment) on the register.
- Performs a decrement by one (DEC : Decrement) on a register.
- Performs a calculated process iteration.
- Repeat the process continuously.
1. Increment Operation (INC)
Increment operation is an operation used to raise one level or add one value to a number in a register. If a register is run with INC operation, then the value of the number in the register will increase one level or increase by one.
Format : INC r
Dimana INC : perintah tambah dengan satu
r : nama register
Example:
- In the Accumulator, the data 00 H is stored and in register B, the data FF H is stored.
- Perform INC operation on accumulator and register B.
Answer:
Program structure,
| Masukkan data 00 H pada accumulator |
|------------------------------------------|
| Masukkan data FF H pada register B |
| Tambah dengan satu data pada accumulator |
| Tambah dengan satu data pada register B |
| Akhir program |
Program,
| Alamat Memori | Bahasa | | Keterangan |
|---------------|----------|-------|------------------------------------------|
| | Assembly | Mesin | |
| 1800 | LD A,00 | 3E 00 | Mengisi Accumulator dengan data 00 H |
| 1802 | LD B,FF | 06 FF | Mengisi register B dengan data FF H |
| 1804 | INC A | 3C | Tambah dengan satu data pada accumulator |
| 1805 | INC B | 04 | Tambah dengan satu data pada register B |
| 1807 | RST 0038 | FF | Akhir program |
Results:
- Accumulator = 01 H
- Register B = 00 H.
2. Decrement Operation (DEC)
Decrement operation is an operation used to lower one level or reduce by one the value of a number in a register. If a register is run with DEC operation, then the value of the number in the register will decrease one level or decrease by one.
Format : DEC r
Dimana INC : perintah kurangi dengan satu
r : nama register
Example:
- In the Accumulator, the data 00 H is stored and in register B, the data FF H is stored.
- Perform DEC operations on the accumulator and register B.
Answer:
Program structure,
| Masukkan data 00 H pada accumulator |
|-------------------------------------------|
| Masukkan data FF H pada register B |
| Kurangi dengan satu data pada accumulator |
| Kurangi dengan satu data pada register B |
| Akhir program |
Program,
| Alamat Memori | Bahasa | | Keterangan |
|---------------|----------|-------|-------------------------------------------|
| | Assembly | Mesin | |
| 1800 | LD A,00 | 3E 00 | Mengisi Accumulator dengan data 00 H |
| 1802 | LD B,FF | 06 FF | Mengisi register B dengan data FF H |
| 1804 | DEC A | 3D | Kurangi dengan satu data pada accumulator |
| 1805 | DEC B | 05 | Kurangi dengan satu data pada register B |
| 1807 | RST 0038 | FF | Akhir program |
Results:
- Accumulator = FF H
- Register B = FE H
3. JUMP Operation
JUMP operation is an operation used to jump to a memory address if a requirement has been met. The requirements for jumping are:
- a) UNC: UnConditional (without conditions). Where every time there is a UNC JUMP operation, the Z-80 microprocessor will execute a jump to the designated address.
- b) NZ: Not Zero (condition is not zero). The jump operation will be executed if the condition is still not zero.
- c) Z: Zero (condition has a value of zero). The jump operation will be executed if the condition has a value of zero (0).
- d) NC: Not Carry (Carry = 0). The skip operation will be executed if the carry is zero (no Carry).
- e) C: Carry ( Carry = 1). The jump operation will be performed if carry is equal to one.
Example: In register A, the data 0F H is stored and in register H, the data F0 H is stored.
Task:
- Perform the DEC (minus 1) operation on register A 15 times.
- Perform the INC operation (add 1) on the H register 3 times.
Answer:
Program structure (Method 1),
| Isi register A dengan data 0F H | |
|---------------------------------|---------------------------------|
| Isi register H dengan data F0 H | |
| Isi register D dengan data 0F H | |
| | D=0 |
| | Kurangi dengan 1 isi register A |
| | Kurang dengan 1 isi register D |
| Isi register D dengan data 03 | |
| | D=0 |
| | Tambah dengan 1 isi register H |
| | Kurangi dengan 1 isi register D |
| Akhir program | |
Program (Method 1),
| Alamat Memori | Bahasa | | Keterangan |
|---------------|------------|----------|----------------------------------------|
| | Assembly | Mesin | |
| 1800 | LD A,0F | 3E 0F | Mengisi Accumulator dengan data 0F H |
| 1802 | LD H,F0 | 26 F0 | Mengisi register H dengan data F0 H |
| 1804 | LD D,0F | 16 F0 | Isi register D dengan data F0 H |
| 1806 | NOP | 00 | Tidak ada operasi |
| 1807 | DEC A | 3D | Kurangi dengan 1 data pada accumulator |
| 1808 | DEC D | 15 | Kurangi dengan 1 data pada register D |
| 1809 | JP NZ 1806 | C2 06 18 | Loncat bersyarat ke alamat 1806 |
| 180C | LD D,03 | 16 03 | Isi register D dengan data 03 H |
| 180E | NOP | 00 | Tidak ada operasi |
| 180F | INC H | 24 | Tambah dengan 1 data pada register H |
| 1810 | DEC D | 15 | Kurangi dengan 1 data pada register D |
| 1811 | JP NZ 180E | C2 0E 18 | Loncat bersyarat ke alamat 180E |
| 1814 | RST 0038 | FF | Akhir program |
Run the program, Accumulator = ............ Redister H = ............
Program structure (Method 2),
| Isi register A dengan data 0F H | | |
|---------------------------------|---------------------------------|--------------------------------|
| Isi register H dengan data F0 H | | |
| Isi register D dengan data 03 H | | |
| | D=0 | |
| | Tambah dengan 1 isi register H | |
| | Isi register E dengan data 05 H | |
| | | E=0 |
| | | Kurang dengan 1 isi register A |
| | | Kurang dengan 1 isi register E |
| | Kurang dengan 1 isi register D | |
| Akhir program | | |
Program (Method 2),
| Alamat Memori | Bahasa | | Keterangan |
|---------------|------------|----------|---------------------------------------|
| | Assembly | Mesin | |
| 1800 | LD A,0F | 3E 0F | Mengisi Accumulator dengan data 0F H |
| 1802 | LD H,F0 | 26 F0 | Mengisi register H dengan data F0 H |
| 1804 | LD D,03 | 16 03 | Mengisi register D dengan data 03 H |
| 1806 | NOP | 00 | Tidak ada operasi |
| 1807 | INC H | 24 | Tambah dengan 1 data pada register H |
| 1808 | LD E,05 | 1E 05 | Mengisi register E dengan data 05 H |
| 180A | NOP | 00 | Tidak ada operasi |
| 180B | DEC A | 3D | Mengisi register D dengan data 03 H |
| 180C | DEC E | 1D | Tidak ada operasi |
| 180D | JP NZ 18 | C2 0A 18 | Loncat bersyarat ke alamat 1809 |
| 1810 | DEC D | 15 | Kurangi dengan 1 data pada register D |
| 1811 | JP NZ 1806 | C2 06 18 | Loncat bersyarat ke alamat 180E |
| 1804 | RST 0038 | FF | Akhir program |
Run the program, Accumulator = ............ Redister H = ............
Task
1. It is known that the contents of register B = 00 H, register C = 02 H and register D = 25 H.
- Add the contents of register B to the contents of register C 15 times.
- Add 1 contents of register D 15 times.
2. Fill the Accumulator with data 05 H and at address 1B00 contain data 05 H.
- Add 1 battery charge 3 times.
- Add 1 to the address 1B00 24 times.
3. It is known that the contents of the Accumulator = FF H, the contents of register B = 00 H
- Reduce by 1 battery charge by 15 times.
- Add 1 to the contents of register B 30 times.
XRL Logic Operations
Performs an EXOR operation between two variables and stores it in the destination variable. If the destination variable is an accumulator, then the other variable can use a register (Rn), direct address, indirect address or immediate data, if the destination variable is a direct address, then the other variable can use an accumulator or immediate data.
XRL A,Rn
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|-------------|-----------|----|----|-----|-----|----|---|---|
| 1 | 1 | XRL A,Rn | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Performs an EXOR operation between accumulator A and Rn (R0...R7) and the result is stored in accumulator A.
XRL A,direct
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|-------------|--------------|----|----|-----|-----|----|---|---|
| 1 | 2 | XRL A,direct | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Performs an EXOR operation between accumulator A and the immediate address and the result is stored in accumulator A.
Example:
XRL A,05H
Accumulator A is EXORed with the data at address 05H and the result is stored in accumulator A.
XRL A,@Ri
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|-------------|-----------|----|----|-----|-----|----|---|---|
| 1 | 1 | XRL A,@Ri | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Performs an EXOR operation between accumulator A and the data pointed to by the Index Register (R0 or R1) and the result is stored in accumulator A.
Example:
XRL A,@R0
Accumulator A is EXORed with the data pointed to by R0, for example R0 contains 50H, then accumulator A is EXORed with the data stored at address 50H and the result is stored in accumulator A.
XRL A,#data
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|-------------|-------------|----|----|-----|-----|----|---|---|
| 1 | 2 | XRL A,#data | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Performs an EXOR operation between accumulator A and the data pointed to by the Index Register (R0 or R1) and the result is stored in accumulator A.
Example:
XRL A,@R0
Accumulator A is EXORed with the data pointed to by R0, for example R0 contains 50H, then accumulator A is EXORed with the data stored at address 50H and the result is stored in accumulator A.
XRL direct,A
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|-------------|--------------|----|----|-----|-----|----|---|---|
| 1 | 2 | XRL direct,A | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Performs an OR operation between the direct address and accumulator A and the result is stored at the direct address.
Example:
ORL 07H,A
The data at address 07H is ORed with accumulator A and the result is stored again at address 07H.
XRL direct,#data
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|-------------|------------------|----|----|-----|-----|----|---|---|
| 2 | 3 | XRL direct,#data | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Performs an EXOR operation between the immediate address and the immediate data and stores the result at the immediate address.
Transfer Data MOV
Performs data transfer from the variable in the second operation code and stores it in the variable in the first operation code.
Transfer Data MCS51
MOV A,Rn
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|-------------|-----------|----|----|-----|-----|----|---|---|
| 1 | 1 | Mov A,Rn | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Transferring data from Rn (R0...R7) to accumulator A
MOV A,direct
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|-------------|--------------|----|----|-----|-----|----|---|---|
| 1 | 2 | Mov A,direct | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Perform data transfer from direct address to accumulator A.
MOVE A,@Ri
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|-------------|-----------|----|----|-----|-----|----|---|---|
| 1 | 1 | Mov A,@Ri | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Performs data transfer from the address indicated by the Index Register (R0 or R1) to accumulator A.
MOV A,#data
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|-------------|-------------|----|----|-----|-----|----|---|---|
| 1 | 2 | Mov A,#data | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Perform data transfer from immediate to accumulator A.
Example:
Data EQU 05H
Mov A,#Data
The Data constant declared as 05H is moved to accumulator A so that the value of accumulator A becomes 05H.
MOV Rn,A
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|-------------|-----------|----|----|-----|-----|----|---|---|
| 1 | 1 | Mov Rn,A | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Transferring data from accumulator A to Rn (R0...R7).
MOV Rn,direct
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|--------------|---------------|----|----|-----|-----|----|---|---|
| 2 | 2 | Mov Rn,direct | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Perform data transfer from direct address to Rn (R0...R7).
Example:
Mov R7,10H
The data at address 10H is moved into R7.
MOV Rn,#data
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|-------------|--------------|----|----|-----|-----|----|---|---|
| 1 | 2 | Mov Rn,#data | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Perform data transfer from immediate to Rn (R0...R7).
Example:
Mov R7,#05H
Data 05H is moved into R7.
MOV direct,A
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|-------------|--------------|----|----|-----|-----|----|---|---|
| 1 | 2 | Mov direct,A | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Perform data transfer from accumulator A to the direct address.
Example:
Mov 10H,A
The data in accumulator A is moved to address 10H.
MOV direct,Rn
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|-------------|---------------|----|----|-----|-----|----|---|---|
| 2 | 2 | Mov direct,Rn | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Perform data transfer from Rn (R0...R7) to the direct address.
MOV direct,direct
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|-------------|-------------------|----|----|-----|-----|----|---|---|
| 2 | 3 | Mov direct,direct | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Perform data transfer from a direct address to a direct address.
Example:
Mov P1,P2
P1 is the register located at address 90H and P2 is the register located at address A0H, therefore the above instruction is the same as Mov 90H,0A0H. That is, the data at address 90H or Port 1, is moved to address 0A0H or Port 2.
MOV direct,@Ri
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|-------------|----------------|----|----|-----|-----|----|---|---|
| 2 | 2 | Mov direct,@Ri | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Performs data transfer from the address designated by the Register Index (R0 or R1) to the direct address.
Example:
Mov 05H,@R0
If R0 previously contained 20H, then the value or data stored at address 20H will be moved to address 05H.
MOV direct,#data
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|-------------|------------------|----|----|-----|-----|----|---|---|
| 2 | 3 | Mov direct,#data | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Perform data transfer from immediate to direct address.
MOV @Ri,A
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|--------------|-----------|----|----|-----|-----|----|---|---|
| 1 | 1 | Mov @Ri,A | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Transferring data from accumulator A to the address indicated by the Index Register (R0 or R1).
MOV @Ri,direct
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|--------------|----------------|----|----|-----|-----|----|---|---|
| 2 | 2 | Mov @Ri,direct | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Performs data transfer from the direct address to the address designated by the Register Index (R0 or R1).
MOV @Ri,#data
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|--------------|---------------|----|----|-----|-----|----|---|---|
| 1 | 2 | Mov @Ri,#data | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Performs immediate data transfer to the address designated by Register Index (R0 or R1).
MOV DPTR,#data16
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|--------------|------------------|----|----|-----|-----|----|---|---|
| 2 | 3 | Mov DPTR,#data16 | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Performs immediate 16 bit data transfer to DPTR.
Example:
Mov DPTR,#2000H
Data 2000H in 16 bit form is moved to the DPTR Register address which consists of DPH and DPL.
MOVC A,@A+DPTR
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|--------------|----------------|----|----|-----|-----|----|---|---|
| 2 | 1 | Movc A,@A+DPTR | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Performs data transfer from the program memory designated by DPTR with accumulator index A to accumulator A. In this instruction, the microcontroller will read the program memory, which is a memory in the Flash PEROM AT89C51 or in a memory component outside the AT89C51 where the RD input of the memory is connected to PSEN. The PSEN signal is active when this instruction is executed.
Example:
Mov A,#50H
Mov DPTR,#2000H
Movc A,@A+DPTR
Data located in memory components outside the AT89C51 and located at address 2000H + 50H will be read and the results stored in accumulator A.
MOVC A,@A+PC
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|--------------|--------------|----|----|-----|-----|----|---|---|
| 2 | 1 | Movc A,@A+PC | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Transferring data from the program memory designated by the PC (Program Counter) with accumulator index A to accumulator A. In this instruction, the microcontroller will read the program memory, which is a memory in the Flash PEROM AT89C51 or in a memory component outside the AT89C51 where the RD input of the memory is connected to PSEN. The PSEN signal is active when this instruction is executed.
Example:
Mov A,#50H
Movc A,@A+PC
If at that time the Program Counter is at address 2100H, then the data located in the memory component outside the AT89C51 and located at address 2100H + 50H will be read and the results stored in accumulator A.
MOVX A,@RI
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|--------------|------------|----|----|-----|-----|----|---|---|
| 2 | 1 | Movx A,@Ri | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Transferring data from external memory (memory components outside the AT89C51) to accumulator A. The address and data lines from the memory are connected via Port 0 and the process of sending addresses and retrieving data is done alternately (multiplexed). The memory address consists of 8 bits so that the maximum capacity of the memory is 256 bytes.
Example:
Mov R0,#50H
Movx A,@R0
The data at address 50H from external memory is moved to accumulator A.
MOVX A,@DPTR
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|--------------|--------------|----|----|-----|-----|----|---|---|
| 2 | 1 | Movx A,@DPTR | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Performs data transfer from external memory designated by DPTR to accumulator A. Unlike MOVC, when this instruction is executed, the signal that appears is the RD signal (not PSEN), so that the external memory where the RD input is connected to the RD of the AT89C51 is read.
Example:
Mov DPTR,#2500H
Movx A, @DPTR
The data located at address 2500H is moved to accumulator A.
MOVX @RI,A
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|-------------|------------|----|----|-----|-----|----|---|---|
| 2 | 1 | Movx @Ri,A | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Performing data transfer from accumulator A to external memory designated by the Index Register. The address and data lines of the memory are connected via Port 0 and the process of sending addresses and sending data is done alternately (multiplexed). The address of the memory consists of 8 bits so that the maximum capacity of the memory is 256 bytes.
Example:
Mov R0,#60H
Movx @R0,A
The data in accumulator A is moved to the address pointed to by R0 in external memory.
MOVX @DPTR,A
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|-------------|--------------|----|----|-----|-----|----|---|---|
| 2 | 1 | Movx @DPTR,A | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Performs data transfer from accumulator A to the address pointed to by DPTR in external memory.
Example:
Mov A,#55H
Mov DPTR,#3000H
Movx @DPTR,A
Data 55H in accumulator A is moved to address 3000H located in external memory.
Operation Logic CLR, CPL, RL, RLC, RR, RRC & SWAP
CLR A
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|-------------|-----------|----|----|-----|-----|----|---|---|
| 1 | 1 | CLR A | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Assigns the value 0 to 8 bits of Accumulator A.
CPL A
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|-------------|-----------|----|----|-----|-----|----|---|---|
| 1 | 1 | CPL A | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Perform complement on each bit in accumulator A.
Example:
If the value of accumulator A is 55H or 01010101b, then after the complement process occurs the value of accumulator A changes to AAH or 10101010b.
RL A
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|-------------|-----------|----|----|-----|-----|----|---|---|
| 1 | 1 | RL A | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Shift left 1 bit for each bit in accumulator A
Example:
The value of Accumulator A is 05H or 00000101b, after the shifting process is carried out, the value of Accumulator A will change to 00001010b or 0AH.
RLC A
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|-------------|-----------|----|----|-----|-----|----|---|---|
| 1 | 1 | RLC A | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | X | | | | | | | |
Example:
The value of Accumulator A is 05H or 00000101b and the carry flag is set, after the shift process is carried out, the value of Accumulator A will change to 00001011b or 0BH with the carry flag clear.
RR A
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|-------------|-----------|----|----|-----|-----|----|---|---|
| 1 | 1 | RR A | | | | | | | |
| | Flag | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Shifts right 1 bit for each bit in accumulator A
Example:
The value of Accumulator A is 05H or 00000101b, after the shifting process is carried out, the value of Accumulator A will change to 10000010b or 0AH.
RRC A
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|--------------|-----------|----|----|-----|-----|----|---|---|
| 1 | 1 | RRC A | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | X | | | | | | | |
Shift right by 1 for each bit in accumulator A followed by the carry flag. Bit 7 will go into the carry flag and the carry flag bit will go into bit 0.
Example:
The value of Accumulator A is 05H or 00000101b and the carry flag is set, after the shift process is carried out, the value of Accumulator A will change to 00001011b or 0BH with the carry flag clear.
SWAP A
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|--------------|-----------|----|----|-----|-----|----|---|---|
| 1 | 1 | SWAP A | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Perform high and low nibble swap operation in accumulator A.
Example:
The contents of accumulator A are 51H, after the SWAP A instruction is executed, data 5 in the high nibble will be exchanged with data 1 in the low nibble to become 15H.
Transfer Data PUSH, POP & XCH
PUSH DIRECT
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|--------------|-------------|----|----|-----|-----|----|---|---|
| 2 | 2 | Push direct | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Stores data from a register or memory into the stack. The location of the data in the stack is indicated by the stack pointer. When this instruction is executed, the value of the stack pointer will increase by one and the PUSHed register or memory will enter the address indicated by the stack pointer.
Example:
Push A
The contents of the previous SP were 09H, then the SP will increase by 1 to 0AH and the value of accumulator A will be stored at address 0AH.
POP DIRECT
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|-------------|------------|----|----|-----|-----|----|---|---|
| 2 | 2 | Pop direct | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Performs data retrieval from the stack to a register or memory. The location of the data in the stack is indicated by the stack pointer. When this instruction is executed, the data at the address indicated by the stack pointer will be moved to the register or memory followed by the value of the stack pointer being reduced by 1.
Example:
Pop B
The contents of the previous SP were 08H, so the data stored at address 08H will be moved to Register B followed by reducing the SP value to 07H.
XCH A,RN
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|-------------|-----------|----|----|-----|-----|----|---|---|
| 1 | 1 | XCH A,RN | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
XCH A,DIRECT
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|--------------|------------|----|----|-----|-----|----|---|---|
| 1 | 2 | Xch direct | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Replaces the data stored in accumulator A with a direct address.
Example:
XCH A,70H
The data in accumulator A is exchanged with the data at address 70H of Internal RAM.
XCH A,@Ri
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|-------------|-----------|----|----|-----|-----|----|---|---|
| 1 | 1 | Xch A,@Ri | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Exchanges the data stored in accumulator A with the address pointed to by Register Index (R0 or R1).
Example:
XCH A,@R0
The data in accumulator A is exchanged with the data at the address pointed to by R0.
XCHD A,@RI
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|--------------|------------|----|----|-----|-----|----|---|---|
| 1 | 1 | XCHD A,@Ri | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Swaps the low nibble of accumulator A with the low nibble of the data pointed to by the Index Register (R0 or R1). The high nibble remains unchanged.
Example:
XCHD A,@R0
If previously accumulator A contained 15H, R0 contained 20H and the contents of the internal RAM at address 20H were 41H, then after this instruction is executed the contents of accumulator A change to 11H and the contents of the internal RAM at address 20H become 45H.