c71e249a4e
First substantive commit: the entire Sprinter C compiler tree on top of
the bare README+gitignore initial commit.
What's in here:
bin/sprinter-cc — driver script invoking SDCC + linker + mkexe
libc/ — Sprinter-specific libc layer over ESTEX/BIOS
(conio, gfx, io, mem, stdio + headers)
runtime/ — crt0 variants (default/small/banked/minimal)
+ heap + bank trampolines
toolchain/ — mkexe (SprintEXE packer, C + tests)
examples/ — 30 demo programs (gfx, file I/O, env, time, …)
lib/Makefile — builds the libc archive (sprinter.lib)
docs/ — converted Sprinter manuals + asm reference samples
third_party/ — solid-c reference compiler dump + sdcc setup script
release_docs/ — packaging / release notes
gitignore overhaul:
• Drop dangerous blanket patterns: *.asm (would hide docs/samples/*.asm)
and *.exe (case-insensitive match was hiding third_party/solid-c/*.EXE
on macOS APFS). Replaced with examples/*/*.{asm,exe,…} and lib/*.lib.
• Restore tracking of toolchain/mkexe/tests/{one,big}.bin — those are
INPUT fixtures, not build outputs.
• Collapse the duplicated SDCC/C/Sdcc sections into one section per
concern (build outputs / vendored / OS-junk).
• Add .sprinter-cc-*/, build/ (catches lib/build/ too), .claude/.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
67 lines
1.8 KiB
C
67 lines
1.8 KiB
C
#include <stdio.h>
|
|
#include <fcntl.h>
|
|
#include <unistd.h>
|
|
|
|
/*
|
|
* Exercises lseek() with offsets that span the 16-bit boundary.
|
|
* big.txt is 102400 bytes (100 KB); every 256-byte block opens with a
|
|
* "[off=NNNNNNN] block #BBBB " label, so any seek aligned to 256 lands
|
|
* on a self-identifying marker.
|
|
*/
|
|
|
|
static void show_marker(int fd, long off)
|
|
{
|
|
long pos = lseek(fd, off, SEEK_SET);
|
|
printf("\nseek %ld -> pos=%ld\n", off, pos);
|
|
|
|
char buf[28];
|
|
int n = read(fd, buf, 27);
|
|
if (n <= 0) {
|
|
printf(" read failed: %d\n", n);
|
|
return;
|
|
}
|
|
buf[n] = 0;
|
|
printf(" bytes: \"%s\"\n", buf);
|
|
}
|
|
|
|
int main(void)
|
|
{
|
|
int fd = open("BIG.TXT", O_RDONLY);
|
|
if (fd < 0) {
|
|
printf("open failed: %d\n", fd);
|
|
(void)getchar();
|
|
return 1;
|
|
}
|
|
|
|
/* Total file size. */
|
|
long size = lseek(fd, 0L, SEEK_END);
|
|
printf("file size = %ld bytes\n", size);
|
|
|
|
/* Seek inside the first 64 KB (high16 = 0). */
|
|
show_marker(fd, 0L);
|
|
show_marker(fd, 256L);
|
|
show_marker(fd, 32768L);
|
|
|
|
/* Right at the 64 KB boundary (offset 0x00010000, high16 = 1). */
|
|
show_marker(fd, 65536L);
|
|
|
|
/* Past 64 KB (high16 still 1, low16 != 0). */
|
|
show_marker(fd, 65536L + 256L);
|
|
show_marker(fd, 81920L);
|
|
|
|
/* Near end of file (size = 102400 = 0x19000, high16 = 1). */
|
|
show_marker(fd, 102400L - 256L);
|
|
|
|
/* SEEK_CUR: from current position, +256. After the previous SEEK_SET
|
|
* to 102144, then read of 27 bytes, pos is 102171. +256 -> 102427,
|
|
* which is past EOF — ESTEX should clamp or error. */
|
|
long after_cur = lseek(fd, 256L, SEEK_CUR);
|
|
printf("\nSEEK_CUR +256 -> pos=%ld (past EOF)\n", after_cur);
|
|
|
|
close(fd);
|
|
puts("");
|
|
puts("Press any key to exit...");
|
|
(void)getchar();
|
|
return 0;
|
|
}
|