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

  1. ;--------------------------
  2. ;-- Define Queue objects --
  3. ;--------------------------
  4.  
  5. MODEL SMALL
  6. LOCALS
  7.  
  8. ;** Define Queue object **
  9.  
  10. INCLUDE queue.aso
  11.  
  12. ;** Create instance of Queue 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. ;** Queue methods **
  37.  
  38. CODESEG
  39.  
  40. ;Initialize a queue
  41. queue_init PROC PASCAL NEAR
  42. ARG @@queue:dword
  43. USES ds,bx,es,di
  44.     les di,@@queue
  45.     call es:di method list:init uses ds:bx pascal,es di
  46.     lds bx,@@queue
  47.     tblinit ds:bx
  48.     ret
  49. endp
  50.  
  51. ;Dequeue a node from the queue
  52. ;This is the virtual method "queue|dequeue"
  53. ;Returns pointer to dequeued node in DX:AX
  54. queue_dequeue PROC PASCAL NEAR
  55. ARG @@queue:dword
  56. USES ds,bx,es,di
  57.     les di,@@queue
  58.     call es:di method list:first uses ds:bx pascal,es di
  59.     isnullptr dx,ax
  60.     jz @@dn
  61.     push dx ax
  62.     call es:di method list:remove uses ds:bx pascal,es di,dx ax
  63.     pop ax dx
  64. @@dn:    ret
  65. ENDP
  66.  
  67. ;Insert a node into the Queue object.
  68. ;This is an illegal queue operation
  69. ;It is included only to disable the inherited linked-list insert method
  70. queue_insert PROC PASCAL NEAR
  71. ARG    @@list:dword,\            ;pointer to list object
  72.     @@oldnode:dword,\        ;pointer to node to insert after
  73.     @@node:dword            ;pointer to new node to insert
  74.     ;does nothing.
  75.     ret
  76. ENDP
  77.  
  78. ;Remove a node from a Queue object.
  79. ;This is an illegal queue operation
  80. ;It is included only to disable the inherited linked-list delete method
  81. queue_delete PROC PASCAL NEAR
  82. ARG    @@list:dword,\            ;pointer to list object
  83.     @@node:dword            ;pointer to node to delete
  84.     ;does nothing.
  85.     ret
  86. ENDP
  87.  
  88. ;Return a pointer to the first or last node in the Queue object
  89. ;These are illegal queue operations
  90. ;They are included only to disable the inherited linked-list first/last methods.
  91. queue_first label near
  92. queue_last PROC PASCAL NEAR
  93. ARG    @@list:dword            ;pointer to list object
  94.     ;does nothing.
  95.     ret
  96. ENDP
  97.  
  98. END
  99.