Смекни!
smekni.com

Особенности разработки микропроцессорной системы и устройства для чтения электронных книг (стр. 12 из 13)

add char,work

push count

rcall write_data

pop count

ret

;-----------------------------------------------------------------------

module_address_set:

sbis usr,rxc

rjmp module_address_set

rcall RXcomplete

mov address2,data

wait1:

sbis usr,rxc

rjmp wait1

rcall RXcomplete

mov address1,data

wait2:

sbis usr,rxc

rjmp wait2

rcall RXcomplete

mov address0,data

ldi hiz,(high(address_set*2))

ldi loz,(low(address_set*2))

rcall message

ret

;-----------------------------------------------------------------------

get_address_text_begin:

push work

mov work,book

cpi work,0

brne address_calc

clr address2

ldi address1,0x02

ldi address0,0x08

rjmp end_get_address_text_begin

address_calc:

dec work;То есть dec book!

clr address1

ldi address0,0x08

;mov work,book

sbrc work,0

sbr address0,0x40

sbrc work,1

sbr address0,0x80

sbrc work,2

sbr address1,0x01

rcall read_flash

mov storeh,data

rcall inc_addr

rcall read_flash

mov storel,data

rcall inc_addr

rcall read_flash

mov address0,data

mov address1,storel

mov address2,storeh

end_get_address_text_begin:

pop work

ret

;-----------------------------------------------------------------------

choose_text:

push work

clr address0

clr address1

clr address2

rcall read_flash

cpi data,0x5e

breq calk_name

ldi hiz,(high(no_text*2))

ldi loz,(low(no_text*2))

rcall message

rcall push_button

rjmp choose_text_ret

calk_name:

inc address0;гораздо быстрее, чем подпрограммой inc_addr

rcall read_flash

cpi data,0x5e

breq calk_name

dec address0

mov all_book,address0

show_name:

clr address1

ldi address0,0x0b;смещение=8 + адрес=3

mov work,book

sbrc work,0

sbr address0,0x40

sbrc work,1

sbr address0,0x80

sbrc work,2

sbr address1,0x01

rcall blank_screen

ser count

mov work,all_book

cpi work,0

breq one_book

cp work,book

breq book_down

ldi char,0xda

rcall write_data

inc count

mov work,book

cpi work,0

breq one_book

book_down:

ldi char,0xd9

rcall write_data

inc count

one_book:

ldi char,' '

rcall write_char

ldi work,55

name_loop:

rcall read_flash

cpi data,0x07

breq end_show_name_ent

push work

mov char,data

rcall write_char

rcall inc_addr

pop work

dec work

brne name_loop

end_show_name_ent:

ldi char,' '

rcall write_char

ldi char,0x7e

rcall write_char

end_show_name:

rcall push_button

cpi key,3;то есть в минус

breq minus_text

cpi key,2;то есть в плюс

breq plus_text

rjmp choose_text_ret

minus_text:

mov work,book

cpi work,0

breq end_show_name

dec book

clr address2

clr address1

mov address0,book

rcall read_flash

cpi data,0x5e

breq ret_minus_text

inc book

ret_minus_text:

rjmp show_name

plus_text:

mov work,book

cpi work,7

breq end_show_name

inc book

clr address2

clr address1

mov address0,book

rcall read_flash

cpi data,0x5e

breq ret_plus_text

dec book

ret_plus_text:

rjmp show_name

choose_text_ret:

pop work

ret

;-----------------------------------------------------------------------

sub_string:

subi address0,low(TSYM)

sbci address1,high(TSYM)

brsh ret_sub_string

dec address2

ret_sub_string:

ret

;-----------------------------------------------------------------------

data_polling:

clr work

out ddrb,work

sbi portd,WE

sbrc address2,3

rjmp ce2_pol

sbi porta,CE2;CE2

cbi porta,CE1;CE1

rjmp repeat_dp

ce2_pol:

sbi porta,CE1

cbi porta,CE2

repeat_dp:

cbi portd,OE

nop

nop

in data,pinb

sbi portd,OE

cbr data,0x7f

cbr char,0x7f

cp data,char

brne repeat_dp; Собссно, это и есть #data polling по 7-му биту

