;COUNT_1--G5_5
;**********************************************************
datarea segment			;define data segment
addr	dw	number
number	dw	1234h
count	dw	?
datarea ends
;**********************************************************
prognam segment			;defint code segment
;----------------------------------------------------------
main	proc	far		;main part of program

	assume cs:prognam,ds:datarea

start:				;starting execution address

;set up stack for return
	push	ds		;save old data segment
	sub	ax,ax		;put zero in AX	
	push	ax		;save it on stack

;set DS register to current data segment
	mov	ax,datarea	;datarea segment addr
	mov	ds,ax	  	;  into DS register

;MAIN PART OF PROGRAM GOES HERE

	mov	cx,0		;initialize C to 0
	mov	bx, addr	
	mov	ax,[bx]		;put Y in AX
repeat:	test	ax,0ffffh	;test Y
	jz	exit		;if Y=0,get exit
	jns	shift		;if MSB=0,C unchanged
	inc	cx		;  else,C=C+1
shift:	shl	ax,1		;shift Y one bit left
	jmp	repeat		;repeat
exit:	mov	count,cx
	ret			;return to DOS

main	endp			;end of main part of prog.
;----------------------------------------------------------
prognam ends			;end of code segment
;**********************************************************

	end	start		;end assembly
