29 lines
553 B
Text
29 lines
553 B
Text
; x86_64 Linux NASM
|
|
; Linked_List_Insert.asm
|
|
|
|
%ifndef INSERT
|
|
%define INSERT
|
|
|
|
%include "Linked_List_Definition.asm" ; see LL def task
|
|
%include "Heap_Alloc.asm" ; see memory allocation task
|
|
|
|
section .text
|
|
|
|
; rdi - link to insert after
|
|
; rsi - value that the new link will hold
|
|
Insert_After:
|
|
push rdi
|
|
push rsi
|
|
mov rdi, linkSize
|
|
call alloc
|
|
cmp rax, 0
|
|
je Memory_Allocation_Failure_Exception
|
|
pop rdi
|
|
mov dword [rax + value], edi
|
|
pop rdi
|
|
mov rsi, qword [rdi + next]
|
|
mov qword [rax + next], rsi
|
|
mov qword [rdi + next], rax
|
|
ret
|
|
|
|
%endif
|