multiply 6 for mapping ascii

Status
Not open for further replies.

auri_z

New Member
hi...

i try to improve my program for led matrix. my original program mapping charakter not in PIC16f877A. i try to build my project with mapping charakter in PIC16F877A. after reading some refences i just found nigel's tutorial with mapping character uC and with assembly . the other use high laungauge such C or picbasic.

in nigel's it use multiply for get corret data table for ascii. my problem is i use 5x7 led matrix so my data 6 bytes for each character in nigel's use 8 bytes so he use multiply 8 for get correct table data. i searching on net how to multiply just found multiply for 2,4,8,16 etc nothing with 6.

help me to do multiply 6 or the other way to fecth data table for ascii .here code from nigel's.it's original from nigel's so still multiply by 8.

Code:
 Message        
                    
            call        String_Table    ;get a character from the string table
            xorlw      0x00            ;is it a zero? - if so end of string
            btfsc       STATUS, Z
            goto        run1
            movwf    tmp2
            movlw    0x20            ;subtract to get character index value
            subwf    tmp2, w    
            call        Load_Char
            incf        offsetL1, f        ;increment 16 bit pointer to string
            btfsc       STATUS    , Z
            incf        offsetH1, f
            goto     Message
            
     
            
   Load_Char  
            movwf    offsetL
            clrf    offsetH
            bcf    STATUS, C        ;clear carry
            rlf    offsetL, f        ;multiply index value by 8
            rlf    offsetH, f
            bcf    STATUS, C        ;clear carry
            rlf    offsetL, f
            rlf    offsetH, f
            bcf    STATUS, C        ;clear carry
            rlf    offsetL, f
            rlf    offsetH, f    
            movlw    0x6            ;each character stroge 6 bytes
            movwf    cacah

    next  call        ASCII_Table
            movwf    27h
            call        shift
            call        gerak
            incf        offsetL, f        ;increment 16 bit pointer to string
            btfsc       STATUS    , Z
            incf        offsetH, f
            decfsz    cacah,1
            goto        next
            return

Code:
 ASCII_Table                      ;perform read from long table
            movlw    High(Table)
            addwf    offsetH, W
            movwf    PCLATH
            movlw    Low(Table)
            addwf    offsetL, w
            btfsc       STATUS    , C
            incf        PCLATH, f
            movwf   PCL
        
    String_Table                      ;perform read from long table
            movlw    High(String)
            addwf    offsetH1, W
            movwf    PCLATH
            movlw    Low(String)
            addwf    offsetL1, w
            btfsc       STATUS    , C
            incf        PCLATH, f
            movwf     PCL       

table ......

string....

here my code
 

Attachments

  • font string.asm
    7 KB · Views: 165
x1 = (x * 4)
which can be done as; x1 = (x << 2)

x2 = (x * 2)
which can be done as; x2 = (x << 1)

result = (x1 + x2)

----------------------------------------------
or you can do;

result = (x + x + x + x + x +x)

----------------------------------------------
or a combination;

x1 = (x << 1)
x2 = (x1 << 1)
result = (x1 + x2)

or;

x1 = (x << 1)
result = (x1 + x1 + x1)

etc. Largely it depends on what is the most important resource, if you must save ram, or save rom, or save time.
 
thank Mr RB...

after reading book Microcontroller Programming The Microchip PIC® By Julio Sanchez i found method for multiply. it's also approach same as yours. my problem was solved. i use shift twice and add twice. but in my case because my program use offsetL dan offsetH I must test if there overflow for offsetL and if happen offsetH must increment by 1 its because table data greater dan 256 bit. earlier i don't increment offsetH just shift twice and add twice and my character don't show correctly after same trial and error i can solve my problem.

is there difference between just shift and shiff with add because i see nigel's tutorial not increment offsetH but his code work properly. ( just curious)
 
Hi auri_z if you using 5X7 font sizes then you need to multiply by 5.For the character separator column you need to show a blank line.If you add this blank columns (0x00) in your table then if there is 100 characters you are adding 100 separator columns you are wasting program memory.

You just need a 8 bit X 8 bit multiplication routine.Find in piclist website.

Higher byte will be incremented if there is any carry from the lower byte.Otherwise anytime you won't increment it.
 
hi Gayan
i was try multiply by 8 and using font 5x7 it,s not working. code for fecth table don,t get corret address. i try use multiply 5 and it's working, but to make display more good I use blank between each charakter. what you suggestion is good, i will try to make it for my program in future but for now i stiil use 6 bit data table with 1 bit as blank because my program still simple and PIC16F877A have enough program memory.

i attachment my code below, but my code still not good (no comment and algorithm bad.)

i use font 5x7 and use 6 bit each charakter. my code was working but i hope you can give same more advice for same improve in my code speacial in in routine shift.

Code:
shift    movf        temp+d'1',0
                   movwf      temp+d'0'
                   movf        temp+d'2',0        
                   movwf       temp+d'1'  
                   ...
                   .....
                   movf        temp+d'72'
                   movwf      temp+d'71'
my routine for shift still use old-fashioned. i was use array for variable and procedure display. is my routine still make more short like routine display. i try but still don't can make like my routine display.

here my question about make array, there my question was answered but i still don,t can make for shift routine.
https://www.electro-tech-online.com/threads/make-assembly-more-simple.112101/

sorry my english is bad..
 

Attachments

  • mau jadi.asm
    12.5 KB · Views: 178
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…