Page 1 of 1

create a program that adds two numbers that have a single digit of integer and a single digit of traction For a simplifi

Posted: Fri May 20, 2022 6:13 pm
by answerhappygod
Create A Program That Adds Two Numbers That Have A Single Digit Of Integer And A Single Digit Of Traction For A Simplifi 1
Create A Program That Adds Two Numbers That Have A Single Digit Of Integer And A Single Digit Of Traction For A Simplifi 1 (130.09 KiB) Viewed 45 times
Using Visual Studio/MASM51 PLEASE
create a program that adds two numbers that have a single digit of integer and a single digit of traction For a simplified program only calculate the fraction to 8 bits of precision Do this by calculating the fraction as: binary_fraction = (fraction_digit * 25)/10 When calculating the exponent you need two methods. If there is an integer portion then the procedure would be as in Part2. If there is only a fraction then there is a negative exponent which subtracts from the bias amount. Also the fraction must be normalized, then the leading bit removed and combined with the exponent. If there is both an integer and a fraction the integer is normalized and the fraction bits are combined directly without normalizing them After performing the floating point addition in order to display the result (see the example output at the end of part 3), the output variable must be broken down into the exponent, integer and fraction portions of the number. The exponent bias is subtracted from the exponent to determine the number of bits of integer or fraction. If there is a positive exponent there is an integer and the exponent represents the length of it (there may or may not be a fraction depending on the bits that follow the integer portion). If the exponent is negative then there is only a fraction portion To calculate the integer portion into decimal repeatedly divide the integer part by 10 decimal(until ax=0). where the remainder of each divide represents the digits from Isd to msd. To calculate the fraction into decimal align the 8 fraction bits to the upper byte of the ax register then repeatedly multiply by 10 for as many digits of precision that are desired. The overflow into the dx register represents the digits from msd to lsd. note that the example below shows 8 digits of precision (so the multiplication process was repeated 8 times). Note if more than 8bit precision still left align all bits and convert in the same manor. As an example the user inputs a decimal number 123.123 and is converted into binary for further processing. Integer 123 = 1111011 and fraction 123*28 = 00011111 After processing in the floating point unit usually a different value result will need to be converted from a binary number back to decimal For this example we'll convert the same number back by calculating the integer using repeated divides by 10 decimal(1010 binary). Each successive divide by 10 the binary digits are shifted across the decimal point to the right as the remainder (ah being the remainder of an 8bit divide) from LSD to MSD. Converting the binary fraction back to decimal is the opposite operation by left aligning the fraction in a register in this case al but if ax or eax it would need to be in the upper byte of the register since it's an 8 bit fraction). After left aligning the fraction, perform repeated multiplications by 10 decimal which left shift a decimal digit worth of bits into the overflow register (ah being the overflow for an 8 bit multiply) from MSD to LSD. Note than the resulting decimal digits are 121 instead of 123 due to precision error

1111011 00011111 123.123 ah al 01111011 bi 00001010 div bl Decimal remainder ah al 00011111 Decimal overflow ы po001010 mul bl pseudo code examples of generating decimal from the floating point addition results mov 61,10 mov si, 0 mov al, int_binary portion while(al>0) { div bi bcd_integer_array[si]=an inc si } mov 61,10 mov si, 0 mov al, fraction_binary portion while(al>0 && si<max_digits) { mul b1 bcd_fraction_array[si]= ah inc si } 2 digit Combinations to attempt to program Notice with 8 bit precision there is error in the result (as shown on the example output screenshot).

Enter up to two digit float nunberi > Enter up to two digit float number2 >1 1.00000000 t Enter up to two digit float nunberi > Enter up to two digit float nunber2 > 3 Enter up to two digit float nunber1 >.3 Enter up to two digit float number2 >.4 .69531250 Enter up to two digit float nunberi >1 Enter up to two digit float number2 >.? 1.69921875 Enter up to two digit float nunberi >1 Enter up to two digit float nunber2 >1 1 2.00000000 Enter up to two digit float nunberi >1 Enter up to two digit float number2 >9 9 10.98989898 Enter up to two digit float nunberi >9.9 Enter up to two digit float nunber2 >9.9 119.79687500 Enter up to two digit float nunberi 71.5 Enter up to two digit float number2 >2.5 4.000000000 Enter up to two digit float nunberi >.