Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
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. ...
  1. #1
    Just 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

  2. #2
    Linux Enthusiast gerard4143's Avatar
    Join Date
    Dec 2007
    Location
    Canada, Prince Edward Island
    Posts
    714
    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 assembler
    Make mine Arch Linux

  3. #3
    Linux Enthusiast gerard4143's Avatar
    Join Date
    Dec 2007
    Location
    Canada, Prince Edward Island
    Posts
    714
    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

  4. #4
    Linux Enthusiast gerard4143's Avatar
    Join Date
    Dec 2007
    Location
    Canada, Prince Edward Island
    Posts
    714
    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

  5. #5
    Just Joined!
    Join Date
    Mar 2009
    Posts
    37
    thanks
    ten chars

  6. #6
    Just Joined!
    Join Date
    Mar 2009
    Posts
    37
    wow this is great the code answered 6 other questions of mine

  7. #7
    Linux Enthusiast gerard4143's Avatar
    Join Date
    Dec 2007
    Location
    Canada, Prince Edward Island
    Posts
    714
    Make mine Arch Linux

  8. #8
    Linux Guru Rubberman's Avatar
    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!

  9. #9
    Linux Enthusiast gerard4143's Avatar
    Join Date
    Dec 2007
    Location
    Canada, Prince Edward Island
    Posts
    714
    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...Gerard4143
    Make mine Arch Linux

  10. #10
    Linux Guru Rubberman's Avatar
    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
    Quote Originally Posted by gerard4143 View Post
    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...Gerard4143
    Sorry. I haven't personally used an assembler on a Linux system, other than assembler directives in a kernel module with GCC.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Page 1 of 2 1 2 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...