Results 1 to 10 of 12
hey i am working on making an os and i am wondering if anybody knows the option to get the gcc compiler to work in 16 bit or real mode.
...
- 05-02-2009 #1Just Joined!
- Join Date
- Mar 2009
- Posts
- 37
gcc realmode
hey i am working on making an os and i am wondering if anybody knows the option to get the gcc compiler to work in 16 bit or real mode.
any help wold be helpful
- 05-02-2009 #2
I look at the very same thing and the closest I could get was using the asm directive .code16...Hope this helps...Gerard4134
i.e. __asm__ (".code16\n\t"); in C ocde
or
.code16
in assemblerMake mine Arch Linux
- 05-02-2009 #3
Here's an example of making a boot disk that will display G4143 in the top left hand corner and then loop forever....G4143
Just copy the code, compile and then place a floppy in the floppy drive and execute and presto a bootable floppy that will boot up and display 'G4143'....Note the hex or assembler is 16 bit...
Code:#include<stdio.h> #include<stdlib.h> #include<fcntl.h> /* .code16 .section .data .scetion .text .global _start _start: movw $0xb800, %ax movw %ax, %es movb $0x41, %es:0 movb $0x1f, %es:1 movb $0x34, %es:2 movb $0x1f, %es:3 movb $0x31, %es:4 movb $0x1f, %es:5 movb $0x34, %es:6 movb $0x1f, %es:7 movb $0x33, %es:8 movb $0x1f, %es:9 loop1: jmp loop1 */ //displays G4143 at boot up and the loop forever char boot_buf[512] = { 0xb8,0x00,0xb8,0x8e,0xc0,0x26,0xc6,0x06,0x00,0x00,0x47,0x26,0xc6,0x06,0x01,0x00,0x1f,0x26,0xc6, 0x06,0x02,0x00,0x34,0x26,0xc6,0x06,0x03,0x00,0x1f,0x26,0xc6,0x06,0x04,0x00,0x31,0x26,0xc6,0x06, 0x05,0x00,0x1f,0x26,0xc6,0x06,0x06,0x00,0x34,0x26,0xc6,0x06,0x07,0x00,0x1f,0x26,0xc6,0x06,0x08, 0x00,0x33,0x26,0xc6,0x06,0x09,0x00,0x1f,0xeb,0xfe }; int main(int argc, char**argv) { int floppy_desc; boot_buf[510]=0x55;//to make the floppy/image bootable boot_buf[511]=0xaa;//to make the floppy/image bootable floppy_desc=open("/dev/fd0",O_RDWR); lseek(floppy_desc,0,SEEK_CUR); write(floppy_desc,boot_buf,512); close(floppy_desc); }Make mine Arch Linux
- 05-02-2009 #4
Also if you haven't already install 'Qemu launcher' this piece of software will allow you to boot your OS image on your own machine...I use it and find it simple and easy to use...Gerard4143
Make mine Arch Linux
- 05-02-2009 #5Just Joined!
- Join Date
- Mar 2009
- Posts
- 37
thanks
ten chars
- 05-02-2009 #6Just Joined!
- Join Date
- Mar 2009
- Posts
- 37
wow this is great the code answered 6 other questions of mine
- 05-02-2009 #7
Check out this link:
Back to Basics: Creating a Bootloader from Scratch - R&D by Michiel van Oosterhout
Gerard4143Make mine Arch Linux
- 05-03-2009 #8Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,974
You can use nasm, which is an 8086 assembler for Linux. You should be able to install it from your package manager.
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 05-03-2009 #9
Do you know how to compile an assembler file so that it strips all the header/symbol information. I want just the text section remaining without any extra information...Gerard4143
Note I would prefer GNU as assembler instructions but if you know how to do it in NASM I'll take that...Gerard4143Make mine Arch Linux
- 05-03-2009 #10


Reply With Quote
