??? 08/24/05 20:10 Read: times |
#100028 - problems Responding to: ???'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 ret 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 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: normalmove: 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. |
Topic | Author | Date |
Second challenge done | 01/01/70 00:00 | |
Vote rules: | 01/01/70 00:00 | |
Sounds like karma | 01/01/70 00:00 | |
problems | 01/01/70 00:00 | |
nowhere? | 01/01/70 00:00 | |
Nope | 01/01/70 00:00 | |
Simulator | 01/01/70 00:00 | |
Problems | 01/01/70 00:00 | |
a better idea? | 01/01/70 00:00 | |
Jan | 01/01/70 00:00 | |
error | 01/01/70 00:00 |