ser work

out ddrb,work

sbi porta,CE1

sbi porta,CE2

ret

;-----------------------------------------------------------------------


Приложение Б

Файл rus.inc

.set _a=0x61

.set _b=0xb2

.set _v=0xb3

.set _g=0xb4

.set _d=0xe3

.set _e=0x65

.set _yo=0xb5

.set _zh=0xb6

.set _z=0xb7

.set _i=0xb8

.set _j=0xb9

.set _k=0xba

.set _l=0xbb

.set _m=0xbc

.set _n=0xbd

.set _o=0x6f

.set _p=0xbe

.set _r=0x70

.set _s=0x63

.set _t=0xbf

.set _u=0x79

.set _f=0xe4

.set _h=0x78

.set _ts=0xe5

.set _ch=0xc0

.set _sh=0xc1

.set _tch=0xe6

;.set _q=0xc2

.set _y=0xc3

.set _q=0xc4

.set _ee=0xc5

.set _yu=0xc6

.set _ya=0xc7

.set bA=0x41

.set bB=0xa0

.set bV=0x42

.set bG=0xa1

.set bD=0xe0

.set bE=0x45

.set bYO=0xa2

.set bZH=0xa3

.set bZ=0xa4

.set bI=0xa5

.set bJ=0xa6

.set bK=0x4b

.set bL=0xa7

.set bM=0x4d

.set bN=0x48

.set bO=0x4f

.set bP=0xa8

.set bR=0x50

.set bS=0x43

.set bT=0x54

.set bU=0xa9

.set bF=0xaa

.set bH=0x58

.set bTS=0xe1

.set bCH=0xab

.set bSH=0xac

.set bTCH=0xe2

;.set b&&=0xad

.set bY=0xae

;.set b##=0xc4

.set bEE=0xaf

.set bYU=0xb0

.set bYA=0xb1

Файл reader.hex

:020000020000FC

:10002000F8940FE50DBF02E00EBF0EEF01BB0BE829

:1000300002BB0FEF07BB08E10AB904E009B90FEFF3

:1000400004BB0FE10ABB002705BB08EF0BBB66270B

:10005000772788275FEF94E033240CD128E3DED0A4

:100060002CE0DCD026E0DAD021E0D8D02CB12CB1C5

:100070002CB1F6E0E2E0ABD26CD2E6D3503051F0D6

:10008000513039F0523091F1F6E0E0E6A0D261D281

:10009000F4CF52C09B7FA1D483D495D224D2D4D3A1

:1000A000F8D45030D1F35130A1F3523071F13BD438

:1000B0005F9389D25FEF89D1E12E212F7ED04BD182

:1000C0005F34C9F75F9145D2A33089F0A23009F0BF

:1000D000E6CF5F93550F550F750F30F48395803140

:1000E00018F06FEF7FEF8FE05F91E2CF54C05F9326

:1000F000550F550F751B28F48A951AF48827772712

:1001000066275F91D5CFEFD1FECF0F9300270FBBAE

:100110003CD0032D000F000F03950EBB8DBB38D0D4

:1001200034D003950EBB7DBB33D02FD003950EBBCF

:100130006DBB2ED00F91B1CF92FD4FD40F930027FE

:100140000FBB032D000F000F03950EBB1AD00F93AA

:100150000DB30F3F49F4F8E0E2E239D2FAD10F9142

:100160000F9192FD8ACF99CF802F0F9103950EBBEF

:1001700008D07DB303950EBB04D06DB30F919B7F68

:100180008CCFE199FECFE09A0895E199FECF0895D2

:10019000E29AE19A0895F6E0ECEB19D25F9BFECF6C

:1001A00012D286D0153E19F01E35E9F0F7CF5F9BCD

:1001B000FECF7ED002D0B1D0FACF0F9353955832F4

:1001C00039F0503551F027FD77D030D00F91089598

:1001D000F22E20EC23D02F2DF6CF5527F22E21E042

:1001E0001DD02F2DF0CF5F9BFECF62D0103149F094

:1001F000103251F0103359F0103459F0103561F0CD

:10020000F2CF9D7F87D1EFCF926084D1ECCF11D117

