News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Calculating Parity

Started by asm_coder, April 27, 2010, 11:12:23 AM

Previous topic - Next topic

jj2007

The Macro :green

include \masm32\include\masm32rt.inc

Parity MACRO arg
  ifdifi <eax>, <arg>
mov eax, arg
  endif
  push eax
  shr eax, 16
  xor eax, [esp]
  add esp, 4
  xor al,ah
  EXITM <Parity?>
ENDM

.data?
binbuffer db 36 dup(?)

.code
start:
xor ebx, ebx
.Repeat
invoke dw2bin_ex, ebx, offset binbuffer
print offset binbuffer+16 ; lowword only
.if Parity(ebx)
print " has parity", 13, 10
.else
print " has no parity", 13, 10
.endif
inc ebx
.Until ebx>400
exit

end start

dedndave

why not preserve EAX ?
Parity MACRO arg
  ifdifi <eax>, <arg>
mov eax, arg
  endif
  push eax
  shr eax, 16
  xor eax, [esp]
  xor al,ah
  pop eax
  EXITM <Parity?>
ENDM