SlideShare a Scribd company logo
4
Most read
5
Most read
6
Most read
A solution manual to
Assembly language
Programming
and the organization of
the IBM PC
Chapter 2
Representation of numbers and
characters
BY:- Ytha Yu & Charles Marut
prepared by :
Warda Aziz
Wardaaziz555@gmail.com
Question 1:
In many applications , it saves time to memorize the conversions
among small binary, decimal, and hex numbers. Without referring to
the table , fill in the blanks in the following table
binary decimal hex
1001 9 9
1010 10 A
1101 13 D
1100 12 C
1110 14 E
1011 11 B
Question 2:
Convert the following numbers into decimal:
A) 1110
B) 100101011101
C) 46Ah
D) FAE2Ch
Solution:
1110:
=1*23
+ 1*22
+ 1*21
+ 0*20
=8 + 4 + 2 + 0
=14
100101011101:
=(1*211
)+(0*210
)+(0*29
)+(1*28
)+(0*27
)+(1*26
)+(0*25
)+(1*24
)+(1*23
)+(1*22
)+(0
*21
) +(1*2 0
)
=2048 + 0 + 0 + 256 + 0 + 64 + 0 + 16 + 8 +
4 + 0 +1
2397
46Ah:
=4*162
+ 6*161
+ A*160
=4*256+ 6*16 +10*1
=1024 + 96 +10
=1130
FAE2Ch:
=F*164
+ A* 163
+ E*162
+ 2*161
+C*160
=15*65536 + 10* 4096 + 14*256 +2*16 +12*1
=983040 + 40960 +3584 +32+12
=1027628
Question 3:
Convert the following decimal numbers:
a) 97 to binary
b) 627 to binary
c) 921 to hex
d) 6120 to hex
Solution:
97 to binary
;LCM with 2, remaining bits are in binary
=1110 0001
627 to binary
=0010 0111 0011
921 to hex
LCM with 16, remaining digits are in hex form
=399
6120 to hex
=17E8
Question 4:
Convert the following numbers:
a) 1001011 to hex
b) 1001010110101110 to hex
c) A2Ch to binary
d) B34Dh to binary
Solution:
a) 1001011 to hex
1001011=0100 1011(byte complete)
As we know 0100=4 and 1011=B
=4B
b) 1001010110101110 to hex
=95AE
c) A2Ch to binary
A=10d=1010(binary)
2=0010(binary)
C=12d=1100(binary)
=1010 0010 1100b
d) B34Dh to binary
B=11(decimal)=1011(binary),
3=0011(binary)
4=0100(binary)
D=1101(binary)
=1011 0011 0100 1101b
Question 5:
Perform the following addition:
a. 100101b + 10111b
b. 100111101b + 10001111001b
c. B23CDh + 17912h
d. FEFFEh + FBCADh
Solution:
100101b + 10111b

100101
+10111
111100
100111101b + 10001111001b
 
100111101
+ 10001111001
10110110110
B23CDh + 17912h
B23CD
+17912
C9CDF
FEFFEh + FBCADh
Solving from the right most values i.e., Eh+Dh=14d+13d=27d
27d=1Bh(solving through LCM method)
B is written below and 1 is given carry to the left bit.
Process goes so on and we get;
FEFFE
+FBCAD
1FACAB
Question 6:
Perform the following subtraction:
a) 11011 - 10110
b) 10000101 - 111011
c) 5FC12h - 3ABD1h
d) F001Eh - 1FF3Fh
Solution:
11011 - 10110
11011
- 10110
00101
10000101 - 111011
10000101
- 111011
1001010
5FC12h - 3ABD1h
    ;borrow carries
0101 1111 1100 0001 0010 (5FC12h)
- 0011 1010 1011 1101 0001 (3ABD1)
0010 0101 0000 0100 0001 (binary)
=25041(hex)
F001Eh - 1FF3Fh
    
1111 0000 0000 0001 1110
- 0001 1111 1111 0011 1111
1101 0000 0000 1101 1111
=D00DF
Question 7:
Give the 16 bit representation of each of the following decimal
integers . write answers in hex.
a. 234d
b. -16d
c. 31634d
d. -32216d
Solution:
234
Bin= 0000 0000 1110 1010
Hex=00EAh
-16
Bin=0000 0000 0001 0000
2’s compliment:
 
