ASM programmer to write a simple IDE test loop program ?

News,announcements,programming,fixes,game patches & discussions.

Moderator: troed

User avatar
Smonson
Posts: 274
Joined: Sat Oct 28, 2017 10:21 am

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

Post by Smonson » Sat Mar 02, 2019 7:31 am

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

User avatar
Smonson
Posts: 274
Joined: Sat Oct 28, 2017 10:21 am

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

Post by Smonson » Sat Mar 02, 2019 7:33 am

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.

User avatar
rpineau
Site Admin
Site Admin
Posts: 473
Joined: Thu Aug 17, 2017 6:08 pm
Location: USA
Contact:

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

Post by rpineau » Sat Mar 02, 2019 5:42 pm

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
Working ones : MegaSTE (68020) / TT030 / Falcon with AB040 & Eclipse / 1040STF
Need testing : Falcon with CT2

User avatar
exxos
Site Admin
Site Admin
Posts: 7141
Joined: Wed Aug 16, 2017 11:19 pm
Location: UK
Contact:

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

Post by exxos » Sun Mar 03, 2019 11:08 pm

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 ?
4MB STFM 1.44 FD- VELOCE+ 020 STE - 4MB STE 32MHz - STFM 16MHz - STM - MEGA ST - Falcon 030 CT60 - Atari 2600 - Atari 7800 - Gigafile - SD Floppy Emulator - PeST - HxC - CosmosEx - Ultrasatan - various clutter

https://www.exxoshost.co.uk/atari/ All my hardware guides - mods - games - STOS
https://www.exxoshost.co.uk/atari/last/storenew/ - All my hardware mods for sale - Please help support by making a purchase.

User avatar
Smonson
Posts: 274
Joined: Sat Oct 28, 2017 10:21 am

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

Post by Smonson » 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.

User avatar
exxos
Site Admin
Site Admin
Posts: 7141
Joined: Wed Aug 16, 2017 11:19 pm
Location: UK
Contact:

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

Post by exxos » Mon Mar 04, 2019 1:59 am

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 :)
4MB STFM 1.44 FD- VELOCE+ 020 STE - 4MB STE 32MHz - STFM 16MHz - STM - MEGA ST - Falcon 030 CT60 - Atari 2600 - Atari 7800 - Gigafile - SD Floppy Emulator - PeST - HxC - CosmosEx - Ultrasatan - various clutter

https://www.exxoshost.co.uk/atari/ All my hardware guides - mods - games - STOS
https://www.exxoshost.co.uk/atari/last/storenew/ - All my hardware mods for sale - Please help support by making a purchase.

Post Reply