From 07e489dc05a71fc5d96478c02a64ff93f7279551 Mon Sep 17 00:00:00 2001 From: Dimitar Trendafilov Date: Sat, 19 Dec 2020 15:38:35 +0200 Subject: Fix usage of registers in assembler demo --- demo/asm/add_answer.asm | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/demo/asm/add_answer.asm b/demo/asm/add_answer.asm index 2864c3c..3bcda83 100644 --- a/demo/asm/add_answer.asm +++ b/demo/asm/add_answer.asm @@ -19,12 +19,16 @@ add_answer: push rcx push rdx push rsi -; Handle Win64 calling convention +; "Handle" Win64 calling convention ; push rdi ; used by System V push rcx ; used by Win64 push 1 mov rdi, rsp + ; Make sure that we commit the stack space we are going to use with the + ; registers + sub rsp, 24 + mov [rdi - 8], byte 42 mov r8, [rdi + 8] @@ -33,9 +37,9 @@ add_answer: mov rcx, r8 add rcx, r9 - mov [rdi + 16], rcx + mov [rdi - 16], rcx - mov eax, [rdi + 16] + mov eax, [rdi - 16] mov rsp, r15 pop r15 pop rbp -- cgit v1.3.1-23-gd82d