The MASM Forum Archive 2004 to 2012

General Forums => The Laboratory => Topic started by: DoomyD on September 14, 2008, 11:44:16 PM

Title: High-level syntax macro simulation for low-level conditional operations
Post by: DoomyD on September 14, 2008, 11:44:16 PM
I created a macro library that simulates high-level syntax for direct conditional jumps; and I hope you'll find some good use for it :green
It's purpose is to allow the programmer to implement conditional jumps directly after using an instruction which affects the eflags, without the need to create a label for each case.
The macros included are:Here's an example code that utilizes the library, I hope it clears the point:.data
  samplestr db "hello world",0

.code
  mov  edi,offset samplestr
  mov  ecx,lengthof samplestr-1
  mov  eax,'r'
  repne scasb
  fIf  <<z>>
    xor  eax,eax
    inc eax
  fElse
    xor  eax,eax
  fEndIf

[attachment deleted by admin]
Title: Re: High-level syntax macro simulation for low-level conditional operations
Post by: Uzarius Futurus on September 15, 2008, 01:32:05 AM
DoomyD,

Nice work, this macro simplyfies the ASM writing yet more then it already is.
I had a quick look at the code and it seems nice, I will test it as soon as I get home.
Title: Re: High-level syntax macro simulation for low-level conditional operations
Post by: drizz on September 15, 2008, 02:19:05 AM
can you give a better example? i mean one that actually does something that built in code can't.
this code works just fine:

.if zero?
    xor  eax,eax
    inc eax
.else
    xor  eax,eax
.enid

or "setz al"
Title: Re: High-level syntax macro simulation for low-level conditional operations
Post by: DoomyD on September 17, 2008, 06:25:16 AM
For example, the opcodes JA, JBE, JG, JGE, GL, GLE, JNA, JNBE, JNG, JNGE, JNL and JNLE would require you to assemble a complex .if
NG, for instance, requires the following combination:zero? || sign? && !overflow? || !sign? && overflow? which assembles to 5 conditional jump instructions, while the macro will generate a single instruction.