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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
07/07/08 04:40
Read: times


 
#156447 - Printing a string
Responding to: ???'s previous message

I use the following to send out strings of characters for messages. The routine 'pstring' is immediately followed by the text to be sent which is embedded in the code using the db pseudo-operator in the assembler. The string is terminated in 00 which tells the routine that the string is ended, and execution resumes in the location following the location of 00.

pstring calls pbyte which is a trvial routine to send a character to the serial port which poll TI until set before sending a new character.

Note A, PSW and dptr are corrupted using pstring. There is an alternative to this method using movc A,@A+dptr which would work, but I have never bothered to develop it since this works.

Hope this helps.

Best regards,

Roger Blott

example lcall pstring
db 'This is a test string',13,0
lcall pstring
db 'This is another string',13,0

;sends string ending in $00 to serial port
pstring pop DPH ;get the address of data
pop DPL ;string into DPTR
pstring1 clr A ;ensure A is zero for fetch
movc A,@A+DPTR ;fetch data from memory
jz pstring2 ;terminates when charactor is $00
acall pbyte ;output character
inc DPTR ;next location
sjmp pstring1
pstring2 mov A,#1
jmp @A+DPTR

;sends a character to the serial port and waits for it to go
pbyte jnb TI,pbyte ;wait here for buffer access
clr TI ;clear TI
mov SBUF,A ;send data
ret



...replace this with your code...


List of 32 messages in thread
TopicAuthorDate
loading the SBUF shortcut?            01/01/70 00:00      
   Printing a string            01/01/70 00:00      
   Shortcut...NOT            01/01/70 00:00      
   You have to enrich your library of Assembly Code            01/01/70 00:00      
      that is not a shortcut            01/01/70 00:00      
         Library of Assembly Code            01/01/70 00:00      
            the key word            01/01/70 00:00      
               polled serial            01/01/70 00:00      
                  "living with interrupts "            01/01/70 00:00      
                     what I got out of all of this            01/01/70 00:00      
                        DPTR .... Yes!!            01/01/70 00:00      
                        Check out DPTR            01/01/70 00:00      
                     I AGREE            01/01/70 00:00      
                        agree with WHAT?            01/01/70 00:00      
                            I AGREE with ...            01/01/70 00:00      
   C shortcut            01/01/70 00:00      
      'C' confusion            01/01/70 00:00      
         Confused            01/01/70 00:00      
            Maybe, maybe not            01/01/70 00:00      
               printf baggage            01/01/70 00:00      
                  This should come as no surprise            01/01/70 00:00      
               27K lots of memory            01/01/70 00:00      
                  "C baggage"            01/01/70 00:00      
                     Getting off-topic            01/01/70 00:00      
                        I wholehardely agree            01/01/70 00:00      
         Shortcuts are for wimps!            01/01/70 00:00      
            Disagree            01/01/70 00:00      
            Half a million Lines?            01/01/70 00:00      
               I didn't use 'C' or other HLL's on the old PC            01/01/70 00:00      
   Poor choice of terms!            01/01/70 00:00      
      A subroutine?            01/01/70 00:00      
         more code-efficient that macros            01/01/70 00:00      

Back to Subject List