:10021000EACFD9D168D1E7CFB3D3E5CF0F930ED0D2

:100220009698959828BB1DD00F9108950F9306D0EE

:10023000969A959828BB15D00F9108952F93002773

:1002400007BB0FEF08BB9698959A0000949A0ED0C2

:1002500026B3949827FDF9CF0FEF07BB96982F91FF

:10026000089504D0949A02D0949808950FE10A95C5

:10027000F1F708950FEF07BB9698959810D00FD01F

:100280000ED00DD00CD007D00AD009D004D007D0A2

:1002900006D001D004D000E308BBE3DF0895332784

:1002A000442703D03A95E9F708954A95F1F7089560

:1002B0002CB1E22E122F0895283A59F0283B59F01C

:1002C0002F73F2E0EAEDE20F08F4F395C895202DC4

:1002D000089522EA089525EB089541A042A1E04542

:1002E000A3A4A5A64BA74D484FA8504354A9AA586C

:1002F000E1ABACE2ADAE62AFB0B161B2B3B4E36555

:10030000B6B7B8B9BABBBCBD6FBE7063BF79E4788D

:10031000E5C0C1E6C2C3C4C5C6C75D9BFECFECB88D

:100320000895979B18BB65BB929A0000929875BB85

:100330000F930BB3087F082B83FD03C00061077F79

:1003400002C008600F7E0BBB0F910000979916B397

:10035000DB9ADC9A08959894639531F4739521F4AF

:100360008395803108F0916008959798939A0F9340

:1003700005E5602F702F882791FD88601AEAD1DF8C

:100380000AEA602F0AE2702F15E5CBDF05E5602F42

:10039000702F10E8C6DF05E5602F702F1AEAC1DF65

:1003A0000AEA602F0AE2702F15E5BBDF05E5602F32

:1003B000702F10E1B6DF979A0F91F02E0AE032D03D

:1003C0000A95E9F70F2D979A0895979A93980F93A6

:1003D000002707BBA6DF0FEF07BB0F91939A089585

:1003E000F62E172E282E9798939A0F9305E5602FD7

:1003F000702F88701AEA95DF0AEA602F0AE2702FE0

:1004000015E58FDF05E5602F702F10EA8ADF6F2D6D

:10041000712D822D122F85DF2F9340D32F910F91B5

:10042000979A08950F9307E43ADF0A95E9F70F9139

:10043000089500273324662777278827C6DF1E35CF

:1004400051F489DF3394032D0830C1F7F7E0E8EB6E

:10045000BED07FD008952EE5C3DFF7E0EEEEB7D033

:10046000882777276BE0032D00FD606401FD60683D

:1004700002FD716007E35F9BFECF1ADFB1DF6BDF28

:100480000A9519F02730B9F702C027E0A9DFF7E095

:10049000E6E79DD085D25F9BFECF0ADF273059F07B

:1004A000122F9EDF3ADF57DF90FFF5CFF8E0E4E050

:1004B0008ED04FD00895282F572E462E8827772785

:1004C00068E0032D00FD606401FD606802FD71605D

:1004D00087DF41DF252D84DF3EDF242D81DFF7E03C

:1004E000E8E875D0089571DFE12E212F66DE33DF55

:1004F0005F3409F0F8CF2DD0A13059F0A23099F334

:10050000605A704080F78A9572F7662777278827A8

:10051000EACF0895002755270FBB37DE01E00EBB59

:100520001FEF1DBB35DE31DE0C5F53955830B9F738

:10053000F7E0EAE64CD019DFF7E0E6E148D00895AD

:100540000F93AA27CD9B0FC0CE9B1DC0CF9B2BC066

:1005500008950F93AA270027CD9B05C0CE9B13C0FB

:10056000CF9B21C0F8CF0A95000021F0CD9BFBCF97

:10057000F2CF00270A95000019F0CD99FBCFF9CFF3

:100580000F91A1E008950A95000021F0CE9BFBCFCA

:10059000E2CF00270A95000019F0CE99FBCFF9CFE2

:1005A0000F91A2E008950A95000021F0CF9BFBCFA8

:1005B000D2CF00270A95000019F0CF99FBCFF9CFD1

