Coder Social home page Coder Social logo

the problem of test.c about memtest86 HOT 5 CLOSED

anphsw avatar anphsw commented on August 26, 2024
the problem of test.c

from memtest86.

Comments (5)

MoreAndMore34545 avatar MoreAndMore34545 commented on August 26, 2024

line 380 is here /* Original C code replaced with hand tuned assembly code /
/

for (; p <= pe; p++) {
*p = rand_32bits(me);
}
*/
line 386 is here asm volatile (
"jmp L200\n\t"
".p2align 4,,7\n\t"
"L201:\n\t"
"addl $4,%%edi\n\t"
"L200:\n\t"
"pushl %%ecx\n\t"
"call rand_32bits\n\t"
"popl %%ecx\n\t"
"movl %%eax,(%%edi)\n\t"
"cmpl %%ebx,%%edi\n\t"
"jb L201\n\t"
: : "D" (p), "b" (pe), "c" (me)
: "eax"
);

from memtest86.

anphsw avatar anphsw commented on August 26, 2024

Original code was written for very old GCC version (and not by me), and you compiling on the modern version of GCC, which may optimize code and can give incorrect results.
You can compile test.c with assembler output: in makefile add "-S" option:
$(CC) -S -c -Wall -march=i486 -m32 -O0 -fomit-frame-pointer -fno-builtin -ffreestanding -fno-pie -fno-stack-protector -std=gnu99 test.c

Compile will fail, but will produce test.s file with assembler source. You can compare then assembler results of original C code optimized by GCC and hand-tuned code.

Second, if you remove all assembly code from test.c, you can compile it without "-fno-pie -fno-stack-protector" options (as they added to support modern GCC versions) and see if it works.

from memtest86.

MoreAndMore34545 avatar MoreAndMore34545 commented on August 26, 2024

thanks a lot.
I have fix the problem.
the replaced c code should be as below:
/* Original C code replaced with hand tuned assembly code */
*p = rand_32bits(me);
for (; p < pe; ) {
p++;
*p = rand_32bits(me);
}

from memtest86.

MoreAndMore34545 avatar MoreAndMore34545 commented on August 26, 2024

the above c code could replace the assembly code
my GCC version is 5.4.0 on ubuntu 16.04

from memtest86.

anphsw avatar anphsw commented on August 26, 2024

Yes, it makes sense.
This code is unused, but if you will make commit fixing it, I will merge it. Or I can make it by myself, as you wish.

from memtest86.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.