gcc 16bit
Re: gcc 16bit
Works ok for me. If you want to navigate directly, try http://www.delorie.com/djgpp/ .abuashraf wrote: there is wrong with http://www.delorie.com it doesn't open.
one note: while GCC can produce 16bit code, it is not true 16bit code, and may not work properly in RMode/VMode and certainly wont work on a 8086/8
all it does is prefix all 32bit references with an override (and removes prefixes from 16bit references), this makes it suitable for use in a 16bit PMode segment, but may or may not work in RMode (and definitely wont work if you must use different segments -- GCC assumes DS.base=SS.base=ES.base, and if you need more than one data segment, it may not work properly)
i dont know what you want to use it for, but this is something important to keep in mind
all it does is prefix all 32bit references with an override (and removes prefixes from 16bit references), this makes it suitable for use in a 16bit PMode segment, but may or may not work in RMode (and definitely wont work if you must use different segments -- GCC assumes DS.base=SS.base=ES.base, and if you need more than one data segment, it may not work properly)
i dont know what you want to use it for, but this is something important to keep in mind
Hi...
and It gives gpf,so would some one please give me a simple example
on how to create 16bit code using GCC,or any link speaks about that.
Thanx.
I need it for my virtual task,virtul mode doesn't accept 32bit,i dont know what you want to use it for
and It gives gpf,so would some one please give me a simple example
on how to create 16bit code using GCC,or any link speaks about that.
It didn't work again...I don't know maybe the wrong comes form my server.Works ok for me. If you want to navigate directly, try http://www.delorie.com/djgpp/ .
Thanx.
try http://207.22.48.162 your DNS server might be stupid and not work on certain websites..I use to have that problem, you can fix it by setting your DNS server to 216.231.41.2
that is a very good free DNS server(it's what I use)
I saw a GCC based 16bit compiler..it didn't support segments iirc, but it didn't use 32bit opcodes..
edited...
that is a very good free DNS server(it's what I use)
I saw a GCC based 16bit compiler..it didn't support segments iirc, but it didn't use 32bit opcodes..
edited...
Last edited by earlz on Fri Jun 08, 2007 1:54 pm, edited 1 time in total.
I think, although I haven't tested this, if you add the line:
to the start of each C file you wish to be compiled as 16 bit code, then gas will generate proper 16-bit code (not 32-bit with the 66 prefix). It limits you to a single segment, however (ie. 64kB code, 64kB data) and you can't use anything that assumes 32-bit operation, e.g. long ints and the like.
edit: if anyone's interested, http://gujin.org has a boot loader written in 16-bit code using gcc.
edit2: and open watcom natively supports 16-bit, if you can tear yourself away from gcc...
Regards,
John.
Code: Select all
asm(".code16gcc\n");
edit: if anyone's interested, http://gujin.org has a boot loader written in 16-bit code using gcc.
edit2: and open watcom natively supports 16-bit, if you can tear yourself away from gcc...
Regards,
John.
A bit of an update.
Using the method I described above, it is possible to have gcc generate code that will execute in real mode (and presumably v8086), but only on a 386 or above, as it still insists on using the 32-bit registers, even for 2 byte wide variables. Be prepared to get lots of 66 and 67 prefixes.
In actuality it is gas which produces the 16-bit code - the asm instruction just inserts the .code16gcc line at the top of the intermediate assembly file.
In addition, as it is gcc, it is completely unaware of segments. Therefore, if you wish to access any memory outside the segment which ds/es are set to, you need to create your own farpeek/farpoke functions with inline asm (see [wiki]Inline_Assembly/Examples[/wiki] - I can't seem to link to this, its something to do with the slash in the title).
As a small test, I compiled the following, both with and without the .code16asm header. I attach the disassembly for reference. No optimisations were used in the compilation, otherwise this would have become really small
If you use short ints instead of ints then the code produced still uses 32-bit registers with prefixes, but the values on the stack are 2-byte aligned.
The .code16gcc option can be changed to .code16, which is similar in its output except that it does not necessarily manipulate the stack pointer in the same way as gcc does making it more difficult to walk the stack from a 32-bit monitor.
The disassembly, produced by the NASM disassembler is attached.
Regards,
John.
Using the method I described above, it is possible to have gcc generate code that will execute in real mode (and presumably v8086), but only on a 386 or above, as it still insists on using the 32-bit registers, even for 2 byte wide variables. Be prepared to get lots of 66 and 67 prefixes.
In actuality it is gas which produces the 16-bit code - the asm instruction just inserts the .code16gcc line at the top of the intermediate assembly file.
In addition, as it is gcc, it is completely unaware of segments. Therefore, if you wish to access any memory outside the segment which ds/es are set to, you need to create your own farpeek/farpoke functions with inline asm (see [wiki]Inline_Assembly/Examples[/wiki] - I can't seem to link to this, its something to do with the slash in the title).
As a small test, I compiled the following, both with and without the .code16asm header. I attach the disassembly for reference. No optimisations were used in the compilation, otherwise this would have become really small
Code: Select all
asm(".code16gcc\n");
int add2(int a);
int main()
{
int a = 31;
int b = add2(a);
return b;
}
int add2(int a)
{
return a + 2;
}
The .code16gcc option can be changed to .code16, which is similar in its output except that it does not necessarily manipulate the stack pointer in the same way as gcc does making it more difficult to walk the stack from a 32-bit monitor.
The disassembly, produced by the NASM disassembler is attached.
Regards,
John.
- Attachments
-
- test16.16.txt
- compiled with .code16gcc
- (1.05 KiB) Downloaded 288 times
-
- test16.16-nogcc.txt
- compiled with .code16
- (1.04 KiB) Downloaded 235 times
-
- test16-short.16.txt
- short ints instead of ints, compiled with .code16gcc
- (1.26 KiB) Downloaded 345 times
- Brynet-Inc
- Member
- Posts: 2426
- Joined: Tue Oct 17, 2006 9:29 pm
- Libera.chat IRC: brynet
- Location: Canada
- Contact:
Uhh, The early Minix releases used "ACK" as a C compiler, Which seems to have a new life here: http://tack.sourceforge.net/hckr83 wrote:Really, if you could find a way past the one segment bit in g++ by making your own far_pointer class...
What about the gcc that minix uses? it would be 16bit wouldn't it?
Supports the 8086 and 80386.. Is even support for other systems as well..