diff --git a/lang/src/vec.asm b/lang/src/vec.asm index ede801d..3053a8a 100644 --- a/lang/src/vec.asm +++ b/lang/src/vec.asm @@ -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