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