OSDev.org

The Place to Start for Operating System Developers
It is currently Fri Apr 19, 2024 3:24 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Unexpected output when printing to text video memory
PostPosted: Sat Apr 06, 2019 9:20 pm 
Offline

Joined: Sun Mar 10, 2019 11:55 pm
Posts: 4
Hello everyone . I develop a kernel in C and I created something that displays a message in the video memory.
But I had two cases: The first is that, when I do not make a link with a C file and the assembly kernel, the characters are displayed normally.
The second case, normally when I make a link with a C file, nothing happens.

In a way, I work on KAli linux. I have a C file, and two asm files. The C file is called screen.c which contains the character display functions. ASM files: a boot.asm for bootsectorwhich load PMODE and kernel.asm file (to use C code functions).

Here are the command lines I used to test my code:

gcc -m32 -c screen.c -o screen.o
nasm -f elf32 -o kernel.o kernel.asm
ld -m elf_i386 -Ttext 1000 kernel.o screen.o -o kernel
nasm -f bin -o boot boot.asm
cat boot kernel.o /dev/zero | dd of=floppyA bs=512 count=2880

Where is the problem ?
Can I give you my codes for more readability?


Attachments:
kernel.asm [318 Bytes]
Downloaded 18 times
File comment: COntain screen function
screen.c [1.46 KiB]
Downloaded 16 times
File comment: File for bootsector and load PMODE
bootsect.asm [1.94 KiB]
Downloaded 12 times
Top
 Profile  
 
 Post subject: Re: Unexpected output when printing to text video memory
PostPosted: Sun Apr 07, 2019 8:55 pm 
Offline
Member
Member

Joined: Fri Aug 26, 2016 1:41 pm
Posts: 692
It is how you are building. 1000 should be 0x1000 . You want to DD kernel, not kernel.o, you will need to have the linker output kernel as a binary file and not an ELF executable. Since you aren't using a cross compiler you'll likely need something like -fno-PIC . Something like this may work:
Code:
gcc -m32 -c screen.c -o screen.o -ffreestanding -fno-PIC
nasm -f elf32 -o kernel.o kernel.asm
ld -m elf_i386 --oformat=binary -Ttext 0x1000 kernel.o screen.o -o kernel
nasm -f bin -o boot boot.asm
cat boot kernel /dev/zero | dd of=floppyA bs=512 count=2880


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], FrankRay78, SemrushBot [Bot] and 154 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group