Post a Reply

Replies

You will modify the first program since it operates only on decimal numbers. This exercise will have the conversation of decimal numbers to it binary form. The binary additions will simulate how a computer operates at the CPU level. Assume that our machine will work only on 16-bits data.

You should have the following addiotional functions:string DecToBin(int num) - converts the decimal number to its equivalent binary string formatint BinToDec(string num) - converts the binary string to its equivalent decimal number.string TwosComplimenent(string num) - get the two's compliment of a binary string.string AddBin(string num1, string num2) - add two binary strings.Modify the following in your second exercise:

In your decode function, make the transformation of decimal to its equivalent binary string. This includes the converstion of 2s compliment for negative numbers.AX, OP1 and OP2 global variables should already be string.In the execute function, make use of the AddBin function in your ADD operation function.The PRT operation function will however display the decimal equivalent of AX. Therefore, use the function BinToDec in this section of the code.

So I think this is it, but slowly it gets really confusing.Btw. Nice method with this 2's complement, didn't know it also works like this.

The only thing that confuses me at the instruction is the 16-bit data...What do you mean with "only on 16-bit data" ?Does this mean the result can have maximum 16 bit or the singl inputs (OP1, OP2)Because if I add two 16 bit values I need a 17th bit to save the result.And if I have a 16 bit result I only can add two 15 bit values.