LMC Code for Sum of Odd Values

Verified

Added on  2022/12/18

|13
|1654
|6
AI Summary
This article provides step-by-step instructions on how to write LMC code to calculate and show the sums of the odd values from 1 to 15 as output. It includes a detailed algorithm and screenshots of the code running in the LMC interpreter. The article also references relevant sources on computer architecture and LMC instruction set.

Contribute Materials

Your contribution can guide someone’s learning journey. Share your documents today.
Document Page
IFN503: Assessment 2
[Type the document subtitle]

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
Contents
Question 1...................................................................................................................................................1
Question 2...................................................................................................................................................4
Question 3...................................................................................................................................................8
REFERENCES..............................................................................................................................................12
Question 1
Osborne(1992)
Solution:
The character string = +15.3682.
The ASCII (American Standard Code for Information Interchange) is a set of 128 characters, which is
defined and standards are set accordingly 7 bits are sufficient to represent 128 characters. ASCII is most
commonly used code and in computer programming it is very important to know this.
The character string mentioned here is +15.3682
First character: +
Hex format = 2B
Document Page
Binary format = 00101011
Decimal format = 43
Octal format = 53
Second character: 1
Hex format = 31
Binary format = 00110001
Decimal format = 49
Octal format = 61
Third character: 5
Hex format = 35
Binary format =00110101
Decimal format = 53
Octal format = 65
Fourth character: .
Hex format = 2E
Binary format =00101110
Decimal format = 46
Octal format = 56
Fifth character: 3
Hex format = 33
Binary format =00110011
Decimal format = 51
Octal format = 63
Fifth character: 6
Hex format = 36
Binary format =00110110
Document Page
Decimal format = 54
Octal format = 66
Sixth character: 8
Hex format = 38
Binary format =00111000
Decimal format = 56
Octal format = 70
Seventh character: 2
Hex format = 32
Binary format =00110010
Decimal format = 50
Octal format = 62
So, the character in
a) Hexadecimal format is
2B 31 35 2E 33 36 38 32
b) Binary number system
00101011 00110001 00110101 0010111000110011 00110110 00111000 00110010
c) Octal number system
5361655663667062
d) Decimal number system
43495346515456 50

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
Question 2
Tanenbaum (1999) IEEE 754 floating point format is a convention that is followed commonly in
computer language for programming and data transmission, this format is of 32 bits, which consist of
following bits
Sign bit Exponent Mantissa
1 bit (0 for positive and 1 for
negative numbers )
8 bit 23 bits
a) Desikan(2001)
+78.875 is given as fixed point decimal number, we need to convert it into
The steps that is followed during conversion of decimal number into IEEE 754 floating point are given
below
Step 1:convert decimal number into binary format
Step 2:convert the binary equivalent number into normalized format, to get exponent and mantissa
Step3: the exponent is converted into biased form and converted into binary format, in this example we
need to add 27-1 = 127, as 8 bits are taken for the exponent.
Step 4:As mantissa is of 23 bits, take as much zero as needed to have 23 bits
Step 5: take all the 32 bits as given above to get binary value of IEEE 754 floating point number.
Step 6: convert the binary value into hexadecimal value,
So, as per the steps explained above
Step 1: 78.875 = 1001110.11100
Step 2: normalized format: 1.00111011100 *26
Step 3: exponent biased form = 6+127 = 133,in binary notation = 10000101
Step 4: Mantissa = 00111011100000000000000
Step 5: give binary value of the calculated sign, exponent and mantissa
Document Page
Sign (1 bit) Exponent (8 bits ) Mantissa(23 bits)
0 10000101 00111011100000000000000
Step 6 :
0100 0010 1001 1101 1100 0000 0000 0000
4 2 9 D C 0 0 0
Using the conversion to convert binary to hexadecimal value, take 4 bits at a time and use the following
way
(Bit3)*23+ (bit2)*22+ (bit1)*21+ (bit0)*20
So, the answer is
429DC000
b) IN this scenario, the hypothetical convention is thought where, the IEEE floating point number
consists of
Sign bit Exponent Mantissa
1 bit (0 for positive and 1 for
negative numbers )
6 bit 25 bits
+78.875 is the decimal number given which is needed to be converted into this IEEE 754 floating point
number.
As explained in the above scenario , the steps are similar , the only difference is the biased exponent
value is now different , as the number of bits used for exponent and mantissa is different . the step by
step conversion of the number is explained below
Step 1: first we need to convert the decimal number into binary equivalent
78.875 = 1001110.11100
Step 2 : now we need to write the binary equivalent number into normalized format
1.00111011100 *26
Document Page
Step 3: the biased number for the exponent as , the number of bits are 6, will be 25-1 = 31
So adding the exponent value from the normalized format with 31 we will be biased form of exponent ,
which will be in decimal format .
6+31 = 37
Step 4: convert the biased decimal from into binary form
37 ==100101
We get the 6 bit exponent in binary form as 100101
Step 5: calculate the mantissa according to the number of bits needed, here 25 bits are given for
mantissa, so we will add required number of zero bits.
0011101110000000000000000is the mantissa
Sign (1 bit) Exponent (6 bits ) Mantissa(25 bits)
0 100101 0011101110000000000000000
0100 1010 0111 0111 0000 0000 0000 0000
4 A B B 0 0 0 0
So, the answer is
4ABB0000(hex format)
c)
In this question the given Hexadecimal number is C37DD000, we need to convert this hexadecimal
number to decimal number where it was got from in IEEE 754 floating point number.
STEP 1: first we need to convert this hex value into equivalent binary notation
1100 0011 0111 1101 1101 0000 0000 0000
Sign (1 bit) Exponent (8 bits ) Mantissa(25 bits)
1 10000110 111 1101 1101 0000 0000 0000

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
The first bit is sign bit, from the above table, we get that number is negative
Step 2: finding the exponent
Here, the exponent has 8 bits, so the biased form must have been added with 127
The decimal equivalent of 10000110 is 134
So , the exponent value will be 134-127 = 7
, so exponent will be 7
Step 3 : The mantissa binary value is 111 1101 1101 0000 0000 0000
So in normalized format , we can write in following manner
1.111 1101 1101 0 *27
Step 4: renormalizing the value to get the binary equivalent of the original decimal number is
1111 1101.1101 0
Step 5: the Decimal equivalent of the binary number 1111 1101.1101 0is-253.8125
Document Page
Question 3
Solution
Englander(1996) in this question we need to write LMC code which will execute and show the sums of
the odd values from 1 to 15 as output
The output will be calculated as follows
1=1
1+3=4
1+3+5=9
1+3+5+7=16
1+3+5+7+9=25
1+3+5+7+9+11=36
1+3+5+7+9+11+13=49
1+3+5+7+9+11+13+15 =64
Algorithm:
Gedupudi (2000).
Step 1 : take the maximum value upto which addition will be done , in this case it is 15.
Step 2 : take the first number to be 1 , and give its output and store it.
Step 3: add 2 to the stored number after each addition.
Step 4: give the output
Step 5: repeat step 3 and 4 until the last number that is 15 is not used.
Step 6: end the program
Document Page
LMC Code is given below
LDA MAX |Load value from Mailbox at MAX
STO 77 |Store at mailbox at 77
LDA VAL1 |load value from mailbox at VAL1
STO 75 |Store at mailbox at 75
STO 76 |Store at mailbox at 76
AGAIN: OUT |output result
LDA 77 |load value from mailbox at 77
SUB 75 |subtract values from mailbox at 75
BRZ STOP |branch on positive result at STOP
LDA 75 |load value from mailbox at 75
ADD VAL2 |add value from mailbox at VAL2
STO 75 |Store at mailbox at 75
ADD 76 |add value from mailbox at 76
STO 76 |Store at mailbox at 76
BRP AGAIN | Branch when positive to again
VAL1: DAT 1 |data value 1
VAL2: DAT 2 |data value 2
MAX: DAT 15 |data value 3
STOP: HLT |stop the program
Screenshots of the code running in the LMC interpreter

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
LMC code Output:
Document Page
Document Page
REFERENCES
Clements, A. (2000). Computer architecture education. IEEE Micro, 20(3), 10-12. Doi:
10.1109/mm.2000.846304
Desikan, R., Burger, D., Keckler, S., Cruz, L., Latorre, F., Gonzalez, A., & Valero, M.
(2002). Errata on "Measuring Experimental Error in Microprocessor
Simulation". ACM SIGARCH Computer Architecture News, 30(1), 2. Doi:
10.1145/511120.511122
Hsiung, P. (2000). Embedded software verification in hardware–software code
sign. Journal Of Systems Architecture, 46(15), 1435-1450. doi: 10.1016/s1383-
7621(00)00034-5
Little man computer. (2019). Retrieved 6 September 2019, from
https://en.wikipedia.org/wiki/Little_man_computer
LMC Instruction Set. (2019). Retrieved 6 September 2019, from
http://www.yorku.ca/sychen/research/LMC/LMCInstructions.html
Tanenbaum, A. (2019). Structured Computer Organization (4th ed.) Prentice Hall,.
The LMC Instruction Set | Key Information & Glossary | Computer Science. (2019).
Retrieved 6 September 2019, from https://teachcomputerscience.com/lmc-instruction-
set/
1 out of 13
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]

Your All-in-One AI-Powered Toolkit for Academic Success.

Available 24*7 on WhatsApp / Email

[object Object]