:1005C0000F91A3E008955FEF21E028DE08950F93D7

:1005D0009860F9DFC895002D003079F0013019F4EA

:1005E00020EC1CDE06C0202FEF93FF931FDEFF914F

:1005F000EF91E39579F7F395EDCF93FD0F91977F09

:1006000008952043B863BF65BC612020224BBDB86C

:10061000B46FC065B922012042657063B8C720314C

:100620002E333700204861C061BFC420C0B8BF610D

:10063000BFC420BABDB8B47901007E0020E06F636A

:10064000BF61BFC420B761BABB61E3BA79010000E2

:1006500020506561BBB8B76FB361BD6F2E2E2E0001

:100660002052264420372DC720A46163BF61B361A7

:100670002E20436FB7E361BB2053656147756C6CF7

:100680002E01204563BBB820C0BF6F2C20BEB8C16F

:10069000B8BF6520BD61202273656167756C6C40D1

:1006A0006D61696C2E72752200002043B3C7B7617B

:1006B000BFC463C7206320AF424D010020A3E3798C

:1006C0002063B3C7B7B820BD612031313532303037

:1006D0000120A86FE3BABBC6C0B8BF6520BE6F706B

:1006E000BF2E000020A8706FE36FBBB6B8BFC42058

:1006F000C0B8BF61BFC4010020A86FBB6FB6B8BF50

:10070000C420B761BABB61E3BA79010020A7B8631E

:10071000BF61BFC4010020A861BCC7BFC42063BFC4

:10072000B570BF6121002042B365E3B8BF6520C149

:1007300061B420BE706FBBB863BFC3B361BDB8C73F

:10074000012028B320BFC363C7C061782063B8BC51

:10075000B36FBB6FB3293A002041E370656320B3E8

:10076000C363BF61B3BB65BD00002043BFB8706108

:10077000C62E2E2E000020A870B8B5BC20B8BDE44F

:100780006F70BC61E5B8B80020A5BDE46F70BC61B6

:10079000E5B8C720BE70B8BDC7BF61210000204BBF

:1007A000BDB8B4B820BD6520B2C3BBB820B761BE28

:1007B000B86361BDC3210000204865BF20BC6563EC

:1007C000BF6120B320BF61B2BBB8E56520BE6FE357

:1007D00020BABDB8B4792101204BBDB8B420BD65A5

:1007E00020B26FBBC4C16520382DBCB821002042A7

:1007F00063BF79C0B8BF6520B761B46FBB6FB36F1B

:10080000BA2E000020A861BCC7BFC420B761BE6F6C

:10081000BBBD65BD6120BE6FBBBD6F63BFC4C621DC

:10082000000020A461BABB61E3BA6120E3BBC7202A

:10083000C5BF6FB920BABDB8B4B8206FBF6379BF68

:1008400063BFB37965BF2100552792FF39C05F931D

:10085000BADE5F91523051F0533091F0503011F4C4

:100860005BD001C05DD0F6E0E4E2B4DE513011F4BB

:1008700053D001C055D0F6E0ECE3ACDE523090F03E

:10088000523011F449D001C04BD0F6E0EAEAA2DEC2

:10089000523041F0533011F43FD001C041D0F6E066

:1008A000E0E598DE56DEA23019F0A33029F0089575

:1008B000533059F25395C9CF503039F25A95C5CFBC

:1008C0005F9381DE5F91523051F0533091F05030A0

:1008D00011F422D001C024D0F6E0E4EE7BDE5130EA

:1008E00011F41AD001C01CD0F6E0ECE373DE5230F4

:1008F000C8F2523011F410D001C012D0F6E0E8EF87

:1009000069DE523079F2533011F406D001C008D0BC

:10091000F7E0ECE05FDEC6CFF6E0EAE35BDE0895E9

:1009200020E284DC08950F934EDE51E0F7E0E6E22A

:1009300051DE27ED73DC5A3028F4052F1BD020E25E

:1009400075DC09C021E35F9371DC5F9128ED66DC03

:10095000052F0A500FD0FDDDA33021F0A23031F079

:100960000F910895503129F35395E3CF513009F396

