list.txt
来自「汇编编程艺术」· 文本 代码 · 共 873 行 · 第 1/2 页
TXT
873 行
Registers on entry: ES:DI- Pointer to list.
DX:SI- Pointer to node to insert
Examples of Usage:
les di, MyList
ldxi NewNode
InsertCur
Description:
InsertCur inserts the node pointed at by DX:SI before the "current" node in
the list. The current node is the last one operated on by the software.
The newly inserted node becomes the CurrentNode in the list.
Include: stdlib.a or lists.a
Routine: InsertmCur
--------------------
Author: Randall Hyde
Category: List Manipulation
Registers on entry: ES:DI- Pointer to list.
DX:SI- Pointer to data for node to insert
Flags on exit: Carry flag is set if malloc error occurs.
Examples of Usage:
les di, MyList
ldxi DataBlock
InsertmCur
jc Error
Description:
InsertmCur builds a new node on the heap (using the block of data pointed at
by DX:SI and the size of a node in the size field of the list variable) and
then inserts the new node before the "current" node in the list. The current
node is the last one operated on by the software.
This code treats the newly inserted node as the current node.
Include: stdlib.a or lists.a
Routine: AppendCur
-------------------
Author: Randall Hyde
Category: List Manipulation
Registers on entry: ES:DI- Pointer to list.
DX:SI- Pointer to node to append
Examples of Usage:
les di, MyList
ldxi NewNode
AppendCur
Description:
AppendCur inserts the node pointed at by DX:SI after the "current" node in
the list. The current node is the last one operated on by the software.
The newly inserted node becomes the CurrentNode in the list.
Include: stdlib.a or lists.a
Routine: AppendmCur
--------------------
Author: Randall Hyde
Category: List Manipulation
Registers on entry: ES:DI- Pointer to list.
DX:SI- Pointer to data for node to insert.
Flags on exit: Carry flag is set if malloc error occurs.
Examples of Usage:
les di, MyList
ldxi DataBlock
AppendmCur
jc MallocError
Description:
AppendmCur builds a new node on the heap (using the block of data pointed at
by DX:SI and the size of a node in the size field of the list variable) and
then inserts the new node after the "current" node in the list. The current
node is the last one operated on by the software.
This code treats the newly inserted node as the current node.
Include: stdlib.a or lists.a
Routine: RemoveCur
-------------------
Author: Randall Hyde
Category: List Manipulation
Registers on entry: ES:DI- Pointer to list.
Registers on exit: DX:SI- Points at node removed from list (NIL if
no such node).
Flags on return: Carry set if the list was empty.
Examples of Usage:
les di, MyList
RemoveCur
jc EmptyList
Description:
RemoveCur removes the current node (pointed at by CurrentNode) from the list
and returns a pointer to this node in DX:SI. If the list was empty, RemoveCur
returns NIL in DX:SI and sets the carry flag.
This routine modifies CurrentNode so that it points at the next item in the
list (the node normally following the current node). If there is no such
node (i.e., CurrentNode pointed at the last node in the list upon calling
RemoveCur) then this routine stores the value of the *previous* node into
CurrentNode. If you use this routine to delete the last node in the list,
it sets CurrentNode to NIL before leaving.
Include: stdlib.a or lists.a
Routine: PeekCur
-----------------
Author: Randall Hyde
Category: List Manipulation
Registers on entry: ES:DI- Pointer to list.
Registers on exit: DX:SI- Points at the current node (i.e., contains
a copy of CurrentNode), NIL if the list
is empty.
Flags on return: Carry set if the list was empty.
Examples of Usage:
les di, MyList
PeekCur
jc EmptyList
Description:
PeekCur simply returns CurrentNode in DX:SI (assuming the list is not empty).
If the list is empty, it returns the carry flag set and NIL in DX:SI.
It does not affect the value of CurrentNode.
Include: stdlib.a or lists.a
Routine: SetCur
----------------
Author: Randall Hyde
Category: List Manipulation
Registers on entry: ES:DI- Pointer to list.
CX- Node number of new current node.
Registers on exit: DX:SI- Returned pointing at selected node.
NIL if the list is empty. Points at the
last node in the list if the value in CX
is greater than the number of nodes in the
list.
Flags on return: Carry set if the list was empty.
Examples of Usage:
les di, MyList
mov cx, NodeNum
SetCur
jc EmptyList
Description:
SetCur locates the specified node in the list and sets CurrentNode to the
address of that node. It also returns a pointer to that node in DX:SI.
If CX is greater than the number of nodes in the list (or zero) then
SetCur sets CurrentNode to the last node in the list. If the list is
empty, SetCur returns NIL in DX:SI and returns with the carry flag set.
Include: stdlib.a or lists.a
Routine: NextNode
------------------
Author: Randall Hyde
Category: List Manipulation
Registers on entry: ES:DI- Pointer to list.
Registers on exit: DX:SI- Returned pointing at selected node.
NIL if the list is empty. Points at the
last node in the list if the current node
was the last node in the list
Flags on return: Carry set if the current node was the last node
or the list was empty.
Examples of Usage:
les di, MyList
NextNode
jc EmptyOrEnd
Description:
NextNode modifies the CurrentNode pointer so that it points to the next
node in the list, if there is one. It also returns a pointer to that node
in DX:SI. If the list is empty, or CurrentNode points at the last node
in the list, NextNode returns with the carry flag set.
Include: stdlib.a or lists.a
Routine: PrevNode
------------------
Author: Randall Hyde
Category: List Manipulation
Registers on entry: ES:DI- Pointer to list.
Registers on exit: DX:SI- Returned pointing at selected node.
NIL if the list is empty. Points at the
1st node in the list if the current node
was the 1st node in the list
Flags on return: Carry set if the current node was the 1st node
or the list was empty.
Examples of Usage:
les di, MyList
PrevNode
jc EmptyOr1st
Description:
PrevNode modifies the CurrentNode pointer so that it points to the previous
node in the list, if there is one. It also returns a pointer to that node
in DX:SI. If the list is empty, or CurrentNode points at the 1st node
in the list, PrevNode returns with the carry flag set.
Include: stdlib.a or lists.a
Routine: Insert (m)
--------------------
Author: Randall Hyde
Category: List Manipulation
Registers on entry: ES:DI- Pointer to list.
DX:SI- Address of node to insert (Insert)
DX:SI- Pointer to data block to create node from
(Insertm).
CX- Number of node to insert DX:SI in front of;
Note that the list is one-based. That is,
the number of the first node in the list is
one. Zero corresponds to the last node in
the list.
Flags on return: Carry set if malloc error occurs (Insertm only).
Examples of Usage:
les di, MyList
ldxi NewNode
mov cx, 5
Insert ;Inserts before Node #5.
; The following example builds a new node on the heap from the data at
; location "RawData" and inserts this before node #5 in MyList.
les di, MyList
ldxi RawData
mov cx, 5
Insertm
jc MallocError
Description:
Insert(m) inserts a new node before a specified node in the list. The node to
insert in front of is specified by the value in the CX register. The first
node in the list is node #1, the second is node #2, etc. If the value in
CX is greater than the number of nodes in the list (in particular, if CX
contains zero, which gets treated like 65,536) then Insert(m) appends the
new node to the end of the list.
Insertm allocates a new node on the heap (DX:SI points at the data fields
for the node). If a malloc error occurs, Insertm returns the carry flag
set.
CurrentNode gets set to the newly inserted node.
Include: stdlib.a or lists.a
Routine: Append (m)
--------------------
Author: Randall Hyde
Category: List Manipulation
Registers on entry: ES:DI- Pointer to list.
DX:SI- Address of node to insert (Append)
DX:SI- Pointer to data block to create node from
(Appendm).
CX- Number of node to insert DX:SI after;
Note that the list is one-based. That is,
the number of the first node in the list is
one. Zero corresponds to the last node in
the list.
Flags on return: Carry set if malloc error occurs (Appendm only).
Examples of Usage:
les di, MyList
ldxi NewNode
mov cx, 5
Append ;Inserts after Node #5.
; The following example builds a new node on the heap from the data at
; location "RawData" and inserts this after node #5 in MyList.
les di, MyList
ldxi RawData
mov cx, 5
Appendm
jc MallocError
Description:
Append(m) inserts a new node after a specified node in the list. The node to
insert in front of is specified by the value in the CX register. The first
node in the list is node #1, the second is node #2, etc. If the value in
CX is greater than the number of nodes in the list (in particular, if CX
contains zero, which gets treated like 65,536) then Insert(m) appends the
new node to the end of the list.
Appendm allocates a new node on the heap (DX:SI points at the data fields
for the node). If a malloc error occurs, Appendm returns the carry flag
set.
CurrentNode gets set to the newly inserted node.
Include: stdlib.a or lists.a
Routine: Remove
----------------
Author: Randall Hyde
Category: List Manipulation
Registers on entry: ES:DI- Pointer to list.
CX- # of node to delete from list.
Registers on exit: DX:SI- Points at node removed from list (NIL if
no such node).
Flags on return: Carry set if the list was empty.
Examples of Usage:
les di, MyList
mov cx, NodeNumbr
Remove
jc EmptyList
Description:
Remove removes the specified node (given by CX) from the list
and returns a pointer to this node in DX:SI. If the list was empty, Remove
returns NIL in DX:SI and sets the carry flag.
This routine modifies CurrentNode so that it points at the next item in the
list (the node normally following the current node). If there is no such
node (i.e., CurrentNode pointed at the last node in the list upon calling
Remove) then this routine stores the value of the *previous* node into
CurrentNode. If you use this routine to delete the last node in the list,
it sets CurrentNode to NIL before leaving.
Include: stdlib.a or lists.a
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?