@mateusz_s, post #28
// ---------------------------
file: asm.s
xdef _my_clear
_my_clear:
moveq #0,d0
loop:
move.l d0,(a0)+
move.l d0,(a0)+
subq.l #1,d1
bne loop
rts
// ----------------------------
file: main.c
void my_clear(
unsigned char* buffer asm("a0"),
long value asm("d1")
);
#define mysize 320*240
unsigned char* buffer;
main()
{
buffer = (unsigned char*)malloc(mysize * sizeof(unsigned char));
// ~1.42 s
// for (int i = 0; i < 10000; i++) memset(buffer, 0, mysize);
// ~7 s
for (int i = 0; i < 10000; i++) my_clear(buffer, mysize/8- 1);
} @drsky, post #30
@Kefir_Union, post #32
@kiero, post #33
// ---------------------------
file: asm.s
xdef _my_clear
_my_clear:
moveq #0,d0
loop:
move.l d0,(a0)+
move.l d0,(a0)+
move.l d0,(a0)+
move.l d0,(a0)+
move.l d0,(a0)+
move.l d0,(a0)+
move.l d0,(a0)+
move.l d0,(a0)+
subq.l #1,d1
bne loop
rts
// ----------------------------
file: main.c
unsigned char* buffer;
void my_clear(
unsigned char* buffer asm("a0"),
long value asm("d1")
);
#define mysize 3200*2400*5
int main(void)
{
buffer = (unsigned char*)malloc(mysize * sizeof(unsigned char));
printf("memsize: %d\n MB", mysize/1024);
for (int i = 0; i < mysize; i++)
{
buffer[i] = i;
}
long now = clock();
my_clear(buffer, mysize/32- 1);
float end = (float)(clock() - now) / CLOCKS_PER_SEC;
printf("my_clear time: %.5f\n\n", end);
now = clock();
memset(buffer, 0,mysize);
end = (float)(clock() - now) / CLOCKS_PER_SEC;
printf("memset time: %.5f\n\n", end);
return 0;
}@mateusz_s, post #34
odnośnie move16 - to ponoć ono robi READ i WRITE wiec jest 2x wolniesze:
Accesses by the MOVE16 instruction also do not allocate cache lines in the data cache foreither read or write misses. Read hits on either valid or dirty cache lines are read from thecache. Write hits invalidate a matching line and perform an external access. Interacting withthe cache in this manner prevents a large block move or block initialization implemented witha MOVE16 from being cached, since the data may not be needed immediately.
@mateusz_s, post #34
@Don_Adan, post #37
@Kefir_Union, post #38
@mateusz_s, post #34
@Hexmage960, post #40
@Kefir_Union, post #42
@Don_Adan, post #43