51 Assembly Programming: 8×8 Dot Matrix Driver

Publisher:csZhouLatest update time:2018-05-09 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

;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:

;

51 Assembly Programming: 8×8 Dot Matrix Driver - Non-Famous Blogger - Electronic Information Corner

;

;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.


Reference address:51 Assembly Programming: 8×8 Dot Matrix Driver

Previous article:51 MCU Programming: Dual Counter
Next article:51 Assembly Programming: Multi-way Delay Switch

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号