ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
The "disassembly" of your startup code (second stage after the loader) looks like this
Code:
db 8Ch ; Œ
db 0C8h ; È
db 8Eh ; Ž
db 0D0h ; Ð
db 8Eh ; Ž
db 0D8h ; Ø
db 0E9h ; é
db 0B6h ; ¶
db 0Bh
At any time ten through twenty years ago, I could have looked at that and known what the instructions were without any noticeable effort. But I haven't worked on such things more recently and the above means little more to me than it does to most programmers.
Without that key part, it's hard to guess where you went wrong.
But I really doubt you wanted "small" memory model. I think you wanted "tiny" (use the -mt switch on the tcc line). I can see by the reference and definition of word_C5A in your disassembly that you have not ended up with "tiny" memory model, so getting the right value for DS and SS would be tricky.
In your other thread, I asked about the disassembly of a specific function, because your mixture of C and asm in that function was done in a way I didn't recognize. Your attachment above included that:
Code:
sub_425 proc near ; CODE XREF: seg000:0471p seg000:0ED0p ...
arg_0 = byte ptr 4
push bp
mov bp, sp
mov ah, 0Eh
mov al, [bp+arg_0]
mov bl, 0Fh
int 10h ; - VIDEO - WRITE CHARACTER AND ADVANCE CURSOR (TTY WRITE)
; AL = character, BH = display page (alpha modes)
; BL = foreground color (graphics modes)
pop bp
retn
sub_425 endp
That function is correct, so that method of mixing C and asm must be OK. Of course we had already deduced by symptoms that function was working and the memory model is not consistent with the value in the DS register.
Last edited by johnsfine; 10-01-2009 at 05:04 PM..
That is the right segment register initialization for tiny memory model. So when you change your tcc command to include the -mt switch, it might work. I'm still not sure whether the .com offset of 0x100 is properly considered everywhere, so that might also make data references wrong. But I think your results are closer to working they would be with a 0x100 offset error.
BTW, there is a very strange instruction
mov si, cs
after the code that displays "Hello world!" one character at a time. Is that from mixing in asm code or did the C compiler generate it? Anyway, I really don't think it is correct at that point.
Last edited by johnsfine; 10-01-2009 at 05:18 PM..
Distribution: Damn Small Linux, KateOs, M$ Ickdows Vista, My own OS
Posts: 1,233
Thanked: 59
Original Poster
ok i want it to print :
Code:
Hello World!
Hey!
but its printing
Code:
Hello World!
V.
the Hello World! is loaded into the registers directally as should be seen on the last
procedure in the disasm
btw are you the same johnsfine as the one that made the johnsfine bootloader?
Last edited by smeezekitty; 10-01-2009 at 05:22 PM..
Reason: question mark
Now that I look at it, I remember it. I'm having trouble believing that was just ten years ago. It feels like longer. Maybe Joel M. Gompert changed the date when making other minor changes when reposting my code (but his tutorial is dated in 2001 and his copy of my code is dated 1999, so maybe it just feels like longer).
Distribution: Damn Small Linux, KateOs, M$ Ickdows Vista, My own OS
Posts: 1,233
Thanked: 59
Original Poster
i'm still confused
the data is at the end of the disassembly yet i just cant read it
also how do you get the address of and hook interrupt vectors without dos
i'm still confused
the data is at the end of the disassembly yet i just cant read it
Because you aren't compiling with tiny memory model.
Quote:
how do you get the address of and hook interrupt vectors without dos
Interrupt vectors are at fixed and documented addresses at the beginning of memory. Read any x86 processor manual for all the specifics. You don't need dos.
If you want to hook them using C code, you need far pointers. I don't recall how you declare and use far pointers in Turbo C in small or tiny memory model. Maybe you can find that in the documentation.
If you know asm, then you can use asm code rather than C code to hook the interrupt vectors.
BTW, are you trying to write a 16 bit kernel? That's an odd choice.
If you want to write a 32 or 64 bit kernel, the 16 bit code loaded by the bootstrap shouldn't do much more than create the environment for the 32 or 64 bit code. That shouldn't involve hooking any interrupts in 16 bit mode. Interrupts vectors work a different way in 32 bit and 64 bit modes.
Last edited by johnsfine; 10-01-2009 at 06:17 PM..
if i compile with -mt switch i get a linker error:
Undefine symbol DGROUP
Any idea where in your code you use DGROUP?
In tiny model, there is no reason to use DGROUP and it isn't normally defined. Since tcc can normally compile tiny model code, I assume there is something unusual in your code to make it need DGROUP.
Even if you wanted to stay with "small" memory model (which would require loading a different value into DS and SS than you code now loads) any reference to DGROUP in your code would still be wrong, because DGROUP requires the DOS .exe loader.
Apparently exetobin just ignores anything in the code that won't run right except in a .exe. Other methods of producing the .bin or .com give error messages for things like use of DGROUP that would make the resulting .com run incorrectly.
Last edited by johnsfine; 10-01-2009 at 06:25 PM..
Distribution: Damn Small Linux, KateOs, M$ Ickdows Vista, My own OS
Posts: 1,233
Thanked: 59
Original Poster
how do it remove the dgroup?
and yes this is a 16bit kernel i see no reason not to use 16bit as i want it to run
on really really old hardware
also the interrupt vector setting system did not work
Code:
void setvector(unsigned char inter, unsigned long ptr){
long far *p = 0;
p[inter] = ptr;
}
unsigned long getvector(unsigned char inter){
long far *p = 0;
return p[inter];
}
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.