Mail Archives: djgpp/2001/01/09/15:06:33
DJ Delorie <dj AT delorie DOT com> skrev i
diskussionsgruppsmeddelandet:200101082101 DOT QAA05779 AT envy DOT delorie DOT com...
>
> > I'll test that. But the strange thing is that the code doesn't work on a
> > 386DX.....
>
> DJGPP was originally written on a 386DX. What, exactly, happens when
> you try to run it?
Here is the code:
init_con(&main_con); /* Init the main-console */
cls(); /* Clear the screen */
asm("nop\nnop\nnop\n"); /* Debugging information */
asm("nop\nnop\nnop\n");
asm("nop\nnop\nnop\n");
asm("nop\nnop\nnop\n");
asm("nop\nnop\nnop\n");
printsa("test before entering printk", 3, 3, 1);
printk("||<Z<z<Z"); /* Printk the line to the active console */
While I was debugging the code, I put a line I know works in printk instead
of the ordinary ones:
printsa("hehehe", 2, 3, 4);
This call will write "hehehe" on pos. 2 x 3 in attribute 4. The line above
printk, is a call to printsa. I can see that line on the screen. The printk
doesn't write any "hehehe" on the screen at all.
I checked the line printsa above the printk line in the debugger. I found
this:
15F6:055D E876FF CALL 04D6 <= Call to printsa
15F6:0560 FFFF ??? DI <= Continue of
the instruction above
15F6:0562 83C410 ADD SP,+10
15F6:0565 83C4F4 ADD SP,-0C
15F6:0568 68 DB 68
15F6:0569 1C05 SBB AL,05
15F6:056B 0000 ADD [BX+SI],AL
15F6:056D E8B609 CALL 0F26 <= Call to printk
-u 4d6
15F6:04D6 0000 ADD [BX+SI],AL <= the call jumps here
15F6:04D8 55 PUSH BP <= printsa's
beginning
15F6:04D9 89E5 MOV BP,SP
Here is a sample cut from an objdump output:
106: 6a 03 push $0x3
108: 68 c5 00 00 00 push $0xc5
10d: e8 76 ff ff ff call 88 <_printsa> <= The printsa
call. The printsa function is in the same .o file while....
112: 83 c4 10 add $0x10,%esp
115: 83 c4 f4 add $0xfffffff4,%esp
118: 68 cc 00 00 00 push $0xcc
11d: e8 de fe ff ff call 0 <.text> <= ....printk
isn't
122: 83 c4 10 add $0x10,%esp
00000088 <_printsa>:
88: 55 push %ebp
89: 89 e5 mov %esp,%ebp
8b: 83 ec 18 sub $0x18,%esp
8e: 8b 45 0c mov 0xc(%ebp),%eax
91: 8b 55 10 mov 0x10(%ebp),%edx
I don't really understand why the program is linked in this strange way...
Fredrik Hellman
- Raw text -