Skip to content

Commit

Permalink
[sample] resize stack element
Browse files Browse the repository at this point in the history
  • Loading branch information
herumi committed Aug 21, 2024
1 parent aabb091 commit 78b4407
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions sample/bf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Brainfuck : public Xbyak::CodeGenerator {
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);
Expand All @@ -42,7 +42,7 @@ class Brainfuck : public Xbyak::CodeGenerator {
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);
Expand All @@ -53,7 +53,7 @@ class Brainfuck : public Xbyak::CodeGenerator {
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);
Expand All @@ -80,7 +80,7 @@ class Brainfuck : public Xbyak::CodeGenerator {
case '<':
{
int count = getContinuousChar(is, c);
add(stack, 4 * (c == '>' ? count : -count));
add(stack, (c == '>' ? count : -count));
}
break;
case '.':
Expand All @@ -89,12 +89,12 @@ class Brainfuck : public Xbyak::CodeGenerator {
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;
Expand All @@ -106,13 +106,13 @@ class Brainfuck : public Xbyak::CodeGenerator {
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);
Expand Down

0 comments on commit 78b4407

Please sign in to comment.