This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Newbie Question about looping through ranges longer than 256

Hello forums, I started playing with a coding the 8051 after a long search for an assembly language to learn and it seemed like the way coolest one.
I looked around a bit for how to do this but I probably just couldn't word it correctly; what I'm trying to do is fill memory locations 0x0200-0x05ff with a certain value, doesn't matter what it is. If i had to just do something like fill locations 0x200-0x2ff it would be easy as I could just use:


   mov r0, # 100h
   mov dptr, # 200h
a: mov a, #27
   mov @dptr, a
   inc dptr
   djnz r0, a

but what is the best way to do it for more than 256 bytes?

Answers on a postcard please.

Parents
  • OK.
    Does decrementing a register which is 00H yields FFH?? In that case, this was a good conversation.

    i would have implemented it in following way.

              MOV  R1, count1
              MOV  A, #27
    L2:       MOV  R0, count2
    L1:       MOV  @DPTR, A
              INC  DPTR
              DJNZ R0, L1
              DJNZ R1, L2
    
     loop executes for count1*count2 times 
    

Reply
  • OK.
    Does decrementing a register which is 00H yields FFH?? In that case, this was a good conversation.

    i would have implemented it in following way.

              MOV  R1, count1
              MOV  A, #27
    L2:       MOV  R0, count2
    L1:       MOV  @DPTR, A
              INC  DPTR
              DJNZ R0, L1
              DJNZ R1, L2
    
     loop executes for count1*count2 times 
    

Children