From ed1a3444c7b04e9b1ddf6820cfefb797c4d5309f Mon Sep 17 00:00:00 2001 From: Sami Samhuri Date: Fri, 26 Jun 2009 11:37:45 -0700 Subject: [PATCH] [CHANGED] Removed use of the LOOP instruction. --- asm/binary.rb | 2 +- compiler.rb | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/asm/binary.rb b/asm/binary.rb index 29dbb3e..945f95c 100644 --- a/asm/binary.rb +++ b/asm/binary.rb @@ -803,7 +803,7 @@ module Assembler end - # TODO remove this, LOOP sucks ... only accepts a 1-byte signed offset. + # NOTE: LOOP only accepts a 1-byte signed offset. Don't use it. def loop_(label) real_eip = @eip + 2 # loop instruction is 2 bytes delta = @symtab.lookup_label(label) - real_eip diff --git a/compiler.rb b/compiler.rb index 08f110a..0b372cd 100644 --- a/compiler.rb +++ b/compiler.rb @@ -547,7 +547,8 @@ class Compiler asm.pop(ECX) match_word('end') - asm.loop_(start_label) + asm.dec(ECX) + asm.jnz(start_label) # Phony push! break needs to clean up the stack, but since we # don't know if there is a break at this point we fake a push and