1111 1111 1110 1111
+ 1
1111 1111 1111 0000
=FFF0h
Hex=FFF0h
31634
bin= 0111 1011 1001 0010b
Hex=7B92h
-32216
Same as Q7(part e)
Bin=1000 0010 0010 1000b
Hex=8228h
Question 8:
Do the following binary and hex subtractions by two’s compliment
addition.
a) 10110100b - 10010111b
b) 10001011b - 11110111b
c) FE0Fh - 12ABh
d) 1ABCh - B3EAh
Solution:
Note:
if the resulting bit has a carry 1 , neglect the carry
if the result has no carry take 2’s compliment again with a negative sign.
10110100 - 10010111
Two’s compliment= 01101000+1=01101001

10110100
+ 01101001
1 00011101
Dropping the resulting carry bit we get the answer 0001 1101b or 11101b
10001011 - 11110111
2’s compliment 11110111=00001000+1=00001001
 
1000 1011
+0000 1001
1001 0100
Taking 2’s compliment again and put a negative sign

01101011
+1
01101100
Ans -1101100
FE0Fh - 12ABh
FE0Fh - 12ABh=1111111000001111b-1001010101011b
Take 2’s compliment of 0001 0010 1010 1011b;
1110 1101 0101 0100b+1b=1110 1101 0101 0101b
   
1111 1110 0000 1111
+1110 1101 0101 0101
1 1110 1011 0110 0100
Ans: =1110 1011 0110 0100b
=EB64h
1ABCh - B3EAh
Same as Q8(3,2)
Ans: -992Eh
Question 9:
Give the signed and unsigned interpretations of each of the following
16 bit or 8 bit numbers.
a. 7FFEh
b. 8543h
c. FEh
d. 7Fh
Solution:
7FFEh
Signed: 32766 ; as the MSB is 0(in binary)
Unsigned: 32766
8543h
Signed: -31421 ; as the MSB is 1
Unsigned: 34115
FEh
Signed: -2 ; as the MSB is 1 (see table 2.4B)
Unsigned: 254
7Fh
Signed: 127 ; as the MSB is 0
Unsigned: 127
Question 10:
Show how the decimal integer -120 would be represented
a) In 16 bits
b) In 8 bits
As we know 120d=0111 1000(binary)
-120=2’s compliment
ANS:
16 bit:
(0000 0000 1000 0111)16 + 1= (1111 1111 1000 1000)16
8 bit:
(1000 0111)8 + 1= (1000 1000)8
;2’s compliment because we are solving for negative value i.e., -120
Question 11:
For each of the following numbers ,tell whether it could be stored
(a)as a 16 bit number or (b) as an 8 bit number?
a. 32767
b. -40000
c. 65536
d. 257
e. -128
ANS:
Number Bit storage
32767 16 bit
-40000 Bigger than 16 bit
65536 Bigger than 16 bit
257 16 bit
-128 both
Question 12:
For each of the following 16 bit numbers, tell whether it is positive or
negative?
ANS:
Signed number polarity
1010010010010100b negative
783E3h positive
CB33h negative
807Fh negative
9AC4h negative
Question 13:
If the character string “$12.75” is being stored in memory starting at
address 0, give the hex contents of byte 0-5.
Data string Data
$ $ 24
1 1 31
2 2 32
. . 2E
7 7 37
5 5 35
ANS: The content at address 5 is 35.
Question 14:
Translate the message of ASCII
41 74 74 61 63 6B 20 61 74 20 44 61 77 6E
ANS: Attack at Dawn
Question 15:
Suppose that a byte contains the ASCII code of an upper case letter.
What hex number should be added to it to convert it to lower case?
ANS: 20h
Question 16:
Suppose a byte contains a decimal digit that is “0”….“9” . what hex
number should be subtracted from the byte to convert it to the
numerical form of chracters?
Ans:30h

More Related Content

PDF
Assembly Langauge Chap 1
PDF
Organization of the ibm personal computers
PDF
Chapter 5The proessor status and the FLAGS registers
PDF
Introduction to ibm pc assembly language
PDF
chapter 7 Logic, shift and rotate instructions
PDF
Chap 8 The stack and introduction to procedures & Chapter 9 multiplication an...
PDF
Chapter 6 Flow control Instructions
PDF
assembly language programming and organization of IBM PC" by YTHA YU
Assembly Langauge Chap 1
Organization of the ibm personal computers
Chapter 5The proessor status and the FLAGS registers
Introduction to ibm pc assembly language
chapter 7 Logic, shift and rotate instructions
Chap 8 The stack and introduction to procedures & Chapter 9 multiplication an...
Chapter 6 Flow control Instructions
assembly language programming and organization of IBM PC" by YTHA YU

