Files
Sprinter-SDCC/libc/time/sleep.c
T
snark13 737c974400 Add mdview markdown viewer, reorganize tests/examples and libc layout
- Split tests/ (libc feature tests) and examples/ (real apps); shared
  app.mk in repo root, was examples/example.mk
- libc/io/* split into libc/{conio,env,errno,file,mouse,string,sys,
  time,video}/ — clearer module boundaries
- New examples/mdview/: markdown viewer (Phases 1-5 + light nested
  lists). Headers (H1-H4), HR, ulist/olist/quote with nesting via
  leading spaces, fenced code blocks, inline emphasis (bold/italic/
  underscore/code), wrap/unwrap mode with soft wrap (F2), horizontal
  pan (← →) with '>' truncation indicator
- libc additions: scroll() in conio (ESTEX SCROLL), strlwr/strupr,
  gets() test
- Makefile updates across tests/ for the new shared app.mk path

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-04 22:23:36 +03:00

31 lines
838 B
C

/*
* sleep — block for N seconds using the 50 Hz frame interrupt.
*
* Sprinter ISR fires 50 times per second. `halt` parks the CPU until
* the next IRQ, so 50 halts = ~1 second of wall clock. This is the
* same trick solid-c uses in IO.ASM:285.
*
* Note: requires interrupts to be enabled (they are by default — ESTEX
* sets up IM 1 with the frame ISR before our program runs).
*/
#include <unistd.h>
void sleep(unsigned int seconds) __naked
{
(void)seconds;
__asm
inter:
;; HL = seconds on entry (SDCC single int arg).
ld a, h
or a, l
ret Z ; sleep(0) return immediately
ld b, #50 ; 50 halts per second (50 Hz interrupt)
inner:
halt
djnz inner
dec hl
jr inter
__endasm;
}