From 78b4407869f2d89c72cf7139c2df9a438993307d Mon Sep 17 00:00:00 2001 From: MITSUNARI Shigeo Date: Wed, 21 Aug 2024 11:18:12 +0900 Subject: [PATCH] [sample] resize stack element --- sample/bf.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/sample/bf.cpp b/sample/bf.cpp index 2abb8a5..657c87c 100644 --- a/sample/bf.cpp +++ b/sample/bf.cpp @@ -30,7 +30,7 @@ public: const Reg32& pPutchar(esi); const Reg32& pGetchar(edi); const Reg32& stack(ebp); - const Address cur = dword [stack]; + const Address cur = byte [stack]; push(ebp); // stack push(esi); push(edi); @@ -42,7 +42,7 @@ public: const Reg64& pPutchar(rsi); const Reg64& pGetchar(rdi); const Reg64& stack(rbp); // stack - const Address cur = dword [stack]; + const Address cur = byte [stack]; push(rsi); push(rdi); push(rbp); @@ -53,7 +53,7 @@ public: const Reg64& pPutchar(rbx); const Reg64& pGetchar(rbp); const Reg64& stack(r12); // stack - const Address cur = dword [stack]; + const Address cur = byte [stack]; push(rbx); push(rbp); push(r12); @@ -80,7 +80,7 @@ public: case '<': { int count = getContinuousChar(is, c); - add(stack, 4 * (c == '>' ? count : -count)); + add(stack, (c == '>' ? count : -count)); } break; case '.': @@ -89,12 +89,12 @@ public: call(pPutchar); pop(eax); #elif defined(XBYAK64_WIN) - mov(ecx, cur); + movzx(ecx, cur); sub(rsp, 32); call(pPutchar); add(rsp, 32); #else - mov(edi, cur); + movzx(edi, cur); call(pPutchar); #endif break; @@ -106,13 +106,13 @@ public: call(pGetchar); add(rsp, 32); #endif - mov(cur, eax); + mov(cur, al); break; case '[': { Label B = L(); labelB.push(B); - mov(eax, cur); + movzx(eax, cur); test(eax, eax); Label F; jz(F, T_NEAR);