;There is a question that requires you to change a C language program into an assembly language. The link is as follows:
;Looking at his original program, it drives the 8*8 LED dot matrix to display characters.
;
; According to the program, the dot matrix driving circuit is drawn. After running the C program, the display is as follows:
;
;
;All the characters displayed by the LED are given below. Some of the characters are very creative.
;The full code is as follows:
;8 * 8 LED dot matrix
ORG 0000H
JMP START
;-----------------------
RED:
DB 0x18,0x00,0x18,0x18,0x18,0x18,0x18,0x18;//i
DB 0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0xFC,0xFC;//l
DB 0x3C,0x42,0x42,0x42,0x42,0x42,0x42,0x3C;//o
DB 0x00,0x00,0x44,0x44,0x44,0x44,0x28,0x10;//v
DB 0x00,0x3E,0x02,0x02,0x3E,0x02,0x02,0x3E;//e
DB 0x81,0xA5,0xDB,0xC3,0xA5,0x99,0x81,0xFF;//u
;-----------------------
START:
MOV DPTR, #RED
MOV R2, #254
LP0: MOV R3, #0
LP1: MOV R5, #100
LP2:MOV R4, #0
LP3:MOV A, R3
ADD A, R4
CALL DISP
INC R4
CJNE R4, #8, LP3
DJNZ R5, LP2
;-----------------
MOV A, R3
ADD A, #8
MOV R3, A
CJNE R3, #48, LP1
SJMP LP0
;-----------------------
DISP:
MOVC A, @A + DPTR
MOV P2, A
MOV P0, R2
MOV A, R2
RL A
MOV R2, A
DJNZ R7, $
DJNZ R7, $
MOV P2, #0
RIGHT
;-----------------------
END
; After submitting the assembler program, the following prompt appears:
;
;>_
;
;This kind of thing has happened many times, and there has been no result after appealing.
;
;Haha, the judgment ability and level of some network administrators on Baidu Zhidao are really hard to describe in words.
;
;
;The C program given in this question is as follows:
#include
#define uchar unsigned char
#define uint unsigned int
uchar code RED[] = {
0x18,0x00,0x18,0x18,0x18,0x18,0x18,0x18,//i
0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0xFC,0xFC,//l
0x3C,0x42,0x42,0x42,0x42,0x42,0x42,0x3C,//o
0x00,0x00,0x44,0x44,0x44,0x44,0x28,0x10,//v
0x00,0x3E,0x02,0x02,0x3E,0x02,0x02,0x3E,//e
0x81,0xA5,0xDB,0xC3,0xA5,0x99,0x81,0xFF //u
};
void delay(uint t)
{
for(; t > 0; t--);
}
void main()
{
uchar r, j, q = 0, t = 0;
while(1) {
for(r = 0; r < 40; r++) {
for(j = q; j < q + 8; j++) {
P0 = (~(0x01 << t));
P2 = RED[j]; delay(200); P2 = 0;
t++; t %= 8;
}
}
q += 8; q %= 48;
}
}
You can try to see if the functions of the two programs are the same.
Previous article:51 MCU Programming: Dual Counter
Next article:51 Assembly Programming: Multi-way Delay Switch
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Download from the Internet--ARM Getting Started Notes
- Learn ARM development(22)
- Learn ARM development(21)
- Learn ARM development(20)
- Learn ARM development(19)
- Learn ARM development(14)
- Learn ARM development(15)
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- [RISC-V MCU CH32V103 Review] + Timer Test and System Summary
- Bluetooth Low Energy (BLE) peripheral mode (peripheral) - using BLE as a server
- The problem of the total distortion increasing after the signal passes through the op amp filter circuit
- FPGA implementation of the design of RU algorithm encoder (LDPC encoder)
- [NXP Rapid IoT Review] + Laptop Bluetooth Interaction with Rapid IOT
- GPIO Operation of TMS320C6748
- Jingzao Wireless Charging Mouse Pad Disassembly Report
- The data of the differential resistance sensor is fluctuating greatly, with about 11 bits fluctuating.
- TI - MCU - MSP430 User Guide 3 -> SYS System Control
- What parameters should be considered when changing a product from 422 communication to 485 communication?