#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

# Determining if # of bit sets in 1st letter is even or odd

Member Posts: 10
[b][red]This message was edited by oldandtired at 2006-3-1 2:12:45[/red][/b][hr]
I just started learning assembly language. I need to determine whether the number of set bits in the first letter of my name is either odd or even. What instructions can I use to do this? I'm only using the 16-bit registers in my code. Any help will do, thanks!

• Member Posts: 511
: [b][red]This message was edited by oldandtired at 2006-3-1 2:12:45[/red][/b][hr]
: I just started learning assembly language. I need to determine whether the number of set bits in the first letter of my name is either odd or even. What instructions can I use to do this? I'm only using the 16-bit registers in my code. Any help will do, thanks!
:
:
:
:
[code]MOV al,letter ; load the value
OR al,al ; set the flags for it
JPE ParityEven ; JPE = jump if parity even
; the parity flag determines whether the number of set
; bits is odd or even
;The parity is odd

ParityEven:
;The parity is even[/code]

use these instructions:
JPE/JP = jump if parity even/if parity
JPO/JNP = jump if parity odd/if no parity

• Member Posts: 10
[b][red]This message was edited by oldandtired at 2006-3-1 21:15:0[/red][/b][hr]
Thank you. I was thinking along those lines, but I wasn't sure.

: : [b][red]This message was edited by oldandtired at 2006-3-1 2:12:45[/red][/b][hr]
: : I just started learning assembly language. I need to determine whether the number of set bits in the first letter of my name is either odd or even. What instructions can I use to do this? I'm only using the 16-bit registers in my code. Any help will do, thanks!
: :
: :
: :
: :
: [code]MOV al,letter ; load the value
: OR al,al ; set the flags for it
: JPE ParityEven ; JPE = jump if parity even
: ; the parity flag determines whether the number of set
: ; bits is odd or even
: ;The parity is odd
:
: ParityEven:
: ;The parity is even[/code]
:
: use these instructions:
: JPE/JP = jump if parity even/if parity
: JPO/JNP = jump if parity odd/if no parity
:
: