fix(list_sort): change rbx for rcx (caller saved)

This commit is contained in:
gbrochar 2024-03-10 06:27:49 +01:00
parent 30ee274862
commit 73d921ebc7
1 changed files with 21 additions and 21 deletions

View File

@ -21,14 +21,14 @@ ft_list_sort:
mov rdi, [r13] ; first arg is curr->data mov rdi, [r13] ; first arg is curr->data
mov rsi, [r13 + 8] ; rsi = curr->next; mov rsi, [r13 + 8] ; rsi = curr->next;
mov rsi, [rsi] ; rsi = rsi->data; mov rsi, [rsi] ; rsi = rsi->data;
;push rbx ; rbx is caller saved ;push rcx ; rcx is caller saved
;push r13 ; same ;push r13 ; same
; align stack here ? ; align stack here ?
sub rsp, 72; align stack ??? sub rsp, 72; align stack ???
call r15 call r15
add rsp, 72 add rsp, 72
;pop rdx ; rdx is caller saved ;pop rdx ; rdx is caller saved
;pop rbx ; rbx is caller saved ;pop rcx ; rcx is caller saved
cmp eax, 0 cmp eax, 0
jle .else ; if in order continue... jle .else ; if in order continue...
cmp r13, [r14] cmp r13, [r14]
@ -38,42 +38,42 @@ ft_list_sort:
mov rdx, [r13 + 8] mov rdx, [r13 + 8]
mov [r12 + 8], rdx mov [r12 + 8], rdx
mov rbx, [r13 + 8] mov rcx, [r13 + 8]
mov rdx, [rbx + 8] mov rdx, [rcx + 8]
mov [r13 + 8], rdx mov [r13 + 8], rdx
mov rbx, [r12 + 8] mov rcx, [r12 + 8]
mov [rbx + 8], r13 mov [rcx + 8], r13
mov r12, 0 mov r12, 0
mov r13, [r14] mov r13, [r14]
;mov rbx, [r13 + 8] ;mov rcx, [r13 + 8]
;mov rbx, [r13 + 8] ;mov rcx, [r13 + 8]
;mov rbx, [rbx + 8] ;mov rcx, [rcx + 8]
;mov [r13 + 8], rbx ;mov [r13 + 8], rcx
;mov rbx, [r12 + 8] ;mov rcx, [r12 + 8]
;mov rbx, [rbx + 8] ;mov rcx, [rcx + 8]
;mov rbx, r13 ;mov rcx, r13
;mov r12, 0, ; reset prev ;mov r12, 0, ; reset prev
;mov r13, [r14] ; reset curr ;mov r13, [r14] ; reset curr
jmp .loop jmp .loop
.is_first_elem: .is_first_elem:
;mov r14, [r13 + 8] ; begin_list = curr->next ;mov r14, [r13 + 8] ; begin_list = curr->next
;mov rbx, [r13 + 8] ; rbx = curr->next ;mov rcx, [r13 + 8] ; rcx = curr->next
;mov rdx, [rbx + 8] ; rbx = curr->next->next ;mov rdx, [rcx + 8] ; rcx = curr->next->next
;mov [r13 + 8], rdx ; curr->next = curr->next->next ;mov [r13 + 8], rdx ; curr->next = curr->next->next
;mov [r14 + 8], r13 ; begin_list->next = curr ;mov [r14 + 8], r13 ; begin_list->next = curr
;mov rdx, [r13 + 8] ;mov rdx, [r13 + 8]
mov rbx, [r13 + 8] mov rcx, [r13 + 8]
mov [r14], rbx mov [r14], rcx
;je .done ;je .done
mov rbx, [r13 + 8] mov rcx, [r13 + 8]
mov rdx, [rbx + 8] mov rdx, [rcx + 8]
mov [r13 + 8], rdx mov [r13 + 8], rdx
mov rbx, [r14] mov rcx, [r14]
mov [rbx + 8], r13 mov [rcx + 8], r13
;jmp .done ;jmp .done
mov r12, 0 ; reset prev mov r12, 0 ; reset prev
mov r13, [r14] ; reset curr mov r13, [r14] ; reset curr