qdosmsq:vectors:rehp

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
qdosmsq:vectors:rehp [2009/02/12 14:54]
george.gwilt Links added
qdosmsq:vectors:rehp [2009/02/12 16:04] (current)
george.gwilt Example moved to 'here' and links corrected
Line 1: Line 1:
 ====== MM_LNKFR/​MEM_REHP - Vector $DA ====== ====== MM_LNKFR/​MEM_REHP - Vector $DA ======
  
-This vector sets up a user heap or links space back into an existing user heap. Space is allocated from the user heap by [[alph|MM_ALLOC/MEM_ALPH]].+This vector sets up a user heap or links space back into an existing user heap. Space is allocated from the user heap by [[alhp|MM_ALLOC/MEM_ALHP]].
 ^Call Parameters^^Return Parameters^^ ^Call Parameters^^Return Parameters^^
 |D1.L|Number of bytes required. |D1.L|Number of bytes allocated.| |D1.L|Number of bytes required. |D1.L|Number of bytes allocated.|
Line 17: Line 17:
 ===== Notes ===== ===== Notes =====
   * All registers except possibly D0 not shown above are not used on entry and are preserved on exit.   * All registers except possibly D0 not shown above are not used on entry and are preserved on exit.
-  * When the vector is used to set up a user heap, the pointer to free space must be made zero. Thereafter its value is maintained by [[alph|MM_ALLOC/MEM_ALPH]] and MM_LNKFR/​MEM_REHP and should not be altered, and need not be used, by the programmer.+  * When the vector is used to set up a user heap, the pointer to free space must be made zero. Thereafter its value is maintained by [[alhp|MM_ALLOC/MEM_ALHP]] and MM_LNKFR/​MEM_REHP and should not be altered, and need not be used, by the programmer.
   ​   ​
 ===== Examples ===== ===== Examples =====
-The examples ​below shows the use of this vector to set up a user heap and to return space to the user heap.+The examples ​[[qdosmsq:​traps:​heaps|here]] show the use of this vector to set up a user heap and to return space to the user heap.
  
-Setting up a user heap 
- 
-We suppose that A6 points to the program'​s data space and that heapad is the offset to a long word containing the pointer to free space. 
- 
-<​code>​ 
-        moveq   #​MT_ALCHP,​d0 ​   ; $18 
-        move.l ​ space,​d1 ​       ; Number of bytes required. 
-        moveq   #​-1,​d2 ​         ; This job 
- trap #​1 ​     ; The base address is set in A0 
-        tst.l   d0 
- bne.s Error_handler ;​ Oops! 
-        lea     ​heapad(a6),​a1 ​  ; Set the pointer to the pointer to the user heap 
-        clr.l   ​(a1) ​           ; Set the pointer to zero 
-        movea.w mm_lnkfr,​a2 ​    ; Put the vector in A2 . . 
-        jsr     ​(a2) ​           ; . . and use it 
-                                ; Now the user heap is set up at A0 
- 
-space   ​dc.l ​   $2000           ; Amount of space needed 
-</​code>​ 
- 
-Returning space to the user heap 
- 
-Suppose that buffer(a6) is the pointer to a buffer allocated from the user heap and that buff_len(a6) contains its length. The code shows this buffer being returned to the user heap. 
- 
-<​code>​ 
-        movea.l buffer(a6),​a0 ​  ; Base of space to be freed 
-        move.l ​ buff_len(a6),​d1 ; Size of space 
-        lea     ​heapad(a6),​a1 ​  ; Set the pointer to the pointer to the user heap        ​ 
-        movea.w mm_lnkfr,​a2 ​    ; Put the vector in A2 . . 
-        jsr     ​(a2) ​           ; . . and use it 
- 
-</​code>​ 
  
  • qdosmsq/vectors/rehp.txt
  • Last modified: 2009/02/12 16:04
  • by george.gwilt