Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
08/16/05 07:19
Read: times


 
#99492 - two tables
Responding to: ???'s previous message
hi,
I'm using this in a routine to display characters on a "5x7 Dot Matrix" display. I was just curious if there a way to back a simpler routine, than all those sequential commands. (i.e combination parameter like in basic you could say "goto ch$val" or something like that?)


Yes, C51 core contains JMP @A+DPTR command.
May I do another suggestion?
I would preffer to use tables like other people say here. In your case it should be two tables: one is characters` bitmaps and another is table of addresses of there bitmaps. Something like next:
BITMAPS_ADDRESSES:
   DW   0x0000     ; char with code 0x00 is not printable
   DW   0x0000     ; char with code 0x01 is not printable
; ....
   DW   BMP_SPACE  ; address of bitmap of char 'space' (0x20)
   DW   BMP_EXCLA  ; exclamation sign
; etc for all 256 possible signs

; Bitmaps
; - space
BMP_SPACE:
   DB   0x00,0x00,0x00,0x00,0x00
BMP_EXCLA:
   DB   0x00,0x00,0x7D,0x00,0x00
; etc for all printable signs

; Now you may easy print all your chars:
PRN_CHAR:
; A - code of the char

; check is char printable
; by loading its bitmap address
   MOV   DPTR,#BITMAPS_ADDRESSES
   ADD   A,ACC          ; due address contain two bytes
   JNC   PRN_CHAR_0
   INC   DPH            ; due table has 256+256 bytes
PRN_CHAR_0:
   MOV   R0,A
   INC   A
   MOVC  A,@A+DPTR      ; low byte of address
   XCH   A,R0
   MOVC  A,@A+DPTR      ; high byte of address
; load bitmap address into DPTR
   MOV   DPH,A
   MOV   DPL,R0
; check is address zero
   ORL   A,R0
   JZ    PRN_CHAR_EXIT  ; not printable char - exit
; printable char - DPTR contains its bitmap address
   CALL  PRN_BMP        ; display bitmap 7x5
PRN_CHAR_EXIT:
   RET
Note: this code is as it is typed; it may contain mistakes.

Regards,
Oleg


List of 14 messages in thread
TopicAuthorDate
Code optimization suggestion?            01/01/70 00:00      
   Table            01/01/70 00:00      
      Table?            01/01/70 00:00      
         Another table ...            01/01/70 00:00      
   CJNE            01/01/70 00:00      
      Everybody is saying to use a table            01/01/70 00:00      
         My confsion            01/01/70 00:00      
   two tables            01/01/70 00:00      
      Tables            01/01/70 00:00      
         sure            01/01/70 00:00      
            gurus don't subtract constants            01/01/70 00:00      
   16 bit table            01/01/70 00:00      
      bit table            01/01/70 00:00      
   Table indexing            01/01/70 00:00      

Back to Subject List