简体   繁体   中英

8086-Matrix Scroll ‘A’ left to right C code

I was trying to scroll 8*8 dot matrix for character 'A' left to right but I am stuck at something. The MDA-8086 trainer kit is not currently available to me. As a result, I am unable to run the code to inspect what is actually happening there.

The code is here.

#include "mde8086.h"
/* Output Font 'A' Left to Right*/
int font1[8] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
int font2[8] = { 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
int font3[8] = { 0xb7, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
int font4[8] = { 0x77, 0xb7, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff };
int font5[8] = { 0x77, 0x77, 0xb7, 0xc0, 0xff, 0xff, 0xff, 0xff };
int font6[8] = { 0xb7, 0x77, 0x77, 0xb7, 0xc0, 0xff, 0xff, 0xff };
int font7[8] = { 0xc0, 0xb7, 0x77, 0x77, 0xb7, 0xc0, 0xff, 0xff };
int font8[8] = { 0xff, 0xc0, 0xb7, 0x77, 0x77, 0xb7, 0xc0, 0xff };
void wait(long del)
{
    while( del-- );
}
void display( int *data1 )
{
    int *data;
    int common, i, k;
    for( k = 0; k != 20; k++ )
    {
        common = 0x01;
        data = data1;
        for( i = 0; i != 8; i++ )
        {
            outportb( PPI2_C, common );
            outportb( PPI2_B, *data );
            wait(120);
            data++;
            common = common << 1;
        }
    }
}
void main(void)
{
    outportb( PPI2_CR, 0x80 );
    outportb( PPI2_A, 0xff );
    do
    {
        display(font1);
        display(font2);
        display(font3);
        display(font4);
        display(font5);
        display(font6);
        display(font7);
        display(font8);
        display(font8);
        display(font8);
    } while(1);
}

On displaying just 'A' without scrolling from left to right, this loop for( k = 0; k;= 20; k++ ) is absent. I just want to know what is the specialty of this loop here?

The output of the above code is shown in the figure below.

矩阵卷轴 A:从左到右

The 8x8 dot matrix can only ever show 8 lit LEDs, one vertical column.
(Actually it could show all identical columns at the same time, using more than one set bit inside common , but that would make for complex code and not help in the long run.)
To show one letter, you have to show the eight colums one by one, each time waiting a little ( wait(120) ). That makes one character, using 1 font, but only for a very short time. The 8 waits seem to be "in parallel" because of the speed with which that happens.
This is the inner loop.

To give a human time to actually see the character, that is done 20 times.
It is not possible to simply wait again, because that would mean only seeing the last column for a humanly perceivable time. This is the outer loop.

The scrolling is done without loop, by the many lines with different fonts inside main() .
The loop inside main() just repeats this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM