#include<stdio.h> #include<ioports.h> /* NOTE: Don't forget to add the -l ioports option under Tools->Compiler options This will add the ioport interface library OR from the command line: gcc binary.c -l ioports -o binary.exe */ /* Define which port to write to */ #define IO_PORT 0x378 main(void) { int num; char instr[25]; printf("press ctrl-C to stop\n\n"); /* Place port into standard output mode */ outb(IO_PORT+2, inb(IO_PORT+2) & ~32); while (1) { printf("Enter a number (prefix with 0x for hex) :"); fgets(instr, sizeof(instr), stdin); /* Jump out of loop if q entered */ if (toupper(instr[0]) == 'Q') break; sscanf(instr, "%i", &num); /* now output it to the port */ outb(IO_PORT, num); /* write value to port */ } return(0); }
-S
gcc -S binary.c
binary.s
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)