Open roman65536 opened 3 years ago
Hello @roman65536, you can find an example of using GCC-IA16 and related tools for bare metal 8086 programming in the project SYS86. The Makefile could help you to figure out how to build your code.
@mfld-fr Thank you for answer, what version of ia16-elf-gcc are you using ?? see below.
$ia16-elf-gcc -Os -ffreestanding -mcmodel=tiny -mprotected-mode entry.S ia16-elf-gcc: error: unrecognized command line option ‘-mcmodel=tiny’ ia16-elf-gcc: error: unrecognized command line option ‘-mprotected-mode’ $ ia16-elf-gcc -v Using built-in specs. COLLECT_GCC=ia16-elf-gcc COLLECT_LTO_WRAPPER=/home/romanp/MyProgram/prg/8086/prefix/libexec/gcc/ia16-elf/6.3.0/lto-wrapper Target: ia16-elf Configured with: ../gcc-ia16/configure --target=ia16-elf --prefix=/home/romanp/MyProgram/prg/8086/prefix --without-headers --with-newlib --enable-languages=c --disable-libssp --with-isl=/home/romanp/MyProgram/prg/8086/prefix-isl Thread model: single gcc version 6.3.0 (GCC)
I am using the same GCC-IA16 as self-built in the project ELKS that @tkchia contributes to.
mfld@home /mnt/data/home/mfld/advantech/sys86 $ . env.sh
TOPDIR set to /mnt/data/home/mfld/advantech/sys86
CROSSDIR set to /mnt/data/home/mfld/advantech/sys86/cross
PATH set to /mnt/data/home/mfld/advantech/sys86/cross/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin:/usr/lib/llvm/11/bin:/home/mfld/bin:/home/mfld/.local/bin
mfld@home /mnt/data/home/mfld/advantech/sys86 $ ia16-elf-gcc -v
Utilisation des specs internes.
COLLECT_GCC=ia16-elf-gcc
COLLECT_LTO_WRAPPER=/mnt/data/usr/src/advantech/cross/bin/../libexec/gcc/ia16-elf/6.3.0/lto-wrapper
Cible : ia16-elf
Configuré avec: ../gcc-src/configure --target=ia16-elf --prefix=/mnt/data/home/mfld/advantech/elks-master/cross --without-headers --enable-languages=c --disable-libssp --without-isl
Modèle de thread: single
gcc version 6.3.0 (GCC)
Hint : that GCC-IA16 version is built with this Makefile.
Ok, try to rebuild my gcc, However, is it correct, the magic is "-mcmodel=tiny -mprotected-mode" ? From what I see in your example, are you running your code out of RAM ? Resp. What I don't see in the example, how to get from the reset vector (0xffff0) to initial asm code -> to C ? And how are the Segment Registers setup? From the ld script it look to me as one continues memory (text,data,bss), so only stack must be separated.
About the magic, @tkchia would explain the GCC-IA16 options better than me :wink: .
For the case of SYS86, the SBC original ROM boot code has been patched with MON86 using an EEPROM programmer, then MON86 is used to load and run SYS86 in RAM from the development PC (with initial CS=DS=ES=SS, and IP=SP=0). I plan to later burn all that stuff in the ROM for a standalone SYS86 boot without any tethering.
Therefore the bootstrap @ FFFF:0h is already there (JMP to @ F000:0h), then some code @ F000:0h already setups the HW and JMP to the application code. I just hacked that latest JMP to redirect it to MON86.
What is your 8086 board ? Are you able to hack the 64K ROM @ F0000h ? Or to load a piece of code in RAM and execute it ?
iSBC 86/30 compatible board. The original used some sort of Intel Monitor. In my case, there is a custom ROM, which I would like to replace with my stuff, so I can play with board. There is no monitor, at least I don't know about it. That's why started to play around with ia16-gcc.
Hello @roman65536,
gcc-ia16
has had the -mprotected-mode
and -mcmodel=tiny
options for quite a long time --- since at least April 2018, in fact. You must be using a very old version of gcc-ia16
, or something else went wrong.
Unfortunately, I have no idea how you were building (or installing) gcc-ia16
, since you did not tell us. If you are using Ubuntu (Linux) Bionic or Ubuntu Focal, you can get precompiled packages from my Ubuntu Personal Package Archive. These should be quite up-to-date and well-tested.
Also, to read the gcc-ia16
documentation, you can run info /usr/ia16-elf/info/gcc.info
. (If you installed gcc-ia16
in some place other than /usr
, replace /usr
with the installation prefix.) The info file will give you a better idea of what the various options do.
Thank you!
@tkchia yes you mind be right, since I download it probably from crtc-demos. Ok will fix this. Since I'm an Debian boy :) I use debian 10. Despite my wrong installation, is it basically possible using your gcc-ia16, to do stuff I would like to do as mention above ??
Hello @roman65536,
@tkchia yes you mind be right, since I download it probably from crtc-demos.
OK. I am not sure why you downloaded gcc-ia16
from one repository, but reported an issue under a different repository. But whatever. 😐
is it basically possible using your gcc-ia16, to do stuff I would like to do as mention above ??
Yes, it is possible.
@mfld-fr 's source code omits some of the needed steps (I think he mentioned that). If you want a more fleshed-out example, you can check out Jamie Iles's 80x86
project, specifically the ROM BIOS portion.
Thank you!
Yeah, I only responded to give an example of "how to use GCC-IA16 to do bare-metal on 8086 based system" (that was the initial question as I understood), not to give any example of "what code to do bare metal on 8086 based system", as it strongly depends on the HW.
I've started using this project as the basis for my exploration and repurpose of an old telecom board that has a 80c188. I've managed to flash Wichit Sirichote's x86Bug Monitor on it (years ago), and I'm loading my code directly into the lower portion of RAM (0x0000). For now I've tried with the tiny memory model, but I would like to experiment with larger code. However, I think I'll try to port the BIOS from the Jamie Illes project as you've mentioned. Sorry for this comment (I know it might not be a constructive one), but I wanted to add my feedback about the project. Thanks!
Hello guys, i am doing similar stuff on a 286 board with ia16. I have a "monitor" installed and i could load my own software from there. however, after i compile my very simple code, the _start function is not at the beginning of the .bin file. i am using the makefile from comment #2 above ( SYS86) and also its Linkerscript. How can i force ia16-gcc to place the _start function at the beginning of the .bin file? Thanks in advance, Stefan
Hello @srmeister,
How can i force ia16-gcc to place the _start function at the beginning of the .bin file?
Are you using '-fno-toplevel-reorder' in the command line? This should leave the functions compiled in the .c/.o files in the same order in the binary as in the source.
Thank you!
thank you for your feedback. Now i tried -fno-toplevel-reorder, it didnt help unfortunately. Also i tried placing the _start function in a separate section like this:
__attribute__ ((section ("text.prologue"))) void _start()
and changing the linker script to place this function first:
.text : { *(.text.prologue*) *(.text*) *(.rodata) *(.data) }
which did not help either.
Also, i tried to compile the other functions in a separate file and pass the .o file with _start in it as a first argument to the linker so that linker would place it first in the output, which also had no effect. i am kind of stuck here.
attribute ((section ("text.prologue"))) void _start()
I presume that's a typo above with no '.' as the first character in 'text.prologue'?
Use the '-M' option to produce a map file to stdout. Lets look at that output to determine more precisely what is happening.
thank you i corrected this typo and now it works! thanks very much. A whole day gone but i learned a lot :)
@tkchia , @mfld-fr
I just would like to let you know, It finally worked. I was able to generate romble code, even with cs!=ds. My trouble was also due to inadequate emulator (simh) for testing the code. Then I used emu86 from mfld-fr and it worked right a way.
rgds roman
@roman65536 Thank you for your feedback !
Hi,
I'm not 100% whether this is correct place..
However, I have a 8086 Board from the 80's, where the Rom starts at 0xf0000 till 0xfffff. Ram occupies 128KB starting from 0x00000. How can I use gcc-ia16/binu-ia16 to program something like this ? resp What I need to do, so I can use gcc-ia16 ?
thx Roman