vec_push returns inserted index
This commit is contained in:
parent
fd8a1f74bf
commit
07dcaf6a64
|
|
@ -161,7 +161,8 @@ vec_get:
|
|||
|
||||
;; rdi: pointer to Vec struct
|
||||
;; rsi: pointer to data to push
|
||||
;; fn vec_push(vec: *mut Vec, data: &[u8])
|
||||
;; returns the index at which the item was pushed (the old length of the vector)
|
||||
;; fn vec_push(vec: *mut Vec, data: &[u8]) -> usize
|
||||
vec_push:
|
||||
push rbp
|
||||
mov rbp, rsp
|
||||
|
|
@ -186,8 +187,9 @@ vec_push:
|
|||
mov rdx, [rax + 24] ; item_size
|
||||
call memcpy
|
||||
; vec.len += 1;
|
||||
mov rax, [rsp] ; vec
|
||||
add qword [rax + 8], 1
|
||||
mov rdx, [rsp] ; vec
|
||||
mov rax, [rdx + 8]
|
||||
add qword [rdx + 8], 1
|
||||
add rsp, 24
|
||||
pop rbp
|
||||
ret
|
||||
|
|
|
|||
Loading…
Reference in a new issue