need help :Generate Random Numbers

Hi,

I am new user to this forum and i hope i get nice support from all of you. As i'm having difficulty for writing these programs, i'm posting the questions here. I'm stuck in the middle of these programs. Can someone please help on these. Please note that i'm using MASM.

1.
Write a program that prompts a user to enter two binary numbers of up to 8 digits each, and prompts their sum on the next line in binary. If the user enters an illegal character, he or she should be prompted to begin again. Each input ends with a carriage return.

Sample execution:
Type a binary number, up to 8 digits : 11001010
Type a binary number, up to 8 digits : 10011100
The binary sum is : 101100110

2.
Suppose that AX = 1234h , BX = 5678h, CX = 9ABCh and SP = 100h. Give
the contents of AX, BX, CX and SP after executing the following
instructions

PUSH AX
PUSH BX
XCHG AX, CX
POP CX
PUSH AX
POP BX

3.
The following method can be used to generate random numbers in the
range 1 to 32767. Start with any number in this range.
Shift left once
Replace bit 0 by the XOR of bits 14 and 15
Clear bit 15

Write the following procedures
a. A procedure READ that lets the user enter a binary number and
stores it in AX.
b. A procedure RANDOM that receives a number in AX and returns a
random number in AX
c. A procedure WRITE that displays AX in binary.

Write a program that displays a ?, calls READ to read a binary number, and calls RANDOM and WRITE to compute and display 100 random numbers. The numbers should be displayed four per line, with four blanks separating the numbers.


Thanks,
Chanti

Sign In or Register to comment.

Howdy, Stranger!

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

Categories