145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org/* 245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * test source file for assembling to COFF 345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * build with (under DJGPP, for example): 445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * yasm -f coff cofftest.asm 545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org * gcc -o cofftest cofftest.c cofftest.o 645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org */ 745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#include <stdio.h> 945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 1045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgextern int lrotate(long, int); 1145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgextern void greet(void); 1245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgextern char asmstr[]; 1345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgextern void *selfptr; 1445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgextern void *textptr; 1545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgextern int integer, commvar; 1645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 1745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgint main(void) { 1845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 1945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org printf("Testing lrotate: should get 0x00400000, 0x00000001\n"); 2045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org printf("lrotate(0x00040000, 4) = 0x%08lx\n", lrotate(0x40000,4)); 2145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org printf("lrotate(0x00040000, 14) = 0x%08lx\n", lrotate(0x40000,14)); 2245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 2345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org printf("This string should read `hello, world': `%s'\n", asmstr); 2445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 2545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org printf("The integers here should be 1234, 1235 and 4321:\n"); 2645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org integer = 1234; 2745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org commvar = 4321; 2845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org greet(); 2945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 3045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org printf("These pointers should be equal: %p and %p\n", 3145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org &greet, textptr); 3245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 3345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org printf("So should these: %p and %p\n", selfptr, &selfptr); 3445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org} 35