ASM programmer to write a simple IDE test loop program ?

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

Moderator: troed

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

ASM programmer to write a simple IDE test loop program ?

Post by exxos » Thu Feb 28, 2019 10:14 pm

Can any of you ASM guys do something like this but in ASM ? Its painfully slow in Basic :(

All it does is write a string loads of times to a file to make 50MB worth of data. Then reads the file back in line by line (about 500bytes per line string) and compares the string in the file to the string in RAM.. then repeats for the whole file.

So if the file is corrupted at any point, the program would report a failure.

I think part of the slowness is a string comparison rather than binary stuff.


Code: Select all

ID=freewind 
WINDOW OPEN ID,"" ,20,20,300,150,1

print "CRAPPY HARD DRIVE TESTER V2.01"

'create string

DIM A$,B$,A,C$,P,C,SZ,MB

A$="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-*!"

B$=""
FOR A=1 TO 13
B$=B$+A$
NEXT A

SZ=100000 ' 50MB

PRINT ""
PRINT " SAVING "+STR$(SZ) +" SECTORS "
PRINT ""

OPEN "BLAH.TXT" for OUTPUT AS #3

FOR A=1 TO SZ
C=C+1
print #3,B$
IF C>5000 THEN PRINT "."; : C=0
NEXT A

close #3

PRINT ""
PRINT " READING & CHECKING SECTOR"
OPEN "BLAH.TXT" FOR INPUT AS #4

F=0

C=0
PRINT ""

FOR A=1 TO SZ
LINE INPUT #4,C$
IF C>5000 THEN PRINT "."; : C=0
	IF C$ = B$ THEN 
		F=F+1
	ELSE
		PRINT "FAILED":END
	END IF

C=C+1
NEXT A

PRINT ""
CLOSE #4

	IF F=SZ THEN 
	PRINT " TESTED OK"
	ELSE
	PRINT " FAILED"  :END
    END IF


PRINT ""


END

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: 280
Joined: Sat Oct 28, 2017 10:21 am

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

Post by Smonson » Fri Mar 01, 2019 11:19 am

I ported it to C. Apparently the reads and writes take about the same amount of time, but the comparison takes aaaaaaaaaages.

I sped it up slightly by using 0-255 as the filler data instead of a string. So I can just check each byte against the byte count, which is quicker than comparing two memory reads.

Sorry, I couldn't work out how to attach a file to the forum.

http://smonson.com/unmanaged/atari/HDDTEST.PRG

User avatar
exxos
Site Admin
Site Admin
Posts: 8230
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 » Fri Mar 01, 2019 11:28 am

Awesome thanks, love the name! It looks like it is saving a lot faster... Will leave it on for a bit and see what happens..

:thanksyellow:


EDIT:

It saved the sectors already that was fast! The verify, I can see the light flashing like five times faster than my code!

I will put in a iffy CF card and see if it triggers up a error!


EDIT2:

Took like 20mins to verify, takes like 2 hours with my code :lol:
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: 280
Joined: Sat Oct 28, 2017 10:21 am

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

Post by Smonson » Fri Mar 01, 2019 1:05 pm

Great! Glad I could save you some time 😊

User avatar
exxos
Site Admin
Site Admin
Posts: 8230
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 » Fri Mar 01, 2019 1:10 pm

Smonson wrote:
Fri Mar 01, 2019 1:05 pm
Great! Glad I could save you some time 😊
Oddly this one passes over my program :shrug:
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
exxos
Site Admin
Site Admin
Posts: 8230
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 » Fri Mar 01, 2019 1:36 pm

Okay tell a lie, fourth time it found a error...

If you are writing 0-255, maybe you could output the number as well ? May help in translating it to binary so we can see if any particular data bit is failing or not..


IMG_3832.JPG
IMG_3832.JPG (66.25 KiB) Viewed 1004 times
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
exxos
Site Admin
Site Admin
Posts: 8230
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 » Fri Mar 01, 2019 10:06 pm

I've been looking into this a bit more.. Then got it to output the failed line...


The top line is correct, the bottom line is incorrect.. It looks like data isnt corrupted as such, there just is to be too much of it..

fl.jpg
fl.jpg (27.73 KiB) Viewed 959 times
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: 280
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 1:44 am

Oh crap! Something's seriously wrong with my error message these. To be honest with you I didn't actually test the failure part, since it was getting quite late.

User avatar
Smonson
Posts: 280
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 2:01 am

Try downloading it again, I've hopefully fixed the issues.

Here's my code.

Code: Select all

extern "C" {
#include <gemdos.h>
#include <libc.h>
}

#define BUFFER_SIZE 512
#define BUFFER_REPEATS 100000

uint8_t buffer[BUFFER_SIZE];
uint8_t read_buffer[BUFFER_SIZE];

void check_error(int condition, const char *message) {
  if (condition) {
    printf("Error: %s.\nPress any key to exit.", message);
    Cconin();
    exit(1);
  }
}

void print_binary(uint8_t byte) {
  for (int bit = 1 << 7; bit; bit >>= 1) {
    printf("%c", byte & bit ? '1' : '0');
  }
}

int main(int argc, char **argv)
{
  printf("\x1b");
  printf("E");
  printf("Crappy hard drive tester V2.01 + a bit\n");

  // Fill buffer up with various data values
  for (int a = 0; a < BUFFER_SIZE; a++) {
    buffer[a] = a;
  }

  // Create a 512,000,000-byte file
  FILE handle = Fcreate("FILE.TXT", 0);
  check_error(handle < 0, "Couldn't create file");
  printf("\nSaving %d sectors\n", BUFFER_REPEATS);
  for (uint32_t count = 0; count < BUFFER_REPEATS; count++) {
    int32_t result = Fwrite(handle, BUFFER_SIZE, buffer);
    check_error(result < 0, "Write error");
    if (count % 5000 == 4999) {
      printf(".");
    }
  }
  printf("\n");
  Fclose(handle);

  // Re-read the file and check the contents are the same
  printf("\nReading and checking sectors\n");
  handle = Fopen("FILE.TXT", GEMDOS_RDONLY);
  check_error(handle < 0, "Couldn't open file for read");
  for (uint32_t count = 0; count < BUFFER_REPEATS; count++) {
    int32_t result = Fread(handle, BUFFER_SIZE, read_buffer);
    check_error(result < 0, "Read error");

    /* To test the failure condition */
    if (0) {
      if (count == 10) {
        read_buffer[307] = 128;
      }
    }

    for (int byte = 0; byte < BUFFER_SIZE; byte++) {
      if (read_buffer[byte] != (byte & 0xff)) {
        printf("Data mismatch: expected 0b");
        print_binary(byte & 0xff);

        printf("\n                   read 0b");
        print_binary(read_buffer[byte]);
        printf("\nPress any key to exit.\n");
        Cconin();
        exit(1);
      }
    }
    if (count % 5000 == 4999) {
      printf(".");
    }
  }
  printf("\n");
  Fclose(handle);

  printf("\nTested OK.\n");
  printf("\nPress any key to exit\n");
  Cconin();

  return 0;
}

User avatar
rpineau
Site Admin
Site Admin
Posts: 494
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 2:36 am

You could use memcmp to compare the 2 buffers and only go in the "slow" comparison to display the error if memcmp fails.

Code: Select all

	 if(memcmp(buffer, read_buffer, BUFFER_SIZE) != 0) {
		 for (int byte = 0; byte < BUFFER_SIZE; byte++) {
			if (read_buffer[byte] != (byte & 0xff)) {
			  printf("Data mismatch: expected 0b");
			  print_binary(byte & 0xff);

			  printf("\n                   read 0b");
			  print_binary(read_buffer[byte]);
			  printf("\nPress any key to exit.\n");
			  Cconin();
			  exit(1);
			}
		 }
    }
this should speed up the test as memcmp is most probably faster than going through the array (it's probably written in ASM). You'll probably need to include string.h
Working ones : MegaSTE (68020) / TT030 / Falcon with AB040 & Eclipse / 1040STF
Need testing : Falcon with CT2

Post Reply

Return to “SOFTWARE PROGRAMMING & DISCUSSION”