_brk.s 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #
  2. ! $Source$
  3. ! $State$
  4. ! $Revision$
  5. ! Declare segments (the order is important).
  6. .sect .text
  7. .sect .rom
  8. .sect .data
  9. .sect .bss
  10. ! This file contains the code necessary to extend the ACK heap. This is called
  11. ! by a i86/libem helper function called .strhp, which takes care of updating
  12. ! some magic global variables --- defined here.
  13. ! Pointer to the current top of the heap.
  14. .sect .data
  15. .define .reghp
  16. .reghp:
  17. .data2 endbss
  18. ! Pointer to the current top of memory.
  19. .sect .data
  20. .define .limhp
  21. .limhp:
  22. .data2 endbss
  23. ! Claims more memory from the system, but does not actually change those
  24. ! global variables (.strhp does that). This does not use the C calling
  25. ! convention!
  26. !
  27. ! Stack: ( desired_limhp : actual_limhp )
  28. ! Also returns: ax = -1 on failure
  29. .sect .text
  30. .define BRK
  31. BRK:
  32. pop bx ! holds return address
  33. pop ax ! holds desired limhp
  34. cmp ax, sp ! compare sp with si
  35. jae fail ! si too big? (Overlaps stack?)
  36. cmp ax, endbss ! compare with bottom of heap
  37. jb fail ! si too small? (Overlaps bss?)
  38. return:
  39. push ax ! success
  40. jmp bx
  41. fail:
  42. mov ax, -1
  43. jmp return