Skip to content

Using Parallel Port in ELKS

toncho11 edited this page Aug 22, 2023 · 9 revisions

Writing to the parallel port is as simple as writing to a memory address. It has been tested on real hardware.

Command line to compile your code: $ ./cross/bin/ia16-elf-gcc pp.c -o pp -melks -mcmodel=small

Code of pp.c in ELKS base folder:

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "elks/include/arch/io.h"

#define base 0x378   //LPT0

int main(void) {

  outb(255,base);  //set all pins hi
  sleep(5);
  outb(0,base);    //set all pins lo

  return 0;
}

If you are having problems with elf2elks missing then modify and execute the following line: export PATH="/home/mysuer/elks/elks/tools/bin:$PATH"

Then you need to copy the executable to ELKS. Expected result: all pins are set to 1 and after 5 seconds all pins are set to 0.