What's hot (20)

PPT
Assignment on alp
PDF
Assembly Language Programming By Ytha Yu, Charles Marut Chap 5 (The Processor...
PDF
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
PDF
Assembly Language Programming By Ytha Yu, Charles Marut Chap 10 ( Arrays and ...
PDF
Solution manual of assembly language programming and organization of the ibm ...
PPTX
Stack and its usage in assembly language
PDF
Assembly language (coal)
PDF
Assembly Language Programming By Ytha Yu, Charles Marut Chap 7 (Logic, Shift,...
PDF
Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...
PPT
Logic, shift and rotate instruction
PPTX
Flag Registers (Assembly Language)
PPTX
Computer architecture instruction formats
PPTX
System Programming Unit II
PPT
Assembly Language Lecture 5
PDF
Unit 3 – assembly language programming
PPT
Assembly Language Lecture 4
PPTX
Assembly 8086
PPTX
Instruction set of 8086
PPTX
Conditional branches
PPTX
Binary and hex input/output (in 8086 assembuly langyage)
Assignment on alp
Assembly Language Programming By Ytha Yu, Charles Marut Chap 5 (The Processor...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 10 ( Arrays and ...
Solution manual of assembly language programming and organization of the ibm ...
Stack and its usage in assembly language
Assembly language (coal)
Assembly Language Programming By Ytha Yu, Charles Marut Chap 7 (Logic, Shift,...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...
Logic, shift and rotate instruction
Flag Registers (Assembly Language)
Computer architecture instruction formats
System Programming Unit II
Assembly Language Lecture 5
Unit 3 – assembly language programming
Assembly Language Lecture 4
Assembly 8086
Instruction set of 8086
Conditional branches
Binary and hex input/output (in 8086 assembuly langyage)
Ad

Similar to Representation of numbers and characters (20)

PPTX
COATheoryLecture2.pptx Coa lecture presentaion
PDF
2. Number Systems AIUB COA COURSE SLIDES
PPTX
Data Representation
PPTX
Assembly Language Introduction where number and characters are represented
PPTX
Data Representation
PPT
08 Numeral systems
PPT
ch3a-binary-numbers.ppt ch3a-binary-numbers.ppt ch3a-binary-numbers.ppt
PPT
ch3a-binary-numbers.ppt
PPT
Review on Number Systems: Decimal, Binary, and Hexadecimal
PPT
binary-numbers.ppt
PPT
ch3a-binary-numbers.ppt
PPT
mmmmmmmmmmmmmmmmmmmmmmbinary-numbers.ppt
PPT
ch3a-binary-numbers.ppt
PPT
ch3a-binary-numbers.ppt
PPT
ch3a-binary-numbers.ppt-BINARY SYSTEM---
PPTX
PPT
ch3a-binary-numbers.ppt
PPTX
computer organization-computer organization-
PPTX
DEC Unit 1 Full-1.pptx Boolean Algebra and Logic gates
PPTX
Representation Of Numbers and Characters
COATheoryLecture2.pptx Coa lecture presentaion
2. Number Systems AIUB COA COURSE SLIDES
Data Representation
Assembly Language Introduction where number and characters are represented
Data Representation
08 Numeral systems
ch3a-binary-numbers.ppt ch3a-binary-numbers.ppt ch3a-binary-numbers.ppt
ch3a-binary-numbers.ppt
Review on Number Systems: Decimal, Binary, and Hexadecimal
binary-numbers.ppt
ch3a-binary-numbers.ppt
mmmmmmmmmmmmmmmmmmmmmmbinary-numbers.ppt
ch3a-binary-numbers.ppt
ch3a-binary-numbers.ppt
ch3a-binary-numbers.ppt-BINARY SYSTEM---
ch3a-binary-numbers.ppt
computer organization-computer organization-
DEC Unit 1 Full-1.pptx Boolean Algebra and Logic gates
Representation Of Numbers and Characters
Ad

Recently uploaded (20)

PDF
Business Ethics Teaching Materials for college
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
PDF
Insiders guide to clinical Medicine.pdf
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
Microbial disease of the cardiovascular and lymphatic systems
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
Week 4 Term 3 Study Techniques revisited.pptx
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PPTX
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
PPTX
Pharma ospi slides which help in ospi learning
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PPTX
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
PPTX
Cell Structure & Organelles in detailed.
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
Business Ethics Teaching Materials for college
Renaissance Architecture: A Journey from Faith to Humanism
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Anesthesia in Laparoscopic Surgery in India
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
Insiders guide to clinical Medicine.pdf
Module 4: Burden of Disease Tutorial Slides S2 2025
2.FourierTransform-ShortQuestionswithAnswers.pdf
Microbial disease of the cardiovascular and lymphatic systems
human mycosis Human fungal infections are called human mycosis..pptx
Week 4 Term 3 Study Techniques revisited.pptx
102 student loan defaulters named and shamed – Is someone you know on the list?
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
Pharma ospi slides which help in ospi learning
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
Cell Structure & Organelles in detailed.
O5-L3 Freight Transport Ops (International) V1.pdf

Representation of numbers and characters

  • 1. A solution manual to Assembly language Programming and the organization of the IBM PC Chapter 2 Representation of numbers and characters BY:- Ytha Yu & Charles Marut prepared by : Warda Aziz Wardaaziz555@gmail.com
  • 2. Question 1: In many applications , it saves time to memorize the conversions among small binary, decimal, and hex numbers. Without referring to the table , fill in the blanks in the following table binary decimal hex 1001 9 9 1010 10 A 1101 13 D 1100 12 C 1110 14 E 1011 11 B Question 2: Convert the following numbers into decimal: A) 1110 B) 100101011101 C) 46Ah D) FAE2Ch Solution: 1110: =1*23 + 1*22 + 1*21 + 0*20 =8 + 4 + 2 + 0 =14 100101011101: =(1*211 )+(0*210 )+(0*29 )+(1*28 )+(0*27 )+(1*26 )+(0*25 )+(1*24 )+(1*23 )+(1*22 )+(0 *21 ) +(1*2 0 ) =2048 + 0 + 0 + 256 + 0 + 64 + 0 + 16 + 8 + 4 + 0 +1 2397 46Ah: =4*162 + 6*161 + A*160 =4*256+ 6*16 +10*1 =1024 + 96 +10 =1130 FAE2Ch: =F*164 + A* 163 + E*162 + 2*161 +C*160 =15*65536 + 10* 4096 + 14*256 +2*16 +12*1 =983040 + 40960 +3584 +32+12 =1027628 Question 3: Convert the following decimal numbers: a) 97 to binary b) 627 to binary
  • 3. c) 921 to hex d) 6120 to hex Solution: 97 to binary ;LCM with 2, remaining bits are in binary =1110 0001 627 to binary =0010 0111 0011 921 to hex LCM with 16, remaining digits are in hex form =399 6120 to hex =17E8 Question 4: Convert the following numbers: a) 1001011 to hex b) 1001010110101110 to hex c) A2Ch to binary d) B34Dh to binary Solution: a) 1001011 to hex 1001011=0100 1011(byte complete) As we know 0100=4 and 1011=B =4B b) 1001010110101110 to hex =95AE c) A2Ch to binary A=10d=1010(binary) 2=0010(binary) C=12d=1100(binary) =1010 0010 1100b d) B34Dh to binary B=11(decimal)=1011(binary), 3=0011(binary) 4=0100(binary) D=1101(binary) =1011 0011 0100 1101b Question 5: Perform the following addition: a. 100101b + 10111b b. 100111101b + 10001111001b c. B23CDh + 17912h d. FEFFEh + FBCADh Solution:
  • 4. 100101b + 10111b  100101 +10111 111100 100111101b + 10001111001b   100111101 + 10001111001 10110110110 B23CDh + 17912h B23CD +17912 C9CDF FEFFEh + FBCADh Solving from the right most values i.e., Eh+Dh=14d+13d=27d 27d=1Bh(solving through LCM method) B is written below and 1 is given carry to the left bit. Process goes so on and we get; FEFFE +FBCAD 1FACAB Question 6: Perform the following subtraction: a) 11011 - 10110 b) 10000101 - 111011 c) 5FC12h - 3ABD1h d) F001Eh - 1FF3Fh Solution: 11011 - 10110 11011 - 10110 00101 10000101 - 111011 10000101 - 111011 1001010 5FC12h - 3ABD1h     ;borrow carries 0101 1111 1100 0001 0010 (5FC12h) - 0011 1010 1011 1101 0001 (3ABD1) 0010 0101 0000 0100 0001 (binary) =25041(hex) F001Eh - 1FF3Fh      1111 0000 0000 0001 1110 - 0001 1111 1111 0011 1111 1101 0000 0000 1101 1111
  • 5. =D00DF Question 7: Give the 16 bit representation of each of the following decimal integers . write answers in hex. a. 234d b. -16d c. 31634d d. -32216d Solution: 234 Bin= 0000 0000 1110 1010 Hex=00EAh -16 Bin=0000 0000 0001 0000 2’s compliment:   1111 1111 1110 1111 + 1 1111 1111 1111 0000 =FFF0h Hex=FFF0h 31634 bin= 0111 1011 1001 0010b Hex=7B92h -32216 Same as Q7(part e) Bin=1000 0010 0010 1000b Hex=8228h Question 8: Do the following binary and hex subtractions by two’s compliment addition. a) 10110100b - 10010111b b) 10001011b - 11110111b c) FE0Fh - 12ABh d) 1ABCh - B3EAh Solution: Note: if the resulting bit has a carry 1 , neglect the carry if the result has no carry take 2’s compliment again with a negative sign. 10110100 - 10010111 Two’s compliment= 01101000+1=01101001  10110100 + 01101001
  • 6. 1 00011101 Dropping the resulting carry bit we get the answer 0001 1101b or 11101b 10001011 - 11110111 2’s compliment 11110111=00001000+1=00001001   1000 1011 +0000 1001 1001 0100 Taking 2’s compliment again and put a negative sign  01101011 +1 01101100 Ans -1101100 FE0Fh - 12ABh FE0Fh - 12ABh=1111111000001111b-1001010101011b Take 2’s compliment of 0001 0010 1010 1011b; 1110 1101 0101 0100b+1b=1110 1101 0101 0101b     1111 1110 0000 1111 +1110 1101 0101 0101 1 1110 1011 0110 0100 Ans: =1110 1011 0110 0100b =EB64h 1ABCh - B3EAh Same as Q8(3,2) Ans: -992Eh Question 9: Give the signed and unsigned interpretations of each of the following 16 bit or 8 bit numbers. a. 7FFEh b. 8543h c. FEh d. 7Fh Solution: 7FFEh Signed: 32766 ; as the MSB is 0(in binary) Unsigned: 32766 8543h Signed: -31421 ; as the MSB is 1 Unsigned: 34115 FEh Signed: -2 ; as the MSB is 1 (see table 2.4B) Unsigned: 254 7Fh Signed: 127 ; as the MSB is 0
  • 7. Unsigned: 127 Question 10: Show how the decimal integer -120 would be represented a) In 16 bits b) In 8 bits As we know 120d=0111 1000(binary) -120=2’s compliment ANS: 16 bit: (0000 0000 1000 0111)16 + 1= (1111 1111 1000 1000)16 8 bit: (1000 0111)8 + 1= (1000 1000)8 ;2’s compliment because we are solving for negative value i.e., -120 Question 11: For each of the following numbers ,tell whether it could be stored (a)as a 16 bit number or (b) as an 8 bit number? a. 32767 b. -40000 c. 65536 d. 257 e. -128 ANS: Number Bit storage 32767 16 bit -40000 Bigger than 16 bit 65536 Bigger than 16 bit 257 16 bit -128 both Question 12: For each of the following 16 bit numbers, tell whether it is positive or negative? ANS: Signed number polarity 1010010010010100b negative 783E3h positive CB33h negative 807Fh negative 9AC4h negative Question 13:
  • 8. If the character string “$12.75” is being stored in memory starting at address 0, give the hex contents of byte 0-5. Data string Data $ $ 24 1 1 31 2 2 32 . . 2E 7 7 37 5 5 35 ANS: The content at address 5 is 35. Question 14: Translate the message of ASCII 41 74 74 61 63 6B 20 61 74 20 44 61 77 6E ANS: Attack at Dawn Question 15: Suppose that a byte contains the ASCII code of an upper case letter. What hex number should be added to it to convert it to lower case? ANS: 20h Question 16: Suppose a byte contains a decimal digit that is “0”….“9” . what hex number should be subtracted from the byte to convert it to the numerical form of chracters? Ans:30h