Implement segalloc for minijort

This commit is contained in:
Jeremy Penner 2023-09-01 19:10:52 -04:00
parent e3d15b37cf
commit 8439de78e9
3 changed files with 9 additions and 0 deletions

View file

@ -791,6 +791,14 @@ void f_rand() {
PUSHI(rand());
}
void f_segalloc() {
void far* ptr = farmalloc(0x10010UL);
unsigned long linearaddr = ((unsigned long)FP_SEG(ptr) << 4) +
((unsigned long)FP_OFF(ptr));
int segment = ((linearaddr & 0x000ffff0UL) >> 4);
PUSHI(segment);
}
void f_init() {
CDEF("[", f_compileoff); f_immediate();
CDEF("]", f_compileon);
@ -900,6 +908,7 @@ void f_init() {
CDEF("chdir", f_chdir);
CDEF("memmove", f_memmove);
CDEF("rand", f_rand);
CDEF("segalloc", f_segalloc);
PCONST("$DOCREATE", f_docreate);
PCONST("$DOVAR", f_dovar);
PCONST("$DODEFERRED", f_dodeferred);

Binary file not shown.

Binary file not shown.