📄 hexdec-lcd.a51.lst
字号:
ASEM-51 V1.3 Copyright (c) 2002 by W.W. Heinz PAGE 1
MCS-51 Family Macro Assembler A S E M - 5 1 V 1.3
=====================================================
Source File: E:\MiCrOConTroller\Coba_M-IDE\HEX-DEC_LCD\hexdec-lcd.a51.asm
Object File: E:\MiCrOConTroller\Coba_M-IDE\HEX-DEC_LCD\hexdec-lcd.a51.hex
List File: E:\MiCrOConTroller\Coba_M-IDE\HEX-DEC_LCD\hexdec-lcd.a51.lst
Line I Addr Code Source
1: ;*******************************************
2: ;* Tutorial: *
3: ;* 1. Hex to Decimal converting routine *
4: ;* 2. Decimal to Ascii converting rout. *
5: ;* 3. LCD (4x40) driving functions *
6: ;*******************************************
7: ;This program was written using Raisonance RIDE MA-51
8: ;my email: jacek.bogusz@ep.com.pl
9:
10:
11: ;at89s8252 at 11.0592 MHz
12:
13: ;******************************************************************************
14: ; LCD connections:
15: ;
16: ; Pin description | AT89S8252
17: ; ---------------------------------------
18: ; enable | P0.4(35)
19: ; read lcd | P0.5(34)
20: ; reg.select | P0.6(33)
21: ; d0..d7 | P2.0 .. P2.7 (21..28)
22: ;
23: ;******************************************************************************
24:
25:
26:
27: ;Stack size (initial value of SP register)
28: N 00E0 StackAddr EQU 0E0H ;stack address (equals size)
29:
30: ;some of hd44780 (lcd controler) orders
31: N 0001 ClrScr EQU 01H ;clear screen
32: N 0002 RetHome EQU 02H ;return to Home pos.
33: N 0010 CursorLeft EQU 10H ;cursor left
34: N 0014 CursorRight EQU 14H ;cursor right
35: N 001C ScreenLeft EQU 1CH ;screen left
36: N 0018 ScreenRight EQU 18H ;screen right
37: N 000C DisplyOn EQU 0CH ;display on
38: N 0008 DisplyOff EQU 08H ;disply off
39: N 0080 SetDDRam EQU 80H ;set ddram address
40: N 0014 LCDLineLength EQU 20 ;lcd's line length
41: N 0004 LCDRowsNum EQU 4 ;lcd's max.row number
42:
43:
ASEM-51 V1.3 Copyright (c) 2002 by W.W. Heinz PAGE 2
Line I Addr Code Source
44: N 30 DSEG AT 30H
45: 30 N 08 t_buffer: DS 8 ;transponder receive
r buffer (64 bits)
46: 38 N 14 LCD_1: DS 20 ;lcd display buffer
47: 4C N 14 LCD_2: DS 20
48: 60 N 14 LCD_3: DS 20
49: 74 N 14 LCD_4: DS 20
^
@@@@@ segment limit exceeded @@@@@
50:
51: B 84 lcdenable BIT P0.4 ;enable signal for lcd display
52: B 85 lcdread BIT P0.5 ;read signal for lcd
53: B 86 lcdreg BIT P0.6 ;when H switch to command register,
when L to data register
54: B A7 lcdbusy BIT P2.7 ;data line 7 od lcd, for busy state
testing
55:
56:
57:
58: mainprog SEGMENT CODE INBLOCK
^
@@@@@ illegal statement syntax @@@@@
59:
60: ;interrupt vectors
61: CODE AT 0H
^
@@@@@ illegal statement syntax @@@@@
62: 08 AJMP InitProc ;reset
^
@@@@@ only allowed in CODE segment @@@@@
63: CODE AT 3H
^
@@@@@ illegal statement syntax @@@@@
64: 08 AJMP IrqExt0 ;int0
^
@@@@@ only allowed in CODE segment @@@@@
65: CODE AT 0BH
^
@@@@@ illegal statement syntax @@@@@
66: 08 AJMP IrqTmr0 ;timer 0
^
@@@@@ only allowed in CODE segment @@@@@
67: CODE AT 13H
^
@@@@@ illegal statement syntax @@@@@
68: 08 AJMP IrqExt1 ;int1
^
ASEM-51 V1.3 Copyright (c) 2002 by W.W. Heinz PAGE 3
Line I Addr Code Source
@@@@@ only allowed in CODE segment @@@@@
69: CODE AT 1BH
^
@@@@@ illegal statement syntax @@@@@
70: 08 AJMP IrqTmr1 ;timer 1
^
@@@@@ only allowed in CODE segment @@@@@
71: CODE AT 23H
^
@@@@@ illegal statement syntax @@@@@
72: 08 AJMP IrqSPI ;spi
^
@@@@@ only allowed in CODE segment @@@@@
73:
74:
75: CODE AT 30H
^
@@@@@ illegal statement syntax @@@@@
76:
77: ;external int0
78: 08 IrqExt0: RETI
^
@@@@@ only allowed in CODE segment @@@@@
79:
80: ;timer 0 interrupt
81: 08 IrqTmr0: RETI
^
@@@@@ only allowed in CODE segment @@@@@
82:
83: ;external int1
84: 08 IrqExt1: RETI
^
@@@@@ only allowed in CODE segment @@@@@
85:
86: ;timer 1 interrupt
87: 08 IrqTmr1: RETI
^
@@@@@ only allowed in CODE segment @@@@@
88:
89: ;spi interrupt
90: 08 IrqSPI: RETI
^
@@@@@ only allowed in CODE segment @@@@@
91:
92: ;------------------------------------------------
ASEM-51 V1.3 Copyright (c) 2002 by W.W. Heinz PAGE 4
Line I Addr Code Source
93: ; MAIN PROGRAM
94: ;
95: ; Note: this is a part of bigger program, which
96: ; is working as a machine controller, so you
97: ; have to change some of orders for your own
98: ; application!
99: ;------------------------------------------------
100: 08 InitProc: MOV SP,#StackAddr ;stack pointer setting
^
@@@@@ only allowed in CODE segment @@@@@
101: 08 MOV P0,#11101110B ;initial value of ea
^
@@@@@ only allowed in CODE segment @@@@@
ch port
102: 08 MOV P1,#10000111B
^
@@@@@ only allowed in CODE segment @@@@@
103: 08 MOV P2,#0FFH ;P2
^
@@@@@ only allowed in CODE segment @@@@@
is used for LCD data line (8 bits)
104:
105: 08 CALL InitLCD ;lcd init -
^
@@@@@ only allowed in CODE segment @@@@@
8 bit interface
106: 08 CALL DefChars ;lcd
^
@@@@@ only allowed in CODE segment @@@@@
special chacters def.
107:
108: 08 MOV R7,#80 ;black lcd a
^
@@@@@ only allowed in CODE segment @@@@@
t the start of the program
109: 08 BlackLoop: MOV A,#0FFH
^
@@@@@ only allowed in CODE segment @@@@@
110: 08 CALL OutLCD ;OUTLCD outp
^
@@@@@ only allowed in CODE segment @@@@@
uts value from ACC to LCD video ram
111: 08 DJNZ R7,BlackLoop
^
@@@@@ only allowed in CODE segment @@@@@
112: 08 CALL LPause ;a little br
ASEM-51 V1.3 Copyright (c) 2002 by W.W. Heinz PAGE 5
Line I Addr Code Source
^
@@@@@ only allowed in CODE segment @@@@@
eak (about 0.8 sec)
113:
114: 08 CALL WriteVersion ;write start informa
^
@@@@@ only allowed in CODE segment @@@@@
tion (about version etc)
115:
116: 08 CALL LongPause ;a few secon
^
@@@@@ only allowed in CODE segment @@@@@
ds of delay
117: 08 CALL ClearLCD ;cle
^
@@@@@ only allowed in CODE segment @@@@@
ar lcd's screen
118:
119: ;example of WriteCString using
120: 08 MOV R1,#0 ;row
^
@@@@@ only allowed in CODE segment @@@@@
no.0
121: 08 MOV R2,#0 ;col
^
@@@@@ only allowed in CODE segment @@@@@
umn no.0
122: 08 MOV DPTR,#ConvDesc ;address of string f
^
@@@@@ only allowed in CODE segment @@@@@
rom rom in dptr
123: 08 CALL WriteCString
^
@@@@@ only allowed in CODE segment @@@@@
124:
125: ;example of hex to dec converting
126: 08 MOV R5,#0
^
@@@@@ only allowed in CODE segment @@@@@
127: 08 MOV R6,#1EH
^
@@@@@ only allowed in CODE segment @@@@@
128: 08 MOV R7,#87H
^
@@@@@ only allowed in CODE segment @@@@@
ASEM-51 V1.3 Copyright (c) 2002 by W.W. Heinz PAGE 6
Line I Addr Code Source
129: 08 CALL Hex3DecConv ;result in r
^
@@@@@ only allowed in CODE segment @@@@@
5,6,7
130: 08 CALL Dec2AsciiConv ;result in lcd_1 (ra
^
@@@@@ only allowed in CODE segment @@@@@
m memory buffer)
131:
132: ;display the result of conversion (example of WriteAString u
sing)
133: 08 MOV R1,#1 ;row
^
@@@@@ only allowed in CODE segment @@@@@
no.1
134: 08 MOV R2,#0 ;col
^
@@@@@ only allowed in CODE segment @@@@@
umn no.0
135: 08 MOV R0,#LCD_1 ;r0 contains
^
@@@@@ only allowed in CODE segment @@@@@
address of ram buffer
136: 08 CALL WriteAString
^
@@@@@ only allowed in CODE segment @@@@@
137:
138: 08 AJMP $
^
@@@@@ only allowed in CODE segment @@@@@
;here stops the program
139:
140:
141:
142: ;Out data to status control register (of LCD)
143: ;status control register is using to input control codes for lcd controller
144: 08 OutStatRegLCD: CLR lcdreg ;choose status register
^
@@@@@ only allowed in CODE segment @@@@@
145: 08 CLR lcdread ;& write mod
^
@@@@@ only allowed in CODE segment @@@@@
e
146: 08 NOP
^
@@@@@ only allowed in CODE segment @@@@@
ASEM-51 V1.3 Copyright (c) 2002 by W.W. Heinz PAGE 7
Line I Addr Code Source
147: 08 SETB lcdenable
^
@@@@@ only allowed in CODE segment @@@@@
148: 08 MOV P2,A ;mov
^
@@@@@ only allowed in CODE segment @@@@@
e acc.content to P2
149: 08 CLR lcdenable ;data latche
^
@@@@@ only allowed in CODE segment @@@@@
d by enable signal
150: 08 CALL CheckBusyFlag
^
@@@@@ only allowed in CODE segment @@@@@
151: 08 RET
^
@@@@@ only allowed in CODE segment @@@@@
152:
153: ;Display char at cursor position
154: ;this routine outputs char contained in acc. to video ram of lcd
155: 08 OutLCD: SETB lcdreg ;choose data register
^
@@@@@ only allowed in CODE segment @@@@@
156: 08 CLR lcdread ;& write mod
^
@@@@@ only allowed in CODE segment @@@@@
e
157: 08 NOP
^
@@@@@ only allowed in CODE segment @@@@@
158: 08 SETB lcdenable
^
@@@@@ only allowed in CODE segment @@@@@
159: 08 MOV P2,A ;mov
^
@@@@@ only allowed in CODE segment @@@@@
e acc.content to P2
160: 08 CLR lcdenable ;data latche
^
@@@@@ only allowed in CODE segment @@@@@
d by enable signal
161: 08 CALL CheckBusyFlag
^
@@@@@ only allowed in CODE segment @@@@@
ASEM-51 V1.3 Copyright (c) 2002 by W.W. Heinz PAGE 8
Line I Addr Code Source
162: 08 RET
^
@@@@@ only allowed in CODE segment @@@@@
163:
164:
165: ;Delay instead of busy line checking
166: ;if you want, you can check the value of P0.7 (d7 of lcd)
167: ;logic H on this line is for BUSY state of lcd controller
168: 08 CheckBusyFlag: MOV R6,#3
^
@@@@@ only allowed in CODE segment @@@@@
169: 08 CBF_0: MOV R5,#0FFH
^
@@@@@ only allowed in CODE segment @@@@@
170: 08 CBF_1: DJNZ R5,CBF_1
^
@@@@@ only allowed in CODE segment @@@@@
171: 08 DJNZ R6,CBF_0
^
@@@@@ only allowed in CODE segment @@@@@
172: 08 RET
^
@@@@@ only allowed in CODE segment @@@@@
173:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -