oops, forgot this file
[newos.git] / tools / bin2asm.c
blob8395edaa4baa95d9de4c580cf0de9a2a1863f0a8
1 /*
2 ** Copyright 2001, Travis Geiselbrecht. All rights reserved.
3 ** Distributed under the terms of the NewOS License.
4 */
5 #include <stdio.h>
6 #include <stdlib.h>
8 #define NUM_COLUMNS 16
10 int main(int argc, char **argv)
12 FILE *infp = stdin;
13 char c;
14 int column = 0;
15 int start = 1;
17 while(!feof(infp)) {
18 int err;
19 err = fread(&c, sizeof(c), 1, infp);
20 if(err != 1)
21 break;
23 if((column % NUM_COLUMNS) == 0) {
24 if(!start) {
25 printf("\n");
26 } else {
27 start = 0;
29 printf(".byte\t");
30 } else {
31 printf(",");
34 printf("0x%02x", ((int)c) & 0xff);
36 column++;
38 printf("\n");
40 return 0;