Chapter 1 • Basic Concepts
Chapter 1 • Basic Concepts
Portable Code
Portable code can run on different computer systems with little or no modification. It
uses standard programming practices and avoids system-specific features.
Languages like Java achieve portability by running on an intermediate platform like
the JVM.
Non-Portable Code
Microcode Interpreter
Assembly language rules are based on the processor's limitations, like requiring
operands to be the same size. It has fewer rules than high-level languages like C++
or Java, which restrict low-level access to prevent errors. Assembly allows direct
memory access but requires more debugging effort due to its freedom and
complexity.
In the past, most programs were written in assembly language due to limited
memory and slow processors. With faster processors and larger memory,
programmers shifted to high-level languages like C, FORTRAN, and later
object-oriented languages like C++ and Java for complex applications. Today,
assembly language is rarely used for entire programs but is employed to optimize
critical sections for speed and hardware access.
Questions 🙂
How do assemblers and linkers work together?
Assemblers translate assembly language code into machine code, producing object
files. Linkers then combine these object files, resolving references between them to
create a single executable program.
Is the assembly language for x86 processors the same as those for computer
systems such as the VAX or Motorola 68x00?
No, assembly languages are specific to each processor's architecture. The x86, VAX,
and Motorola 68x00 have distinct instruction sets and assembly languages.
Name two types of applications that would be better suited to assembly language
than a high-level language.
Applications requiring direct hardware access and those needing highly optimized
code for performance, such as embedded systems and computer games, are better
suited to assembly language.
Why would a high-level language not be an ideal tool for writing a program that
directly accesses a particular brand of printer?
High-level languages may not provide the necessary low-level access to
hardware-specific features of a particular printer, making assembly language more
suitable for such tasks.
Why is assembly language not usually used when writing large application
programs?
Assembly language is time-consuming to write and maintain, making it impractical
for large applications compared to high-level languages that offer more abstraction
and efficiency.
The virtual machine concept explains how hardware and software interact to
execute programs.
○ Java uses this concept. Java programs are compiled into Java
bytecode (a low-level language).
○ The JVM interprets this bytecode and executes it, making Java
programs system-independent.
1. Number Systems:
○ Numbers are represented in different bases: binary (base 2), decimal (base 10),
and hexadecimal (base 16).
○ Binary uses 0 and 1, while hexadecimal uses digits 0-9 and letters A-F (for
values 10-15).
2. Binary Numbers:
○ Binary digits (bits) can be 0 or 1, representing electronic on/off states.
○ MSB (Most Significant Bit) is the leftmost bit; LSB (Least Significant Bit) is the
rightmost bit.
○
2. Steps for Addition:
○ Start from the right (LSB), add bit pairs, and handle carries.
3. Overflow:
○ If the sum exceeds the bit limit (e.g., adding 11111111 + 1), the result wraps
around (e.g., 00000000 for 8 bits).
● Hexadecimal Representation:
○ Each hexadecimal digit represents 4 binary bits, making it easier to read large
binary numbers.
○ Hexadecimal uses digits 0-9 and letters A-F (for decimal 10-15).
○ Two hexadecimal digits together represent one byte (8 bits).
Signed Integers
Two’s-Complement Notation
Example:
For signed binary 11110000, the highest bit is 1, so:
Example:
For −43:
A signed integer of n bits uses only n-1 bits to represent the number’s magnitude.
Character Storage
Computers store characters using character sets, which map characters to integers.
ASCII Strings
● Codes 0–31 in ASCII are control characters, used for actions like backspace, line feed,
and carriage return.
Example:
○ Code 8: Backspace
○ Code 10: Line feed
Questions 🙂
Least Significant Bit (LSB): The rightmost bit in a binary number, which represents the
smallest value (2^0 or 1).
Most Significant Bit (MSB): The leftmost bit in a binary number, representing the largest value
(highest power of 2).
● a. 11111000 = 248
● b. 11001010 = 202
● c. 11110000 = 240
● a. 00110101 = 53
● b. 10010110 = 150
● c. 11001100 = 204
● a. Word = 2 bytes
● b. Doubleword = 4 bytes
● c. Quadword = 8 bytes
● a. Word = 16 bits
● b. Doubleword = 32 bits
● c. Quadword = 64 bits
● a. 65 = 7 bits
● b. 256 = 9 bits
● c. 32768 = 15 bits
● a. 4095 = 12 bits
● b. 65534 = 16 bits
● c. 2134657 = 22 bits
● a. 1100111101010111 = CF57
● b. 0101110010101101 = 5CAD
● c. 1001001111101011 = 93EB
● a. 0011010111011010 = 35DA
● b. 1100111010100011 = CEA3
● c. 1111111011011011 = FEDB
● a. E5B6AED7 = 11100101101101101010111011010111
● b. B697C7A1 = 10110110100101111000011110100001
● c. 234B6D92 = 00100011010010110110110110010010
● a. 0126F9D4 = 00000001001001101111100111010100
● b. 6ACDFA95 = 01101000110011011111101010010101
● c. F69BDC2A = 11110110100110111111001010101010
Unsigned decimal representation of hexadecimal numbers:
● a. 3A = 58
● b. 1BF = 447
● c. 4096 = 16,384
● a. 62 = 98
● b. 1C9 = 457
● c. 6A5B = 27,339
● a. -26 = FFDA
● b. -452 = FFCD
● a. -32 = FFE0
● b. -62 = FF9E
● a. 7CAB = 31,195
● b. C123 = -3,869
● a. 7F9B = 32,827
● b. 8230 = -31,744
● a. 10110101 = -75
● b. 00101010 = 42
● c. 11110000 = -16
● a. 10000000 = -128
● b. 11001100 = -52
● c. 10110111 = -73
8-bit two’s complement binary representation:
● a. -5 = 11111011
● b. -36 = 11011100
● c. -16 = 11110000
● a. -72 = 10111000
● b. -98 = 10011110
● c. -26 = 11100110
● Hexadecimal: 58
● Decimal: 88
● Hexadecimal: 4D
● Decimal: 77
Boolean Operations
Boolean algebra defines a set of operations on the values true and false. It was invented by
George Boole, a mid-nineteenth-century mathematician. Boolean operations are mathematical
operations used to work with true/false values. They are essential in digital circuits and
programming.
Boolean Expression A boolean expression involves a boolean operator and one or more
operands. Each boolean expression implies a value of true or false. The set of operators
includes the folllowing:
1. NOT (¬ or ~): Reverses a boolean value (true becomes false, and vice versa).
2. AND (∧): Both operands must be true for the result to be true.
3. OR (∨): At least one operand must be true for the result to be true.
Operator Precedence:
A boolean function takes boolean inputs and produces a boolean output. Truth tables show all
input/output combinations.
This boolean function describes a multiplexer, a digital component that uses a selector bit (S)
to select one of two outputs (X or Y). If S false, the function output (Z) is the same as X. If
Questions 🙂
1. Describe the following boolean expression: ¬X ∨ Y.
○ This expression means NOT X OR Y. The output is true if either X is false or Y is
true.
2. Describe the following boolean expression: (X ∧ Y).
○ This expression means X AND Y. The output is true only if both X and Y are true.
3. What is the value of the boolean expression (T ∧ F) ∨ T?
○ The value is T. First, (T ∧ F) is F, and then F ∨ T is T.
4. What is the value of the boolean expression ¬(F ∨ T)?
○ The value is F. (F ∨ T) is T, and then NOT T is F.
5. What is the value of the boolean expression ¬F ∨ ¬T?
○ The value is T. ¬F is T and ¬T is F, so T ∨ F is T.
6. Create a truth table to show all possible inputs and outputs for the boolean
function described by ¬(A ∨ B).
7. Create a truth table to show all possible inputs and outputs for the boolean
function described by (¬A ∧ ¬B).
8. If a boolean function has four inputs, how many rows are required for its truth table?
○ A truth table with four inputs will require 16 rows (2^4 = 16).
9. How many selector bits are required for a four-input multiplexer?
○ A four-input multiplexer requires 2 selector bits (since 2^2 = 4).