Unit1 Basic Structure of Computer HOD NOTES (2)
Unit1 Basic Structure of Computer HOD NOTES (2)
Architecture
Course Instructor
Dr. Umadevi V
Department of CSE, BMSCE
1
January 21, 2025 CSE, BMSCE
Unit-1
Computer is a “machine”
As long as power is supplied, processor keeps executing
instructions
Stored program model
Sequential order of execution
Memory: Program and data storage
2. Output Unit: Computer after computation returns the computed results, error messages,
etc. via output unit. The standard output device is a video monitor, LCD/TFT monitor. Other
output devices are printers, plotters etc.
Primary memory is a semiconductor memory that provides access at high speed. Run time program instructions and operands
are stored in the main memory. Main memory is classified again as ROM and RAM. ROM holds system programs and firmware
routines such as BIOS, POST, I/O Drivers that are essential to manage the hardware of a computer. RAM is termed as Read/Write
memory or user memory that holds run time program instruction and data. While primary storage is essential, it is volatile in
nature and expensive. Additional requirement of memory could be supplied as auxiliary memory at cheaper cost. Secondary
memories are non volatile in nature.
The control Unit and the Arithmetic and Logic unit of a computer system are jointly known as the Central
Processing Unit (CPU).
Program consists of
Basic Step1
N Instructions Instruction
Basic
. Step2
Instruction 1
.
Instruction 2 . Operation Operand
Basic Step m Or
.
. Opcode
.
. Register Memory
.
Instruction N.
….. -----
Memory Address 200 76
Label A
PC 100 R2
IR
Processor
….. -----
Memory Address 200 76
Label A
PC 100 R2
IR
Processor
….. -----
Memory Address 200 76
Label A
PC 100 R2
IR Load R2, A
….. -----
Memory Address 200 76
Label A
PC 101 R2
IR Load R2, A
….. -----
PC 101 R2
IR Load R2, A
….. -----
PC 101 R2 76
IR Load R2, A
….. -----
Memory Address 200 76
Label A
100 R2 76
PC
IR Load R2, A
Processor
Solution:
(a)
Load R0 , A
Load R1 , B
Add R1, R0
Store C , R1
20 1 1
21 2 2
20 1 1
21 2 2
Decimal Binary
0 00
1 01
2 10
3 11
January 21, 2025 CSE, BMSCE 39
Binary Number Representation or Base 2
Power of 2 Calculation Value
20 1 1
21 2 2
Decimal Binary
1 01
2 10
3 11
20 1 1
21 2 2
Decimal Binary
Convert binary to decimal by finding the decimal equivalent of the binary array of
digits 1011001012 and expanding the binary digits into a series with a base of 2giving an
equivalent of 35710 in decimal or denary.
7-bit Binary
Decimal
Number
5
14
26
53
7-bit Binary
Decimal
Number
5 0000101
14 0001110
26 0011010
53 0110101
We can use a single bit to identify the sign of a signed binary number as being positive or negative in
value. So to represent a positive binary number (+n) and a negative (-n) binary number, we can use
them with the addition of a sign.
For signed binary numbers the most significant bit (MSB) is used as the sign bit. If the sign bit is “0”,
this means the number is positive in value. If the sign bit is “1”, then the number is negative in value.
The remaining bits in the number are used to represent the magnitude of the binary number in the
usual unsigned binary number format way.
Then we can see that the Sign-and-Magnitude (SM) notation stores positive and negative values by
dividing the “n” total bits into two parts: 1 bit for the sign and n–1 bits for the value which is a pure
binary number. For example, the decimal number 53 can be expressed as an 8-bit signed binary
number as follows:
If all bits in a byte are inverted by changing each 1 to 0 and each 0 to 1, we have
formed the one’s complement of the number.
Convert 47 to an 8-bit, twos complement binary number. This is positive, so all that is needed is to convert to
binary and pad to eight bits. So 4710 = 1011112. So 47 as an 8-bit two's complement number is just
00101111.
Convert -109 to an 8-bit, twos complement number. So 10910 = 11011012.
Convert 81 to an 8-bit, twos complement number. Since this is positive, it's just a matter of converting to binary and
padding to 8 bits. So 8110 = 10100012, giving 01010001
Adding 0101 +5
+5-5 1101 -5
Total 10010 INCORRECT, because the result should be zero
(1 i.e., 00000
Carryout)
Adding 0101 +5
+5-5 1010 -5
One’s Complement of -5
+7 0111
Two’s Complement
+6 0110 (4-bit Representation)
+5 0101
Adding 0101 +5
+4 0100 +5-5 1011 -5
+3 0011
Total 10000 CORRECT(Zero)
+2 0010
(1 Ignore the Carryout
+1 0001 Carryout)
+0 0000
-0 – Two’s Complement
(4-bit Representation)
-1 1111
-2 1110 Adding 0110 +6
+6-2 1110 -2
-3 1101
-4 1100 Total 10100 CORRECT(+4)
-5 1011 (1 Ignore the Carryout
Carryout)
-6 1010
-7 1001
January 21, 2025 CSE, BMSCE 72
Addition and Subtraction of Signed Numbers using two’s Complement
The 2’s complement is the most efficient method for performing addition and subtraction
operations
The rules governing addition and subtraction of n-bit signed numbers using 2's complement
representation system may be stated as follows:
To add two numbers, add their n-bit representation , ignoring the carry-out bit from the Most
Significant Bit (MSB) position. The sum will be algebraically correct value in 2’s complement
representation if the actual result is in the range -2n-1 through +2n-1 -1
To subtract two numbers X and Y, that is, to perform X-Y, form the 2’s complement of Y,
then add it to X using the add rule. Again, the result will be algebraically correct value in 2’s
complement representation if the actual result is in the range -2n-1 through +2n-1 -1
Note:
Subtrahend: what is being subtracted
Minuhend: what it is being subtracted from
Carry Out
Ignore
Ignore
11100 -4
Care must be taken when adding numbers of like sign since overflow can occur.
If you add two numbers of like sign and the result is of the opposite sign, then the result cannot be used. This
"overflow" condition occurs because, in order to represent the result, we would need more bits than are available
in the bit field. (Remember, we can't just "enlarge" the size of the result- it must remain the same size as the
operands.) Here are examples for adding two negative numbers, and adding two positive numbers, each of which
results in overflow.
Overflow occurs if
(+A) + (+B) = −C
(−A) + (−B) = +C
If two 2's Complement numbers are subtracted, and their signs are different, then overflow
occurs if and only if the result has the same sign as the subtrahend.
Overflow occurs if
(+A) − (−B) = −C
(−A) − (+B) = +C
Example: Using 4-bit Two's Complement numbers (−8 ≤ x ≤ +7)
Subtract −6 from +7
(+7) 0111 0111
−(−6) 1010 -> Negate -> +0110
---------- -----
13 1101 (−3) : Overflow
1 second word
•
•
•
i th word
•
•
•
M-1 last word
2 22=4 Locations
3 23=8 Locations
4 24=16 Locations
Memory
Address Word Length
K=2bits n =8bits = 1 Byte
0 00 0000 0110 1st Byte or word
1 01 0000 0111 2nd Byte or word
2 10 0000 1000 3rd Byte or word
3 11 0000 1010 4th Byte or word
Big-endian and little-endian are terms that describe the order in which
a sequence of bytes are stored in computer memory.
1. Big-endian addressing assigns Lower byte addresses to Most Significant
(leftmost) bytes of word
2. Little-endian addressing assigns Lower byte addresses to Least Significant
(rightmost) bytes of word
Example: Consider storing the number 2064 i.e., Two thousand Sixty four. We will assume one digit
occupies 4bits.
2064 2 0 6 4
0010 0000 0110 0100
MSB LSB
Most Significant Byte Least Significant Byte
Example: Consider storing the number 2064 i.e., Two thousand Sixty four. We will assume one digit
occupies 4bits.
2064 2 0 6 4
0010 0000 0110 0100
MSB LSB
Most Significant Byte Least Significant Byte
Big-endian addressing assigns Lower byte addresses Little-endian addressing assigns Lower byte addresses
to Most Significant (leftmost) bytes of word to Least Significant (rightmost) bytes of word
W ord
address Byte address Byte address
0 0 1 2 3 0 3 2 1 0
4 4 5 6 7 4 7 6 5 4
• •
• •
• •
k k k k k k k k k k
2 - 4 2 - 4 2 - 3 2 - 2 2 - 1 2 - 4 2 - 1 2 - 2 2 - 3 2 - 4
Note: To specify
Hexadecimal numbers
Prefix 0x will be used
i.e.,
0x123
or
123h
Hex
c 0x63
o 0x6F
m 0x6D
p 0x70
u 0x75
t 0x74
e 0x65
r 0x72
Word Length
Hex Address n=8bits=1 Byte
c 63 1000 0110 0011 c 63 MSB
o 6F 1001 0110 1111 o 6F
m 6D 1002 0110 1101 m 6D
p 70 1003 0111 0000 p 70
u 75 1004 0111 0101 u 75 Big-Endian Approach
t 74 1005 0111 0100 t 74
e 65 1006 0110 0101 e 65
r 72 1007 0111 0010 r 72 LSB
January 21, 2025 CSE, BMSCE 106
Question
Consider a computer has a byte-addressable memory organized in 32-bit words according to the Little-endian scheme. A
program reads ASCII characters entered at a keyboard and stores them in successive byte locations, starting at location
1000. Show the contents of the two memory words at locations 1000 and 1004 after the word “computer” has been
entered. Values corresponding to the characters are as shown below:
Hex
c 63
o 6F
m 6D
p 70
u 75
t 74
e 65
r 72
Word Length
Hex Address n=8bits=1 Byte
c 63 1000 0110 0011 r 72 LSB
o 6F 1001 0110 1111 e 65 1000: 72 65 74 75
m 6D 1002 0110 1101 t 74 r e t u
p 70 1003 0111 0000 u 75
1004: 70 6D 6F 63
u 75 p m o c
1004 0111 0101 p 70 Little-Endian
t 74 1005 0111 0100 m 6D Approach
e 65 1006 0110 0101 o 6F
r 72 1007 0111 0010 c 63 MSB
Example
Load R2, LOC ; R2 [LOC]
R1 2 R1 18
R2 10 R2 10
0x2000 2 0x2000 2
R1 0x2000 R1 0x2000
R2 8 R2 10
0x2005 2 0x2005 2
R1 0x2000 R1 0x2000
R2 8 R2 2
0x2005 6 0x2005 6
R1 0x2000 R1 0x2000
R2 8 R2 6
R3 5 R3 5
ii. (R4,R5)
EA=[R4]+[R5]
5000=2000+3000
iii. 28(R4,R5)
EA= [28]+[R4]+[R5]
5028= 28+2000+3000
January 21, 2025 CSE, BMSCE 147
Index Addressing Mode used in accessing Test Scores
Move R2, #LIST ; Get the address LIST.
Clear R3
Clear R4
Clear R5
Load R6, N ; Load the value n.
LOOP: Load R7, 4(R2) ; Add the mark for next student's
Add R3, R3, R7 ; Test 1 to the partial sum.
Load R7, 8(R2) ; Add the mark for that student's
Add R4, R4, R7 ; Test 2 to the partial sum.
Load R7, 12(R2) ; Add the mark for that student's
Add R5, R5, R7 ; Test 3 to the partial sum.
Add R2, R2, #16 ; Increment the pointer.
Subtract R6, R6, #1 ; Decrement the counter.
Branch_if_[R6]>0 LOOP ; Branch back if not finished.
Store R3, SUM1 ; Store the total for Test 1.
Store R4, SUM2 ; Store the total for Test 2.
Store R5, SUM3 ; Store the total for Test 3.
N 2 1000
Sum1 1036
Sum2 1040
Sum3 1044
Clear R3 3004
Program to find sum of Test1, Test2 and Test3 marks of all students
Clear R4 3008
Memory
4 Bytes Address Clear R5 3012
Clear R3 3004
After executing the program
Clear R4 3008
Memory
4 Bytes Address Clear R5 3012
N : DATAWORD 3 N 3 204
NUM: DATAWORD 10, 20, 30 NUM 10 208
END
20 212
30 216
END of Unit-1