mirror of
https://github.com/dschmenk/VM02.git
synced 2024-06-07 18:29:28 +00:00
29 lines
474 B
C
29 lines
474 B
C
|
#include <stdio.h>
|
||
|
#include <stdlib.h>
|
||
|
#include <fcntl.h>
|
||
|
|
||
|
unsigned char buf[256];
|
||
|
|
||
|
int main(int argc, char **argv)
|
||
|
{
|
||
|
int fd, offset;
|
||
|
|
||
|
if (argc < 2)
|
||
|
{
|
||
|
printf("Usage: %s <binfile>\n", argv[0]);
|
||
|
return (1);
|
||
|
}
|
||
|
if ((fd = open(argv[1], O_RDONLY, 0)) > 0)
|
||
|
{
|
||
|
offset = 0;
|
||
|
while (read(fd, buf, 1) == 1)
|
||
|
{
|
||
|
if (offset++ & 0x0F)
|
||
|
printf(",$%02X", buf[0]);
|
||
|
else
|
||
|
printf("\n\t.BYTE\t$%02X", buf[0]);
|
||
|
}
|
||
|
printf("\n");
|
||
|
}
|
||
|
close(fd);
|
||
|
}
|