Page 2 of 2

Re: ASM programmer to write a simple IDE test loop program ?

Posted: Sat Mar 02, 2019 7:31 am
by Smonson
rpineau wrote: Sat Mar 02, 2019 2:36 am this should speed up the test as memcmp is most probably faster than going through the array (it's probably written in ASM).
Which libc are you thinking of? I wouldn't mind taking a look at their implementation. GCC 8.2 created this convoluted memcmp from what I thought was a pretty straightforward C func. It was long, so I didn't look too closely, I just decided to avoid it.

Code: Select all

int memcmp(const void *s1, const void *s2, size_t n)
{
    147c:       2f02            movel %d2,%sp@-
    147e:       206f 0008       moveal %sp@(8),%a0
    1482:       226f 000c       moveal %sp@(12),%a1
    while (n--) {
    1486:       4aaf 0010       tstl %sp@(16)
    148a:       6730            beqs 14bc <memcmp+0x40>
        if (*(uint8_t *)s1 != *(uint8_t *)s2)
    148c:       1010            moveb %a0@,%d0
    148e:       1211            moveb %a1@,%d1
    1490:       b001            cmpb %d1,%d0
    1492:       6616            bnes 14aa <memcmp+0x2e>
    1494:       5289            addql #1,%a1
    1496:       242f 0010       movel %sp@(16),%d2
    149a:       d488            addl %a0,%d2
            return *(uint8_t *)s1 - *(uint8_t *)s2;
        s1++;
    149c:       5288            addql #1,%a0
    while (n--) {
    149e:       b1c2            cmpal %d2,%a0
    14a0:       671a            beqs 14bc <memcmp+0x40>
        if (*(uint8_t *)s1 != *(uint8_t *)s2)
    14a2:       1010            moveb %a0@,%d0
    14a4:       1219            moveb %a1@+,%d1
    14a6:       b200            cmpb %d0,%d1
    14a8:       67f2            beqs 149c <memcmp+0x20>
            return *(uint8_t *)s1 - *(uint8_t *)s2;
    14aa:       0280 0000 00ff  andil #255,%d0
    14b0:       0281 0000 00ff  andil #255,%d1
    14b6:       9081            subl %d1,%d0
        s2++;
    }
    return 0;
}
    14b8:       241f            movel %sp@+,%d2
    14ba:       4e75            rts
    return 0;
    14bc:       7000            moveq #0,%d0
}
    14be:       241f            movel %sp@+,%d2
    14c0:       4e75            rts

Re: ASM programmer to write a simple IDE test loop program ?

Posted: Sat Mar 02, 2019 7:33 am
by Smonson
Actually in my updated version I changed the sectors from 507 bytes to 512, so I should actually compare it an array of 32-bit words instead if maximum speed is the goal.

Re: ASM programmer to write a simple IDE test loop program ?

Posted: Sat Mar 02, 2019 5:42 pm
by rpineau
yea, that gcc implementation is not really the best for sure.
I would have though that it would have done a loop with some optimization like if it's a multiple of 2 use cmp.w, if it's a multiple of 4 use cmp.l
Also instead of addq.l #1, use the (a0)+ and (a1)+more the 2 moves

Re: ASM programmer to write a simple IDE test loop program ?

Posted: Sun Mar 03, 2019 11:08 pm
by exxos
Smonson wrote: Sat Mar 02, 2019 2:01 am Try downloading it again, I've hopefully fixed the issues.
Its passed 3 times over so far..

Now I don't know if I fixed my board somehow, or the program update broke something :lol:

Do you still have the previous version ?

Re: ASM programmer to write a simple IDE test loop program ?

Posted: Mon Mar 04, 2019 1:49 am
by Smonson
Ummm, no, sorry. I can try changing the buffer size back to 507 bytes for you when I get home from work tonight, though. Maybe that's more likely to precipitate the failure.

Re: ASM programmer to write a simple IDE test loop program ?

Posted: Mon Mar 04, 2019 1:59 am
by exxos
Smonson wrote: Mon Mar 04, 2019 1:49 am Ummm, no, sorry. I can try changing the buffer size back to 507 bytes for you when I get home from work tonight, though. Maybe that's more likely to precipitate the failure.
No worries.. I'm using my program to verify.. And that is passing currently as well, so looks like I may have solved the issue I was having :)