elks-enhanced
public
Read
Owner: themaster
Branch: master
Commits: 6893
Updated: 2026-04-19 00:15
Git CLI clone URL
git clone https://www.xt-emporium.com/git/elks-enhanced.git
Fullscreen desktop URL
Code
Commits
History
Branches
Bug Reports
Discussions
Compare
Settings
elks-enhanced
/
Documentation
/
html
/
user
/
writing_apps_in_C.html
File editor
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=windows-1252"/> <title></title> <meta name="generator" content="LibreOffice 5.2.7.2 (Windows)"/> <meta name="author" content="Georg Potthast"/> <meta name="created" content="00:00:00"/> <meta name="changed" content="2020-04-13T22:03:59.952000000"/> <meta name="created" content="00:00:00"> <meta name="changed" content="2020-04-13T20:38:53.396000000"> <meta name="created" content="00:00:00"> <meta name="changed" content="2020-02-26T23:06:22.507000000"> <meta name="created" content="00:00:00"> <meta name="changed" content="2020-02-26T20:32:51.535000000"> <style type="text/css"> @page { margin: 2cm } p { margin-bottom: 0.21cm } td p { margin-bottom: 0cm } pre.cjk { font-family: "NSimSun", monospace } h2 { margin-bottom: 0.21cm } h2.western { font-family: "Arial", sans-serif; font-size: 14pt; font-style: italic } h2.cjk { font-family: "Microsoft YaHei"; font-size: 14pt; font-style: italic } h2.ctl { font-family: "Lucida Sans"; font-size: 14pt; font-style: italic } a:link { so-language: zxx } </style> </head> <body lang="de-DE" dir="ltr"> <p style="page-break-before: always"><br/> <br/> </p> <table width="718" cellpadding="4" cellspacing="0"> <col width="710"> <tr> <td width="710" valign="top" style="border: none; padding: 0cm"> <h2 class="western" style="font-variant: normal; font-style: normal"> <font size="5" style="font-size: 20pt">Writing applications for ELKS in C with gcc-ia16</font></h2> <p style="margin-bottom: 0.5cm"><font face="Arial, sans-serif">You can develop application programs for ELKS by cross-compiling them on a standard Linux system with the gcc-ia16 compiler. Because this compiler is also used to compile ELKS, the gcc-ia16 compiler is usually installed in the „cross“ directory of the ELKS directory after you downloaded and compiled ELKS.</font></p> <p style="margin-bottom: 0.5cm"><font face="Arial, sans-serif">For a test let's compile a 'hello world' program and run that in ELKS. Here is the code:</font></p> <pre class="western">#include<stdio.h> int main() { printf("Hello World\n"); return 0; }</pre><p style="margin-bottom: 0.5cm"> <font face="Arial, sans-serif">Make a new „testing“ directory and copy and save this with a text editor as 'hello.c' in e.g. an elks/testing directory. Then get into this directory and enter:</font></p> <p style="margin-bottom: 0.5cm"><font face="Liberation Mono, monospace"><font size="2" style="font-size: 10pt">ia16-elf-gcc hello.c -o hello -melks-libc -mcmodel=small</font></font></p> <p style="margin-bottom: 0.5cm"><font face="Arial, sans-serif"><font size="3" style="font-size: 12pt">This will compile the hello executable in the testing directory. The „-melks-libc“ specifies to use the libc in the elks directory and „-mcmodel=small“ specifies to compile the program using the small model. Currently ELKS can only load programs generated for 128k using the small model. This will be up to 64k of code and up to 64k of data and stack in two separate segments.</font></font></p> <p style="margin-bottom: 0.5cm"><font face="Arial, sans-serif"><font size="3" style="font-size: 12pt">To see if this program works with ELKS enter: „../elksemu/elksemu hello“ on the command line. The elksemu emulator will run the hello program then.</font></font></p> <p style="margin-bottom: 0.5cm"><font face="Arial, sans-serif"><font size="3" style="font-size: 12pt">If you want to run the hello executable with ELKS you have to put it e.g. into the directory 'usr/bin' on the ELKS disk image, e.g. the 'fd1440.bin' image file. You can load an existing ELKS image as a loop device on Linux and then copy the new executable to this image. To do this you can use a script with the following lines: </font></font> </p> <pre class="western">set -x mount -o loop image/fd1440.bin floppy1 cp testing/hello floppy1/bin umount floppy1</pre><p style="margin-bottom: 0.5cm"> <font face="Arial, sans-serif">Execute this script with 'sudo' ! This script assumes that you are in the 'elks' directory and that the 'fd1440.bin' image file is in the image directory. Also there has to be a 'floppy1' directory within the 'elks' directory which will be used for the loop device. </font> </p> <p style="margin-bottom: 0.5cm"><font face="Arial, sans-serif">You may wonder why Linux can access this floppy image since it is using the Minix file system. The reason is that Linux can use the Minix file system for floppy disks as well. Newer Linux distributions often blacklist this file system. Enter „modprobe -v minix“ to load this file system or add it to the „etc/modprobe.d“ file to have it available after a reboot.</font></p> <p style="margin-bottom: 0.5cm"><font face="Arial, sans-serif">Then call qemu to run ELKS and call your program. Either run the „./qemu.sh“ script in the elks directory or enter:</font></p> <pre class="western" style="margin-bottom: 0.5cm">qemu-system-i386 -fda <font face="Liberation Mono, monospace"><font size="2" style="font-size: 10pt">image/fd1440.bin</font></font></pre><p style="margin-bottom: 0.5cm"> <font face="Arial, sans-serif">After ELKS has booted, log in as „root“ and type cd ../bin and execute the ./hello program in there. </font> </p> <p style="margin-bottom: 0.5cm"><font face="Arial, sans-serif">If you have to repeat this frequently while developing your program, you can put these commands into the '.profile' script for root which is in the /root directory. Then your program will be run as soon as you log in as root.</font></p> <p style="margin-bottom: 0.5cm"><font face="Arial, sans-serif">Another alternative is to make a directory in the ELKS source code, write a Makefile for your application program and then compile ELKS including your program. </font> </p> <p style="margin-bottom: 0.5cm"><font face="Arial, sans-serif">Finally, you could set up an ftp server on your Linux host and use the ftpget progam on ELKS to download the executable to ELKS and run it there. There is another document that describes how to set up a tcp/ip connection between ELKS running in Qemu and your Linux system.</font></p> <h2 class="western" style="font-variant: normal; font-style: normal"> <font size="5" style="font-size: 20pt">Writing applications for ELKS in C with the bcc compiler</font></h2> <p style="margin-bottom: 0.5cm"><font face="Arial, sans-serif">ELKS and application programs for ELKS can be made by</font> <font face="Arial, sans-serif">cross-compiling them</font> <font face="Arial, sans-serif">on a standard Linux system with the dev86 package. This contains the bcc C compiler, the ld86 linker, the as86 assembler and the ar86 archiver. You can download the dev86 package from the repository of your Linux distribution or download it here: <a href="https://github.com/jbruchon/dev86">https://github.com/jbruchon/dev86</a>. Then compile and install it from this source code. Enter make in the main directory for that and „quit“ when the configuration menu is displayed. </font> </p> <p style="margin-bottom: 0.5cm"><font face="Arial, sans-serif">For a start let's compile a „hello world“ program and run that in ELKS. Here is the code:</font></p> <pre class="western">#include<stdio.h> int main() { printf("Hello World\n"); return 0; }</pre><p style="margin-bottom: 0.5cm"> <font face="Arial, sans-serif">Copy and save this as hello.c with a text editor. Then enter </font> </p> <pre class="western" style="margin-bottom: 0.5cm">bcc -ansi hello.c -o hello</pre><p style="margin-bottom: 0.5cm"> <font face="Arial, sans-serif">We always use the -ansi switch here because otherwise bcc will assume K&R style. </font> </p> <p style="margin-bottom: 0.5cm"><font face="Arial, sans-serif"><font size="3" style="font-size: 12pt">To see if this program will work with ELKS enter: „../elksemu/elksemu hello“ on the command line. The elksemu emulator will run the hello program then. Or use one of the alternatives described above</font> <font size="3" style="font-size: 12pt">for the gcc-ia16 compiler.<br/> </font>If an error number is returned you can look that up in the file „elks\include\arch\errno.h“.</font></p> <p style="margin-bottom: 0.5cm"><font face="Arial, sans-serif">The bcc compiler has been ported to DOS so you can also develop ELKS applications in DOS or a Windows 32bit DOS box: <a href="https://ftp.gwdg.de/pub/misc/freedos/files/devel/c/bcc/">https://ftp.gwdg.de/pub/misc/freedos/files/devel/c/bcc/</a> This includes doselks.com to run the compiled programs. </font> </p> <h2 class="western" style="margin-top: 0cm; margin-bottom: 0.5cm"><span style="font-variant: normal"><font face="Arial, sans-serif"><font size="5" style="font-size: 20pt"><span style="font-style: normal">Writing applications for ELKS with the Turbo-C compiler</span></font></font></span></h2> <p style="margin-bottom: 0.5cm"><font face="Arial, sans-serif">Alfonso Martone found a way to convert DOS Turbo-C programs to enable these to run with ELKS: <a href="http://www.alfonsomartone.itb.it/fhlvnr.html">http://www.alfonsomartone.itb.it/fhlvnr.html</a></font> <font face="Arial, sans-serif">For this</font> <font face="Arial, sans-serif">he developed the exe2elks DOS utility program and a small libc without DOS system calls. </font> </p> <p style="margin-bottom: 0.5cm"><font face="Arial, sans-serif">You compile your</font> <font face="Arial, sans-serif">C program with this small libc library instead of the standard Turbo-C libc. Then you use the exe2elks utility to convert the generated executable in the DOS EXE format to a 16bit OMAGIC aout file as required by ELKS.</font> </p> <p style="margin-bottom: 0.5cm"><font face="Arial, sans-serif">The exe2elks program may work for DOS TASM assembler programs as well if you get TLINK to generate a map file.</font></p> <p><font face="Arial, sans-serif">14</font><sup><font face="Arial, sans-serif">th</font></sup> <font face="Arial, sans-serif">of </font><font face="Arial, sans-serif">April</font><font face="Arial, sans-serif"> 2020</font> <font face="Arial, sans-serif">Georg Potthast</font></p> </td> </tr> </table> <p><br/> <br/> </p> </body> </html>
Commit message
This repository is read-only for this account.
Repository snapshot
Current branch
master
Visibility
public
Your access
Read
Remote
Configured
File activity
View file history