Author Topic: Brand new loop instruction discovered  (Read 4715 times)

jj2007

  • Member
  • *****
  • Posts: 13283
  • Assembly is fun ;-)
    • MasmBasic
Brand new loop instruction discovered
« on: August 07, 2015, 02:23:33 AM »
Works only with the latest MASM version, or with JWasm:

include \masm32\MasmBasic\MasmBasic.inc      ; download
  Init
  mov ecx, 66666
  @@:
  Print Str$(ecx), " "
  loopnew @B
  Exit
end start
Masm32 Tips, Tricks and Traps

Some members can't live without insulting others. It tells us a lot about them.

K_F

  • Member
  • *****
  • Posts: 1692
  • Anybody out there?
Re: Brand new loop instruction discovered
« Reply #1 on: August 07, 2015, 09:02:22 AM »
Discovered ??
 :icon_eek:
'Sire, Sire!... the peasants are Revolting !!!'
'Yes, they are.. aren't they....'

dedndave

  • Member
  • *****
  • Posts: 8828
  • Still using Abacus 2.0
    • DednDave
Re: Brand new loop instruction discovered
« Reply #2 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

sinsi

  • Guest
Re: Brand new loop instruction discovered
« Reply #3 on: August 07, 2015, 08:44:37 PM »
 :lol: ml 6.15 has no problem with it either (as it shouldn't)

dedndave

  • Member
  • *****
  • Posts: 8828
  • Still using Abacus 2.0
    • DednDave
Re: Brand new loop instruction discovered
« Reply #4 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

jj2007

  • Member
  • *****
  • Posts: 13283
  • Assembly is fun ;-)
    • MasmBasic
Re: Brand new loop instruction discovered
« Reply #5 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:
Masm32 Tips, Tricks and Traps

Some members can't live without insulting others. It tells us a lot about them.

habran

  • Member
  • *****
  • Posts: 1228
    • uasm
Re: Brand new loop instruction discovered
« Reply #6 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)
Cod-Father