The MASM Forum

General => The Campus => Topic started by: jj2007 on August 07, 2015, 02:23:33 AM

Title: Brand new loop instruction discovered
Post by: jj2007 on August 07, 2015, 02:23:33 AM
Works only with the latest MASM version, or with JWasm:

include \masm32\MasmBasic\MasmBasic.inc      ; download (http://masm32.com/board/index.php?topic=94.0)
  Init
  mov ecx, 66666
  @@:
  Print Str$(ecx), " "
  loopnew @B
  Exit
end start
Title: Re: Brand new loop instruction discovered
Post by: K_F on August 07, 2015, 09:02:22 AM
Discovered ??
 :icon_eek:
Title: Re: Brand new loop instruction discovered
Post by: dedndave on August 07, 2015, 08:08:05 PM
1) is this a MasmBasic thing ?
2) isn't ECX destroyed in the Print call ?
3) what Van said - lol
Title: Re: Brand new loop instruction discovered
Post by: sinsi on August 07, 2015, 08:44:37 PM
 :lol: ml 6.15 has no problem with it either (as it shouldn't)
Title: Re: Brand new loop instruction discovered
Post by: dedndave on August 07, 2015, 08:47:40 PM
but - what opcode is generated ?
it's probably an alias for one of the well-known LOOPxx instructions
Title: Re: Brand new loop instruction discovered
Post by: jj2007 on August 07, 2015, 09:36:31 PM
it's probably an alias for one of the well-known LOOPxx instructions

Congrats, you are very close :t

LOOPNEW is "loop non-equal word sized". It loops as long as the zero flag is not set and cx>0.

 ;)

P.S.:
> 1) is this a MasmBasic thing ?
No, works with ML 6.14

> 2) isn't ECX destroyed in the Print call ?
Not in MasmBasic

> 3) what Van said - lol
I just discovered it :biggrin:
Title: Re: Brand new loop instruction discovered
Post by: habran on August 07, 2015, 11:10:25 PM
Code: [Select]
ins (LOOP,   loop,       OpCls( I8,   NONE,  NONE  ), 0,      0,  no_RM,  0xE2,     0x00,   P_86,    0)
ins (LOOPE,  loope,      OpCls( I8,   NONE,  NONE  ), 0,      0,  no_RM,  0xE1,     0x00,   P_86,    0)
ins (LOOPZ,  loopz,      OpCls( I8,   NONE,  NONE  ), 0,      0,  no_RM,  0xE1,     0x00,   P_86,    0)
ins (LOOPNE, loopne,     OpCls( I8,   NONE,  NONE  ), 0,      0,  no_RM,  0xE0,     0x00,   P_86,    0)
ins (LOOPNZ, loopnz,     OpCls( I8,   NONE,  NONE  ), 0,      0,  no_RM,  0xE0,     0x00,   P_86,    0)
ins (LOOPD,  loopd,      OpCls( I8,   NONE,  NONE  ), F_32A,  0,  no_RM,  0xE2,     0x00,   P_386,   0)
ins (LOOPED, looped,     OpCls( I8,   NONE,  NONE  ), F_32A,  0,  no_RM,  0xE1,     0x00,   P_386,   0)
ins (LOOPZD, loopzd,     OpCls( I8,   NONE,  NONE  ), F_32A,  0,  no_RM,  0xE1,     0x00,   P_386,   0)
ins (LOOPNED,loopned,    OpCls( I8,   NONE,  NONE  ), F_32A,  0,  no_RM,  0xE0,     0x00,   P_386,   0)
ins (LOOPNZD,loopnzd,    OpCls( I8,   NONE,  NONE  ), F_32A,  0,  no_RM,  0xE0,     0x00,   P_386,   0)
insx(LOOPW,  loopw,      OpCls( I8,   NONE,  NONE  ), F_16A,  0,  no_RM,  0xE2,     0x00,   P_86,    0, RWF_IA32)
insx(LOOPEW, loopew,     OpCls( I8,   NONE,  NONE  ), F_16A,  0,  no_RM,  0xE1,     0x00,   P_86,    0, RWF_IA32)
insx(LOOPZW, loopzw,     OpCls( I8,   NONE,  NONE  ), F_16A,  0,  no_RM,  0xE1,     0x00,   P_86,    0, RWF_IA32)
insx(LOOPNEW,loopnew,    OpCls( I8,   NONE,  NONE  ), F_16A,  0,  no_RM,  0xE0,     0x00,   P_86,    0, RWF_IA32)
insx(LOOPNZW,loopnzw,    OpCls( I8,   NONE,  NONE  ), F_16A,  0,  no_RM,  0xE0,     0x00,   P_86,    0, RWF_IA32)