# Thread: CS401 Assignment # 2- Help needed

1. ## CS401 Assignment # 2- Help needed

Question_1: [marks: 10]
Find the 2’s complement of a number using bitwise logical operator.

Question_2: [marks: 10]
Take a random number of word (dw), form and input this to a subroutine “Is Number Power of Two”. Check number is in power of 2 using bitwise logical operators and then display the return result on the screen if the number is even it diplay that number is even if the number is odd then it display the number is odd.

Due date: 22-11-2010

2. Kindly help in solving this assignment....please!

3. Hi Anya,
i think today is bonus day for ur assignment..
i have gOt this little help that may help u ...as its not my subject but my brothers

so kindly...have a look

Below is the idea solution:
Q1.
Take a number and move in one variable like AX.
Use NOT to invert.

Pseudo code:
move Ax, 10
Not AX

Q2.
Use the examples in handoouts (print number + hello world).
write a sub routine to check for even or odd, if it it odd (divide by 2, if remainder in dx is not zero, it is odd), then exit from sub routine using ret, and display the result,
If number is even, the check for power of two. Algoeithim is divide the number by 2 untill divider is 1 and check for remainder dx using XOR. if remainder is 1 then it is not power of 2,

subriutine of clear screen
subroutine to display
subroutine to check even
move AX,10 ;number to check
move bx, 2
div bx,
cmp dx,0
jnz outofsequence
move AX,10 ;number to check
move bx, 2
div bx,
cmp bx,1
jmb mainloop
XOR bx, dx
cmp bx, 0
if not 0, number is not power of 2,
else number is power of 2,
ret main loop
call display in main loop

you need to use stack in your program too.

I hope now it will be easy to write the program.

best regards

4. Good effort.

5. cs 402 ki assingment ka soln post kr dain.it is third assingment.it is difficult 4 me

7. cs402 solution

http://vuhelp.net/mcs/6247-cs402-theory-automata-idea-solution-assignment-no-3-spring-june-2011-a.html