A51 MACRO ASSEMBLER WIND DATE 29/09/94 PAGE 1 MS-DOS MACRO ASSEMBLER A51 V4.01 OBJECT MODULE PLACED IN WIND.OBJ ASSEMBLER INVOKED BY: A51 WIND.A51 DEBUG XREF LOC OBJ LINE SOURCE 1 name wind 2 3 ; Runs the handheld LCD anenometer by reading the 12-bit digitized 4 ; wind speed from the data tap and sending it to the remote LCD 5 ; serially 6 ; 7 ; Port assignments: 8 ; 0: bits 0-3: Diagnostic pins 9 ; 1: all bits: top 8 bits data from Data Tap 10 ; Simulator name 11 ; 3: bit 0: DATA OUT from LCD driver RXD 12 ; 1: LOAD to LCD TXD 13 ; 2: DATA to LCD INT0 14 ; 3: CLOCK to LCD, watchdog INT1 15 ; 4: RESET from handheld unit T0 16 ; 17 ; Register assignments 18 ; R5: Generic stuff 19 ; R6: Gust speed; highest wind speed since last reset 20 ; R7: Current wind speed 21 ; 22 ; 7/25/94 Bob Broilo 23 24 ; Define segments 25 PROG SEGMENT CODE 26 CONST SEGMENT CODE 27 BITVAR SEGMENT BIT 28 STACK SEGMENT IDATA 29 30 ; Define constants 0099 31 MAXSPD EQU 99H ;maximum displayable speed, defined by LCD and 32 ; DAT2BCD routine, in BCD for display 0007 33 NUMSEG EQU 7 ;number of segments per digit on LCD 00FF 34 INPORT EQU 11111111B ;all pins inputs on port 00F0 35 PORT0 EQU 11110000B ;port 0 initialization: all four diagnostic 36 ; pins on. 00F1 37 PORT3 EQU 11110001B ;port 3 startup value 0010 38 STSIZE EQU 10H ;stack size 0028 39 CYCLES EQU 40 ;Max transmission rate through 100' cable 40 ; was found to be 100KHz. The period of this 41 ; is 1e-5 and ~10 instructions can occur in this 42 ; time. This is the number of cycles/2 to 43 ; delay between output changes 44 ---- 45 RSEG STACK 0000 46 DS STSIZE ;16 Bytes Stack 47 ---- 48 RSEG CONST 49 ; Seven-segment lookup table 50 ; GFEDCBA segments 0000 7E 51 SEGTAB: DB 01111110B ;0 on LCD 0001 0C 52 DB 00001100B ;1 0002 B6 53 DB 10110110B ;2 0003 9E 54 DB 10011110B ;3 A51 MACRO ASSEMBLER WIND DATE 29/09/94 PAGE 2 LOC OBJ LINE SOURCE 0004 CC 55 DB 11001100B ;4 0005 DA 56 DB 11011010B ;5 0006 FA 57 DB 11111010B ;6 0007 0E 58 DB 00001110B ;7 0008 FE 59 DB 11111110B ;8 0009 DE 60 DB 11011110B ;9 61 ---- 62 RSEG BITVAR 0000 63 EXTREME:DBIT 1 ;extreme windspeed bit (>99mph). 64 65 ; Power up instruction 66 CSEG AT 0 67 USING 0 ;Register-Bank 0 0000 020000 F 68 JMP START ;Execution starts at address 0 on power-up. 69 ---- 70 RSEG PROG 71 0000 72 START: 73 ; Initialization 0000 758100 F 74 MOV SP, #STACK-1 ;set Stack Pointer, initialize the ports, etc... 0003 7580F0 75 MOV P0, #PORT0 ;TESTING 0006 7590FF 76 MOV P1, #INPORT ;P1 and P2 are inputs 0009 75A0FF 77 MOV P2, #INPORT 000C 75B0F1 78 MOV P3, #PORT3 000F C200 F 79 CLR EXTREME ;clear the extreme windspeed flag 0011 900000 F 80 MOV DPTR, #SEGTAB ;set up DPTR to the segment lookup table 0014 7E00 81 MOV R6, #0 ;clear the gust speed 82 0016 83 LOOP: ;while (1) { 84 ; Main program loop 0016 D280 85 SETB P0.0 ;TESTING turn off diagnostic pin 0018 E590 86 MOV A, P1 ;read Data Tap (top 8 bits) 001A F4 87 CPL A ;Data Tap output is inverted 001B FF 88 MOV R7, A ;store it 001C F5F0 89 MOV B, A 90 91 ; replace the max gust speed with this one if exceeded 001E C3 92 CLR C 001F 9E 93 SUBB A, R6 ;see if it was bigger 0020 4002 94 JC EEEP 0022 AEF0 95 MOV R6, B ;if so, replace gust 96 97 ; convert and display the windspeed 0024 EE 98 EEEP: MOV A, R6 ;get the gust speed 0025 1100 F 99 ACALL DAT2BCD ;convert it to BCD for display 0027 D281 100 SETB P0.1 ;TESTING made it through DAT2BCD 0029 5004 101 JNC EEEP2 002B D200 F 102 SETB EXTREME ;if windspeed > MAXSPD, then set flag 002D 7499 103 MOV A, #MAXSPD ;and use MAXSPD as speed 002F 1100 F 104 EEEP2: ACALL SSPEED ;send digits 4 and 3 (4.3:2.1 on LCD) 0031 1100 F 105 ACALL SHI ;turn on middle decimal point 0033 1100 F 106 ACALL SHI ;turn on colon 0035 EF 107 MOV A, R7 ;get the current windspeed 0036 1100 F 108 ACALL DAT2BCD ;convert it to BCD for display 0038 5004 109 JNC EEEP8 003A D200 F 110 SETB EXTREME ;if windspeed > 99, then set flag 003C 7499 111 MOV A, #MAXSPD ;and use '99' as speed 003E 1100 F 112 EEEP8: ACALL SSPEED ;send digits 2 and 1 0040 1100 F 113 ACALL SLOAD ;and tell the LCD to load the new numbers A51 MACRO ASSEMBLER WIND DATE 29/09/94 PAGE 3 LOC OBJ LINE SOURCE 114 0042 80D2 115 JMP LOOP ; } /* while(1) */ 116 117 0044 118 SSPEED: 119 ; Send SPEED 120 ; sends the two digit BCD number in A, one digit at a time, to the LCD 121 ; (also turning the decimal point off and blanking any leading zeros) 122 ; A: input number, changed at return 123 ; R5,B,C: changed 124 00F0 125 HIMASK EQU 11110000B ;high nibble mask 000F 126 LOMASK EQU 00001111B ;low nibble mask 0004 127 BITS EQU 4 ;number of bits in each number 128 0044 D282 129 SETB P0.2 ;TESTING made it to SSPEED 0046 FD 130 MOV R5, A ;make a copy of A so we don't booger it 0047 54F0 131 ANL A, #HIMASK ;mask off the lower digit 132 133 ; move the top bits down 0049 75F004 134 MOV B, #BITS ;for (b=BITS;b>0;b--) { 004C 03 135 EEEP6: RR A 004D D5F0FC 136 DJNZ B, EEEP6 ;rotate the bits down } 137 0050 700B 138 JNZ NOBLNK ;if not leading zero, do not send blank 0052 75F007 139 MOV B, #NUMSEG ;for (b=NUMSEG;b>0;b--) { 0055 1100 F 140 EEEP10: ACALL SLO ;send blank segment 0057 D5F0FB 141 DJNZ B, EEEP10 ; } 005A 020000 F 142 JMP EEEP11 ;skip sending zero 005D 1100 F 143 NOBLNK: ACALL SDIG ;send the digit 005F 1100 F 144 EEEP11: ACALL SLO ;send a low (turn off the decimal point) 0061 ED 145 MOV A, R5 ;retreive original A 0062 540F 146 ANL A, #LOMASK ;mask off the upper digit 0064 1100 F 147 ACALL SDIG ;and send the lower 0066 22 148 RET 149 0067 150 SDIG: 151 ; Send DIGit 152 ; sends the number (0-9) in A to the LCD 153 ; A: input BCD number (4 bits) 154 ; B, C: changed 155 0067 D283 156 SETB P0.3 ;TESTING made it to SDIG 0069 93 157 MOVC A, @A+DPTR ;get the appropriate segment info 158 159 ; do each of the NUMSEG segments 006A 75F007 160 MOV B, #NUMSEG ;for (b=NUMSEG;b>0;b--) { 006D 33 161 EEEP3: RLC A 006E 4005 162 JC EEEP4 0070 1100 F 163 ACALL SLO ;send a low to LCD data 0072 020000 F 164 JMP EEEP5 0075 1100 F 165 EEEP4: ACALL SHI ;send a high to LCD data 0077 D5F0F3 166 EEEP5: DJNZ B, EEEP3 ; } /* for */ 007A 22 167 RET 168 007B 169 DAT2BCD: 170 ; converts the number in A to a two digit (00-99) BCD number. If the 171 ; number is greater than 99 decimal, the carry bit is set 172 ; A: input number, output BCD <=99 A51 MACRO ASSEMBLER WIND DATE 29/09/94 PAGE 4 LOC OBJ LINE SOURCE 173 ; B: is changed 174 ; C: set if input number > 99 decimal 175 0063 176 MAXNUM EQU 99 ;biggest number we can handle 177 007B F5F0 178 MOV B, A 007D 7463 179 MOV A, #MAXNUM ;see if the number is too big 007F C3 180 CLR C 0080 95F0 181 SUBB A, B 0082 4009 182 JC EEEP1 0084 E5F0 183 MOV A, B 0086 75F00A 184 MOV B, #10 ;convert to decimal for display 0089 84 185 DIV AB ;places 10's in A and 1's in B 008A C4 186 SWAP A 008B 25F0 187 ADD A, B ;place the BCD digit in A 008D 22 188 EEEP1: RET 189 008E 190 SHI: 191 ; Send HIgh 192 ; Sends a high to the LCD buffer and clocks it in 193 008E D2B3 194 SETB P3.3 ;CLOCK hi 0090 D2B2 195 SETB P3.2 ;DATA hi 0092 1100 F 196 ACALL DELAY 0094 C2B3 197 CLR P3.3 ;CLOCK lo 0096 1100 F 198 ACALL DELAY 0098 22 199 RET 200 0099 201 SLO: 202 ; Send LOw 203 ; Sends a low to the LCD buffer and clocks it in 204 0099 D2B3 205 SETB P3.3 ;CLOCK hi 009B C2B2 206 CLR P3.2 ;DATA lo 009D 1100 F 207 ACALL DELAY 009F C2B3 208 CLR P3.3 ;CLOCK lo 00A1 1100 F 209 ACALL DELAY 00A3 22 210 RET 211 00A4 212 SLOAD: 213 ; Send LOAD 214 ; Sends a load to the LCD buffer 00A4 D2B1 215 SETB P3.1 ;LOAD hi 00A6 1100 F 216 ACALL DELAY 00A8 C2B1 217 CLR P3.1 ;LOAD lo 00AA 22 218 RET 219 00AB 220 DELAY: 221 ; DELAY between output changes to ensure proper data transmission through 222 ; the length of cable 00AB C0F0 223 PUSH B 00AD 75F028 224 MOV B, #CYCLES ;for(B=CYCLES;B<0;B--) 00B0 D5F0FD 225 EEEP9: DJNZ B, EEEP9 ;2 cycles per iteration 00B3 D0F0 226 POP B 00B5 22 227 RET 228 229 END A51 MACRO ASSEMBLER WIND DATE 29/09/94 PAGE 5 XREF SYMBOL TABLE LISTING ---- ------ ----- ------- N A M E T Y P E V A L U E ATTRIBUTES / REFERENCES B. . . . . D ADDR 00F0H A 89 95 134 136 139 141 160 166 178 181 183 184 187 223 224 225 226 BITS . . . N NUMB 0004H A 127# 134 BITVAR . . B SEG 0001H REL=UNIT 27# 62 CONST. . . C SEG 000AH REL=UNIT 26# 48 CYCLES . . N NUMB 0028H A 39# 224 DAT2BCD. . C ADDR 007BH R SEG=PROG 99 108 169# DELAY. . . C ADDR 00ABH R SEG=PROG 196 198 207 209 216 220# EEEP . . . C ADDR 0024H R SEG=PROG 94 98# EEEP1. . . C ADDR 008DH R SEG=PROG 182 188# EEEP10 . . C ADDR 0055H R SEG=PROG 140# 141 EEEP11 . . C ADDR 005FH R SEG=PROG 142 144# EEEP2. . . C ADDR 002FH R SEG=PROG 101 104# EEEP3. . . C ADDR 006DH R SEG=PROG 161# 166 EEEP4. . . C ADDR 0075H R SEG=PROG 162 165# EEEP5. . . C ADDR 0077H R SEG=PROG 164 166# EEEP6. . . C ADDR 004CH R SEG=PROG 135# 136 EEEP8. . . C ADDR 003EH R SEG=PROG 109 112# EEEP9. . . C ADDR 00B0H R SEG=PROG 225# 225 EXTREME. . B ADDR 0000H.0 R SEG=BITVAR 63# 79 102 110 HIMASK . . N NUMB 00F0H A 125# 131 INPORT . . N NUMB 00FFH A 34# 76 77 LOMASK . . N NUMB 000FH A 126# 146 LOOP . . . C ADDR 0016H R SEG=PROG 83# 115 MAXNUM . . N NUMB 0063H A 176# 179 MAXSPD . . N NUMB 0099H A 31# 103 111 NOBLNK . . C ADDR 005DH R SEG=PROG 138 143# NUMSEG . . N NUMB 0007H A 33# 139 160 P0 . . . . D ADDR 0080H A 75 85 100 129 156 P1 . . . . D ADDR 0090H A 76 86 P2 . . . . D ADDR 00A0H A 77 P3 . . . . D ADDR 00B0H A 78 194 195 197 205 206 208 215 217 PORT0. . . N NUMB 00F0H A 35# 75 PORT3. . . N NUMB 00F1H A 37# 78 PROG . . . C SEG 0000H REL=UNIT 25# 70 SDIG . . . C ADDR 0067H R SEG=PROG 143 147 150# SEGTAB . . C ADDR 0000H R SEG=CONST 51# 80 SHI. . . . C ADDR 008EH R SEG=PROG 105 106 165 190# SLO. . . . C ADDR 0099H R SEG=PROG 140 144 163 201# SLOAD. . . C ADDR 00A4H R SEG=PROG 113 212# SP . . . . D ADDR 0081H A 74 SSPEED . . C ADDR 0044H R SEG=PROG 104 112 118# STACK. . . I SEG 0010H REL=UNIT 28# 45 74 START. . . C ADDR 0000H R SEG=PROG 68 72# STSIZE . . N NUMB 0010H A 38# 46 WIND . . . ---- ---- 1 REGISTER BANK(S) USED: 0 ASSEMBLY COMPLETE, NO ERRORS FOUND