;*************************************************************************** ; ; File Name :"TABLES.asm" ; Title :Constant data ; Date :98.07.21 ; Version :0.01 ; Support telephone :765 287 1987 David B. VanHorn ; Support fax :765 287 1989 ; Support Email :dvanhorn@cedar.net ; Target MCU :AT90S8515 ; ;*************************************************************************** ; ; M O D I F I C A T I O N H I S T O R Y ; ; rev. date who why ; ---- -------- --- ------------------------------------------ ; 0.01 98.07.29 dvh Creation ; 0.02 98.09.27 dvh Added servo min and range tables for fast servo math ; ; ;************************************************************************* ;The provided example could be implemented as an algorithm, simply adding ;30h to the input byte, but in the table implementation, any value can be ;used. This is good for functions where the translation algorithm is unknown ;or arbitrary. Mainly I wanted a clear example of table based translation. ;************************************************************************* ; ;.org $F00 ;Arbitrary point in romspace ;Optionally, comment out the .org directive, and ;the table will float at the end of the code ;provided it is the LAST FILE included in MAIN ; ;Nothing prevents you from splattering your tables ;throughout the rom space, but it's neater this way :) .cseg ; ;************************************************************************* ; ;Just an example table for now. ; ; BIN2ASC_TAB: ; 0 1 2 3 4 5 6 7 8 9 A B C D E F .db $30,$31,$32,$33,$34,$35,$36,$37,$38,$39,$41,$42,$43,$44,$45,$46 ; ;************************************************************************* ; ;Example table-reading code. Converts a binary value in TEMP to ASCII. ;To keep it simple we assume that the calling routine will only pass us ;values 0-F, otherwise we will read past the end of the table ; ;Note that this routine does not care where the table is located. ; ;Read_Table: ; ldi R30,low(BIN2ASC_TAB*2) ;Make the Z reg point at the table ; ldi R31,high(BIN2ASC_TAB*2) ;preparing for the LPM instruction ; add R30,TEMP ;Add the calculated offset ; brcc RT_A ;If no carry, then we're done ; inc R31 ;Handle carry ; ;RT_A: ; lpm ;look up character ; ret ; ;I assume external hardware will take care of current control in half step mode ; ; BIG HAIRY NOTE! Because of the way that the assembler works, and ;the fact that EPROM is 16 bit words, tables built as follows are ;actually allocating one word per byte, Have a look at the read routine ;in STEPPER.ASM for these tables as opposed to the one above. Both ;work, but putting more than one byte per .db statement results in ;more efficient use of the romspace. ; Full_Step_Table: .db $08 ;1000 Full current .db $04 ;0100 Full current .db $02 ;0010 Full current .db $01 ;0001 Full current Half_Step_Table: .db $08 ;1000 Full current .db $0C ;1100 Half current .db $04 ;0100 Full current .db $06 ;0110 Half current .db $02 ;0010 Full current .db $03 ;0011 Half current .db $01 ;0001 Full current .db $09 ;1001 Half current ; ;These 16 bit constants are computed at assembly-time, in equates.inc. ;This just places them in ROM so we can extract them easily. ; Servo_Min_Table: .dw Servo_1_Min .dw Servo_2_Min .dw Servo_3_Min .dw Servo_4_Min .dw Servo_5_Min .dw Servo_6_Min .dw Servo_7_Min .dw Servo_8_Min Servo_Range_Table: .dw Servo_1_Range .dw Servo_2_Range .dw Servo_3_Range .dw Servo_4_Range .dw Servo_5_Range .dw Servo_6_Range .dw Servo_7_Range .dw Servo_8_Range Signon_Message: ; 00000000011111111112222222222333 3 3 3 3 3 3 3 ; 12345678901234567890123456789012 3 4 5 6 7 8 9 .db "AVR8515 Startup program version ","MAJOR_REV",".","Minor_Rev","Minor_RevB",CR,LF,NUL ; ;************************************************************* ; MORSETAB: ;Space and ! are not encoded in morse, and so they ;have no entry, but space is legal in ASCII. ASC2MORSE ;strips these two before calling the table. ;Each entry is either a dot(00) dash (01) or stop (11) ;not space-efficient, but real fast to look up, and ;simple to code for. ;index is (ASCII-22h)*2 Convert LC to UC as morse has ;no case. ;illegals are all stop(11) ;space should be a special case that generates an inter ;word timing. .DB 00010000 ; .DB 01001111 ;AF(22H) .DB 11111111 ; .db 11111111 ; (23H) .DB 01000000 ; .db 10000011 ;SX(24H) .DB 11111111 ; .db 11111111 ; .DB 11111111 ; .db 11111111 ; .DB 00010101 ; .db 01001111 ;WG(27H) .DB 11111111 ; .db 11111111 ; .DB 01000101 ; .db 00111111 ;KN(29H) .DB 01000101 ; .db 00011111 ;KK .DB 00010001 ; .db 00111111 ;AR .DB 01010000 ; .db 01011111 ;MIM .DB 01000000 ; .db 00011111 ;DU .DB 00010001 ; .db 00011111 ;AAA .DB 01000001 ; .db 00111111 ;DN .DB 01010101 ; .db 01111111 ;0 .DB 00010101 ; .db 01111111 ;1 .DB 00000101 ; .db 01111111 ;2 .DB 00000001 ; .DB 01111111 ;3 .DB 00000000 ; .DB 01111111 ;4 .DB 00000000 ; .DB 00111111 ;5 .DB 01000000 ; .DB 00111111 ;6 .DB 01010000 ; .DB 00111111 ;7 .DB 01010100 ; .DB 00111111 ;8 .DB 01010101 ; .DB 00111111 ;9 .DB 01010100 ; .DB 00001111 ;OS .DB 01000100 ; .DB 01001111 ;KR .DB 11111111 ; .DB 11111111 ; .DB 01000000 ; .DB 01111111 ;BT .DB 11111111 ; .DB 11111111 ; .DB 00000101 ; .DB 00001111 ;IMI .DB 11111111 ; .DB 11111111 ; .DB 00011111 ; .DB 11111111 ;A .DB 01000000 ; .DB 11111111 ;B .DB 01000100 ; .DB 11111111 ;C .DB 01000011 ; .DB 11111111 ;D .DB 00111111 ; .DB 11111111 ;E .DB 00000100 ; .DB 11111111 ;F .DB 01010011 ; .DB 11111111 ;G .DB 00000000 ; .DB 11111111 ;H .DB 00001111 ; .DB 11111111 ;I .DB 00010101 ; .DB 11111111 ;J .DB 01000111 ; .DB 11111111 ;K .DB 00010000 ; .DB 11111111 ;L .DB 01011111 ; .DB 11111111 ;M .DB 01001111 ; .DB 11111111 ;N .DB 01010111 ; .DB 11111111 ;O .DB 00010100 ; .DB 11111111 ;P .DB 01010001 ; .DB 11111111 ;Q .DB 00010011 ; .DB 11111111 ;R .DB 00000011 ; .DB 11111111 ;S .DB 01111111 ; .DB 11111111 ;T .DB 00000111 ; .DB 11111111 ;U .DB 00000001 ; .DB 11111111 ;V .DB 00010111 ; .DB 11111111 ;W .DB 01000001 ; .DB 11111111 ;X .DB 01000101 ; .DB 11111111 ;Y .DB 01010000 ; .DB 11111111 ;Z(5A) .DB 11111111 ; .DB 11111111 ; .DB 11111111 ; .DB 11111111 ; .DB 11111111 ; .DB 11111111 ; .DB 11111111 ; .DB 11111111 ; .DB 00000101 ; .db 00011111 ;IQ(5f) ; ;************************************************************* ;