:100970005A95DFCF20E3200F5F9358DC5F910895F5

:100980005F9BFECF95DC812F5F9BFECF91DC712FAB

:100990005F9BFECF8DDC612FF7E0E8E518DE089560

:1009A0000F93032D003021F4882772E068E013C014

:1009B0000A95772768E000FD606401FD606802FD2C

:1009C000716003DD212EC7DC00DD112EC4DCFDDCEF

:1009D000612F712D822D0F9108950F936627772730

:1009E0008827F3DC1E3529F0F7E0EEE9F0DDB1DD14

:1009F0004EC06395EADC1E35E1F36A95662E7727D3

:100A00006BE0032D00FD606401FD606802FD716014

:100A1000DADD5FEF062D003059F0031531F02AEDD5

:100A200005DC5395032D003019F029EDFFDB5395BC

:100A300020E2C3DB07E3C9DC173039F00F93212F25

:100A4000BCDB89DC0F910A95B1F720E2B6DB2EE71B

:100A5000B4DB7FDDA33019F0A23069F018C0032D9C

:100A60000030B9F33A9488277727632DAEDC1E3522

:100A700009F03394C4CF032D073059F333948827FA

:100A80007727632DA2DC1E3509F03A94B8CF0F9179

:100A900008956055704008F48A950895002707BBB3

:100AA000979A83FD03C0DC9ADB9802C0DB9ADC983E

:100AB00093980000000016B3939A107820781217CC

:0C0AC000B9F70FEF07BBDB9ADC9A089532

:00000001FF


Приложение В

Файл reader.cpp

#include <stdio.h>

#include <conio.h>

#include <string.h>

#include <time.h>

#define OUT_REG BASE

#define IN_REG BASE

#define CONTROL BASE+3

#define STATUS BASE+5

#define LOW_DIV BASE

#define HIGH_DIV BASE+1

#define INT_REG BASE+1

#define DIVISOR 0x80

unsigned long BASE;

FILE *file3;

int code;

void Help();

void Erase();

void Write(char *wr_file);

int o_sym(char symbol);

void Inv(char insym);

char i_sym();

void main(int argc, char *argv[])

{

FILE *file1;

char *param;

clrscr();

if ((file1 = fopen("reader.ini", "rt"))

== NULL)

{

printf("Cannot open file &bsol;"reader.ini&bsol;" !&bsol;n");

return;

}

do {

fscanf(file1,"%s&bsol;n",param);

}while(strcmp(param,"[PORT]")!=0);

fscanf(file1,"%s&bsol;n",param);

printf("&bsol;nConnect device to %s",param);

if(param[3]=='1')

BASE=0x3f8;

if(param[3]=='2')

BASE=0x2f8;

fsetpos(file1,0);

do {

fscanf(file1,"%s&bsol;n",param);

}while(strcmp(param,"[CODE]")!=0);

fscanf(file1,"%s&bsol;n",param);

printf("&bsol;nCode= %s",param);

if(!strcmp(param,"DOS")) code=1;

else code=0;

fclose(file1);

//Initial COM-port block

outportb(CONTROL,DIVISOR);

outportb(LOW_DIV,1);

outportb(HIGH_DIV,0);

outportb(CONTROL,0x07);//8 bit+2stop+noparity

outportb(INT_REG,0);//Disable interrupt

inportb(IN_REG);

inportb(IN_REG);//Zeroing read

//End of initial block

o_sym (0x5e);//Switch to operation mode

if(argc<2)

{

Help();

return;

}

switch(*argv[1])

{

case 'e':

Erase();

break;

case 'w':

Write(argv[2]);

break;

default:

Help();

break;

}

}

void Help()

{

printf ("&bsol;nUse &bsol;"reader.exe e&bsol;" for erase books, &bsol;"reader.exe w <file>&bsol;" for write <file>");

}

void Erase()

{

printf ("&bsol;nAll books in the memory will be erased.&bsol;nWait message on the Readerbook's screen");

o_sym(0x10);//first IC

o_sym(0x20);//second IC

}

void Write(char *wr_file)

{

FILE *file1;

char author[40],title[40],header[81],rec_sym;

int i=0,flag;

char win[256]={

0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15

,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31