Quantcast
Channel: Question and Answer » assembly
Viewing all articles
Browse latest Browse all 23

ATmega328P assembler inline text and assembelr ALIGN

$
0
0

I have a program in assembler like this:

        lots of code
        ......

.ORG $7000 ;;  (or somewhere) 

atext:   .DB    "this is a test string 1"

         .ALIGN EVEN    

Btext:   .DB    "this is a test string 2"
  1. QUESTION : Assuming the length of text 1 is ODD- Is it possible to ALIGN Btext using some kínd of ALIGN command ( like above). The Atmel Assembler (studío 6.2) says NO – but I wonder….

(Problem easily solved by manually alignment like this:

atext:   .DB    "this is a test string 1",0,0
   //            01234567890123456789012  3 4      

And adding zeroes where needed to align.

  1. QUESTION :

I now want to write the text to my serial monitor.

So I do this;

      ldi zh,High (text1)
      ldi zl,LOW (text1)
      push ZH 
      push ZL 
      lsl ZL  
      rol ZH  ;; to ensure LPM later 

WRTE: lpm R16,Z+ ; get byte/data 
      cpi R16,0  
      breq wrte2 
      call output
      rjmp wrte 
wrte2: 

      pop zl
      pop zh
      ret 

Now I wonder: If I use

      ......       
WRTE: LD   R16,Z+      ; get byte/data /// BAD - DON'T 

  .....

What will I get in R16?


Viewing all articles
Browse latest Browse all 23

Trending Articles