Untitled
unknown
assembly_x86
3 years ago
1.7 kB
6
Indexable
include win64.inc ; biblioteca cu structuri si functii Win x64 option win64:3 option literals:on lpLIST TYPEDEF ptr LIST LIST STRUCT number QWORD NULL next_node lpLIST NULL LIST ENDS .data list_head LIST {NULL, NULL} hStdOut HANDLE ? .code ; Sergmentul de cod (program) Add_to_sorted_list PROTO :QWORD, :lpLIST Print_list PROTO :lpLIST main proc uses rbx ; functia principala "main" mov hStdOut, GetStdHandle(STD_OUTPUT_HANDLE) .if (hStdOut == INVALID_HANDLE_VALUE) echo "Error reading Standard Output Handle" exit(-1) .endif Add_to_sorted_list(3, &list_head) Add_to_sorted_list(1, &list_head) Add_to_sorted_list(2, &list_head) Add_to_sorted_list(0, &list_head) Print_list(&list_head) exit(0) ret main endp ; sfarsitul functiei main ; alte functii/proceduri Add_to_sorted_list proc uses rbx Arg1:QWORD, Arg2:lpLIST mov rbx, malloc(sizeof(LIST)) mov rdx, Arg1 mov [rbx].LIST.number, rdx mov [rbx].LIST.next_node, NULL mov r8, Arg2 .if ([r8] == NULL) mov [r8].LIST.number, rdx mov [r8].LIST.next_node, NULL .else mov r10, [r8].LIST.next_node .while (r10 != NULL && [r10].LIST.number > rdx) mov r8, [r8].LIST.next_node mov r10, [r8].LIST.next_node .endw mov [rbx].LIST.next_node, r10 mov [r8].LIST.next_node, rbx .endif ret Add_to_sorted_list endp Print_list proc uses rbx Arg1:lpLIST mov rbx, Arg1 .while (rbx != NULL) mov r10, [rbx].LIST.number printf("%p\n", [rbx].LIST.number) mov rbx, [rbx].LIST.next_node .endw ret Print_list endp end
Editor is loading...