| ??? 08/28/02 12:27 Read: times |
#28057 - Clean code |
I've just started writing my first code
on a Phytec P89C51RD2 development board. Thanks to all who suggested using this processor,flash programming is so simple and fun. I have written some code which I would like to simplify.It outputs a menu to hyperterminal on my PC and it does work but is ugly. Here is part of the program; ; This is the main program. ; which displays the text on the console. ; type message CALL PUT_CRLF MOV DPTR,#TXT CALL PUTSTRING CALL PUT_CRLF MOV DPTR,#TXT1 CALL PUTSTRING CALL PUT_CRLF MOV DPTR,#TXT2 CALL PUTSTRING CALL PUT_CRLF MOV DPTR,#TXT3 CALL PUTSTRING CALL PUT_CRLF MOV DPTR,#TXT4 CALL PUTSTRING CALL PUT_CRLF MOV DPTR,#TXT5 CALL PUTSTRING ; repeat REPEAT: SJMP REPEAT ; RSEG CONST TXT: DB 10,13,'TEST PROGRAM - Serial control LED 3',10,13,00H TXT1: DB 10,13,'Hello Phil',10,13,0 TXT2: DB 10,13,'01 - Input LED 3 ontime',10,13,0 TXT3: DB 10,13,'02 - Input LED 3 offtime',10,13,0 TXT4: DB 10,13,'CTRL-C to Quit............',10,13,0 TXT5: DB 10,13,'>',0 END I was thinking I could pad each text line with spaces so they are the same length and then place the string length in ACC and loop using MOV @a+dptr,TXT#.Is there a cleaner way though? Look forward to any suggestions - I have already learned so much this month from the forum and the tutorials page.Guess I need a book on programming techniques though. Phil Bassett. |
| Topic | Author | Date |
| Clean code | 01/01/70 00:00 | |
| RE: Clean code | 01/01/70 00:00 | |
| RE: Clean code | 01/01/70 00:00 | |
| RE: Clean code | 01/01/70 00:00 | |
| RE: Clean code | 01/01/70 00:00 | |
| RE: Clean code | 01/01/70 00:00 | |
| RE: Clean code | 01/01/70 00:00 | |
| RE: Clean code - to Donald | 01/01/70 00:00 | |
| RE: Clean code George, Donald | 01/01/70 00:00 | |
| RE: Clean code | 01/01/70 00:00 | |
| RE: Clean code | 01/01/70 00:00 | |
| RE: Null terminator | 01/01/70 00:00 | |
| CRLF? LFCR? | 01/01/70 00:00 | |
| RE: Clean code | 01/01/70 00:00 | |
| RE: Clean code - to Philip | 01/01/70 00:00 | |
| RE: Null terminator | 01/01/70 00:00 | |
| Hyperterminal alternative | 01/01/70 00:00 | |
| RE: Clean code | 01/01/70 00:00 | |
| RE: Hyperterminal alternative | 01/01/70 00:00 | |
RE: Hyperterminal alternative | 01/01/70 00:00 |



