home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_122 / 13.ddi / QUEUE.ZIP / STACK.ASM < prev    next >
Encoding:
Assembly Source File  |  1992-06-10  |  2.0 KB  |  90 lines

  1. ;--------------------------
  2. ;-- Define Stack objects --
  3. ;--------------------------
  4.  
  5. MODEL SMALL
  6. LOCALS
  7.  
  8. ;** Define Stack object **
  9.  
  10. INCLUDE stack.aso
  11.  
  12. ;** Create instance of stack virtual method table **
  13.  
  14. DATASEG
  15.  
  16. TBLINST
  17.  
  18. ;** Define some macros for use by the methods **
  19. ;** These are used by the methods for storing and loading double registers **
  20.  
  21. ;Check to see if two 16-bit registers are both set to 0
  22. ;(r1 cannot be ax)
  23. isnullptr macro r2,r1
  24.     ifdifi <r1>,<ax>
  25.       mov ax,r2
  26.       or ax,r1
  27.     else
  28.       push bx
  29.       push r2
  30.       pop bx
  31.       or bx,ax
  32.       pop bx
  33.     endif
  34.     endm
  35.  
  36. ;** stack methods **
  37.  
  38. CODESEG
  39.  
  40. ;Pop a node from the stack
  41. ;This is the virtual method "stack|pop"
  42. ;Returns pointer to the poped node in DX:AX
  43. stack_pop PROC PASCAL NEAR
  44. ARG @@stack:dword
  45. USES ds,bx,es,di
  46.     mov ax,@Data
  47.     mov ds,ax
  48.     les di,@@stack
  49.     call es:di method list:last uses ds:bx pascal,es di
  50.     isnullptr dx ax
  51.     jz @@dn
  52.     push dx ax
  53.     call es:di method list:remove uses ds:bx pascal,es di,dx ax
  54.     pop ax dx
  55. @@dn:    ret
  56. ENDP
  57.  
  58. ;Insert a node into the Stack object.
  59. ;This is an illegal stack operation
  60. ;It is included only to disable the inherited linked-list insert method
  61. stack_insert PROC PASCAL NEAR
  62. ARG    @@list:dword,\            ;pointer to list object
  63.     @@oldnode:dword,\        ;pointer to node to insert after
  64.     @@node:dword            ;pointer to new node to insert
  65.     ;does nothing.
  66.     ret
  67. ENDP
  68.  
  69. ;Remove a node from a Stack object.
  70. ;This is an illegal stack operation
  71. ;It is included only to disable the inherited linked-list delete method
  72. stack_delete PROC PASCAL NEAR
  73. ARG    @@list:dword,\            ;pointer to list object
  74.     @@node:dword            ;pointer to node to delete
  75.     ;does nothing.
  76.     ret
  77. ENDP
  78.  
  79. ;Return a pointer to the first or last node in the Stack object
  80. ;These are illegal stack operations
  81. ;They are included only to disable the inherited linked-list first/last methods.
  82. stack_first label near
  83. stack_last PROC PASCAL NEAR
  84. ARG    @@list:dword            ;pointer to list object
  85.     ;does nothing.
  86.     ret
  87. ENDP
  88.  
  89. END
  90.