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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
Maarten Brock
08/24/05 14:10
Read: 916 times
The Netherlands

#100028 - problems
Responding to: Craig Steiner's previous message
Solution 1:
move:   inc     r6              ;For avoiding 255 loop if is 0 the value
        inc     r7
and after that:
        mov     a,dpl           ;Origin is lower than destination
        add     a,r7            ;We add the number of bytes to the origin
        mov     sum_l,a         ;And we check if overlaps with destination
        mov     a,dph
        addc    a,r6
        mov     sum_h,a

But r6:r7 are no longer the number of bytes!

And also:
up:     djnz    r7,up1
        djnz    r6,up1
up1:    movx    a,@dptr          ;We move the data in up direction
        inc     dptr
        mov     store,r4         ;Swap r4,dph
        mov     r4,dph
        mov     dph,store
        mov     store,r5         ;Meant to swap r5,dpl I guess
        mov     r4,dpl
        mov     dpl,r5
        movx    @dptr,a
        inc     dptr
        sjmp    up

This moves one byte from destination to source end the next from source to destination (if the swapping was done correctly)!

Solution 2:
   mov   a,r4        ;now determine copy direction 
   cjne  a,dph,BlkMovX2
   mov   a,r5 
   cjne  a,dpl,BlkMovX2
   jnc   BlkMovDwn
BlkMovUp:           ;----------- LDIR -------------
   mov   P2,r4       ;prepare destination address for movx @r0,a
;   mov   r0,ar5
   mov   r0,a         ;!trick - a already contains r5

If dph != r4 then a == r4, not r5!

Solution 3:
      mov a,r7
      orl a,r6
      jz  done
      dec r7
      jnz mv10
      dec r6

Decrementing r7 does not affect the "zero flag"!

Now you may guess where my vote went.

List of 11 messages in thread
Second challenge done      Maarten Brock      08/24/05 07:31      
   Vote rules:      José Félix Díaz Ivorra      08/24/05 08:22      
      Sounds like karma      Craig Steiner      08/24/05 11:31      
         problems      Maarten Brock      08/24/05 14:10      
            nowhere?      Erik Malund      08/24/05 14:53      
               Nope      Maarten Brock      08/25/05 03:09      
                  Simulator      José Félix Díaz Ivorra      08/25/05 08:14      
                  Problems      Craig Steiner      08/25/05 09:37      
      a better idea?      Erik Malund      08/25/05 06:55      
   Jan      Craig Steiner      08/27/05 19:12      
      error      Jan Waclawek      08/29/05 08:18      

Back to Subject List