From 39bccce4fdd1d5ebe312321c963e0325e4d696c5 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Sat, 21 Nov 2020 21:38:56 +0100 Subject: Bugfixing of stack (WIP) --- asm/intel64/encode.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'asm/intel64/encode.cpp') diff --git a/asm/intel64/encode.cpp b/asm/intel64/encode.cpp index a2434fd..4e72933 100644 --- a/asm/intel64/encode.cpp +++ b/asm/intel64/encode.cpp @@ -33,7 +33,7 @@ std::shared_ptr makeLoadValue(const FlowGraph::Data& data, const FlowGraph:: //FlowGraph::TemporaryStorage& storage {dynamic_cast(data_storage)}; index_t index { graph.scope()->indexOfData(data)}; - return makeOp("mov", Asm::Args{{Asm::Args::Register32("eax"), Asm::Args::Mem32Ptr64("rbp", int32_t(index) * -4)}}); + return makeOp("mov", Asm::Args{{Asm::Args::Register32("eax"), Asm::Args::Mem32Ptr64("rbp", int32_t(index + 1) * -4)}}); } else throw std::runtime_error("ICE: Unsupported type for operand data at load: "s + demangle(typeid(data_storage))); } @@ -52,7 +52,7 @@ std::shared_ptr makeStoreValue(const FlowGraph::Data& data, const FlowGraph: //FlowGraph::TemporaryStorage& storage {dynamic_cast(data_storage)}; index_t index { graph.scope()->indexOfData(data)}; - return makeOp("mov", Asm::Args{{Asm::Args::Mem32Ptr64("rbp", int32_t(index) * -4), Asm::Args::Register32("eax")}}); + return makeOp("mov", Asm::Args{{Asm::Args::Mem32Ptr64("rbp", int32_t(index + 1) * -4), Asm::Args::Register32("eax")}}); } else throw std::runtime_error("ICE: Unsupported type for operand data at store: "s + demangle(typeid(data_storage))); } @@ -79,7 +79,7 @@ std::shared_ptr makeAddValue(const FlowGraph::Data& data, const FlowGraph::G //FlowGraph::TemporaryStorage& storage {dynamic_cast(data_storage)}; index_t index { graph.scope()->indexOfData(data)}; - return makeOp("add", Asm::Args{{Asm::Args::Register32("eax"), Asm::Args::Mem32Ptr64("rbp", int32_t(index) * -4)}}); + return makeOp("add", Asm::Args{{Asm::Args::Register32("eax"), Asm::Args::Mem32Ptr64("rbp", int32_t(index + 1) * -4)}}); } else throw std::runtime_error("ICE: Unsupported type for operand data at add: "s + demangle(typeid(data_storage))); } @@ -109,7 +109,7 @@ std::vector> makeMulValue(const FlowGraph::Data& data, co //FlowGraph::TemporaryStorage& storage {dynamic_cast(data_storage)}; index_t index { graph.scope()->indexOfData(data)}; - return {{makeOp("mul", Asm::Args{{Asm::Args::Mem32Ptr64("rbp", int32_t(index) * -4)}})}}; + return {{makeOp("mul", Asm::Args{{Asm::Args::Mem32Ptr64("rbp", int32_t(index + 1) * -4)}})}}; } else throw std::runtime_error("ICE: Unsupported type for operand data at mul: "s + demangle(typeid(data_storage))); } @@ -139,7 +139,7 @@ std::vector> makeDivValue(const FlowGraph::Data& data, co //FlowGraph::TemporaryStorage& storage {dynamic_cast(data_storage)}; index_t index { graph.scope()->indexOfData(data)}; - return {{makeOp("div", Asm::Args{{Asm::Args::Mem32Ptr64("rbp", int32_t(index) * -4)}})}}; + return {{makeOp("div", Asm::Args{{Asm::Args::Mem32Ptr64("rbp", int32_t(index + 1) * -4)}})}}; } else throw std::runtime_error("ICE: Unsupported type for operand data at div: "s + demangle(typeid(data_storage))); } -- cgit v1.2.3