///hello world!!! ///that piece of crap, i mean, code assumes that tha memory startin address is on IX ///and the memory ending adress are on iy memstarth: defs 0 memstartl: defs 0 memendh: defs 0 memendl: defs 0 mmapladdrh: defs 0 mmapladdrl: defs 0 ld (memstarth),ixh ;putting start memory adress on ram ld (memstartl),ixl ;assuming that its on ix ld (memendh),iyh ;putting end memory adress on ram ld (memendl),iyl ;assuming that its on iy ld (mmapladdrh),iyh ;putting end memory adress on ram ld (mmapladdrl),iyl ;assuming that its on iy malloc: ld ixh,(memendh) ;get the last available memory address ld ixl,(memendl) ld iyh,(ix+1) ;get the last header memory address from MM ld iyl,(ix+2) ld h,(iy) ;get the size of last chunk ld l,(iy+1) add iy,hl ;get the first free address on memory or a sbc ix,iy ;get the free memory size ld de,6 ;fill DE with header size and MM registry size add de,bc ;get the amout of memory neded or a sbc ix,de ;see if the free memory is enough to exec malloc ld hl,0 ;prepare to exit case the memory is not enough jr nc,mmap ;test if memory is enoght ret mmap: ld ixh,(memendh) ;get the last available memory address ld ixl,(memendl) dec ix dec ix ld (memendh),ixh ;save new memory last available address ld (memendl),ixl ld (ix+1),iyh ;save mmap record ld (ix+2),iyl ld hl,de ld (iy),h ;save the size in the header inc iy ld (iy),l inc iy ld (iy),KERNEL_CurTaskID ;put the app id on the header inc iy inc iy ld hl,iy; ;put the memory starting address on hl to be returned by API ret free: ret