11-24-2010, 01:46 AM
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.
Add 1 to it.
Answer is 2.s complement,
Pseudo code:
move Ax, 10
Not AX
Add ax,1
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
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.
Add 1 to it.
Answer is 2.s complement,
Pseudo code:
move Ax, 10
Not AX
Add ax,1
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
