
Write a program that asks the user to enter an alphabetic character (either lower or upper case) and change the case of the character from lower to upper and from upper to lower and display it.
Write a program that asks the user to enter an unsigned number and read it. Then swap the bits
at odd positions with those at even positions and display the resulting number. For example, if the
user enters the number 9, which has a binary representation of 1001, then bit 0 is swapped with
bit 1, and bit 2 is swapped with bit 3, resulting in the binary number 0110. Thus, the program
should display 6.
Write a program that asks the user to enter and integer number and read it. Then ask him to
enter a bit position (between 0 and 31) and display the value of that bit.
This presentation provides an in-depth look at the fundamental nature of machine instructions, which are the binary commands that dictate every operation a processor performs. By exploring the processor’s instruction set, the video illustrates how these commands serve as the primary means for a programmer to control the computer's hardware.
The overview covers several key areas:
• Elements of an Instruction: You will learn about the four essential components of any machine instruction: the operation code (opcode), which specifies the task; source operand references (inputs); result operand references (outputs); and the next instruction reference, which tells the processor where to go next.
• The Instruction Cycle: The video breaks down the steps the processor takes to execute these commands, including instruction fetching, decoding, and operand address calculation.
• Instruction Formats and Addressing: We examine how instructions are represented as a sequence of bits divided into specific fields. The discussion includes the design trade-offs between three, two, one, and zero-address architectures, highlighting how the number of addresses affects processor complexity and program length.
• Instruction Types: The sources categorize instructions into four functional groups: data processing (arithmetic and logic), data storage (memory movement), data movement (I/O), and control (test and branch).
• Types of Operands: Finally, the overview describes the various forms of data that instructions manipulate, such as addresses, numbers (including packed decimal), characters (ASCII and EBCDIC), and logical data.
Whether represented as binary bits for the computer or as symbolic mnemonics (like ADD or LOAD) for the programmer, machine instructions are the core language of computing.
Analogy: Think of a machine instruction as a recipe card for a chef: the opcode is the action (like "bake" or "chop"), the operands are the ingredients found in specific cupboards (registers or memory), and the instruction format is the layout of the card that ensures the chef can quickly find the information needed to move on to the next dish.
Explore the fascinating evolution and technical contrasts of the Intel 8086, one of the oldest and most prevalent processor architectures in computing history. This video provides a comprehensive comparison between the Complex Instruction Set Computer (CISC) philosophy embodied by the 8086 and the Reduced Instruction Set Computer (RISC) approach found in the MIPS architecture.
What you will learn in this video:
• Registers & Architecture: We compare the 32 uniform 32-bit registers of MIPS against the 8086’s limited set of general-purpose and specialized registers, such as EAX, EBX, ESP, and EIP. Having fewer general-purpose registers in the 8086 often necessitates more frequent and slower memory accesses.
• Instruction Set Philosophies: Understand the difference between the MIPS three-address, register-to-register model and the 8086 two-address, register-to-memory model. While 8086 supports complex addressing modes like scaled indexing to simplify array access, its instruction formats vary wildly from 1 to 17 bytes, making hardware decoding significantly more complex than the uniform 32-bit instructions of MIPS.
• Memory Management: Dive into the 8086’s unique segmented memory model, where 20-bit addresses are generated using segment and offset registers like CS:IP. We also examine why the 8086 lacks the data alignment restrictions found in MIPS, which allows for flexibility but can impact performance.
• Control Flow & Function Calls: Compare how these two giants handle branching and subroutines. While MIPS uses explicit register-based return addresses, the 8086 relies on the stack via CALL and RET instructions and uses the EFLAGS register to manage conditional jumps based on status bits like Zero (Z) and Carry (C).
• The Legacy of the x86: Trace the timeline from the original 16-bit 8086 in 1978 to the Pentium 4, which achieves high clock rates by translating complex instructions into a RISC-like core for deeper pipelining.
Whether you are interested in the hardware trade-offs of the 1980s or how modern Intel CPUs maintain backward compatibility while adopting RISC-based ideas, this comparison offers a deep look into the "headaches" and triumphs of processor design.
Analogy for Understanding: Think of the MIPS architecture like a professional kitchen where every tool is a specialized, single-purpose knife that is easy to keep sharp and fast to use, but requires many steps to prepare a meal. In contrast, the Intel 8086 is like a Swiss Army knife: it has many different, complex attachments that can do several tasks at once, which saves space in your pocket (memory) but makes the tool itself much more complicated to handle and maintain.
0:00 – Introduction: The Role of Instruction Sets The video opens by defining the instruction set as the essential "toolset" that allows a compiler to translate high-level code into machine-level instructions optimized for a specific processor.
0:45 – Data Foundations and Endianness
• x86 Types: We cover the general data types (8 to 128 bits) and the x86 little-endian storage style.
• ARM Types: Contrast this with ARM’s support for 8, 16, and 32-bit lengths. We highlight the E-bit (SETEND instruction), which allows ARM processors to dynamically switch between big and little-endian formats to match the OS environment.
1:50 – The Seven Universal Instruction Categories We briefly categorize the operations found on almost all machines: Data Transfer, Arithmetic, Logical, Conversion, I/O, System Control, and Transfer of Control. Data Transfer is highlighted as the most fundamental, requiring the specification of operand locations, data length, and addressing modes.
2:45 – Logical Operations and "Bit Twiddling" Learn how processors manipulate individual bits using AND, OR, and XOR. We show a quick example of using logical shifts and masks to "unpack" characters from a 16-bit word for transmission.
3:50 – Control Flow: Branches and Skips Understand how the processor updates the program counter to handle loops and decision-making. We distinguish between unconditional jumps and conditional branches based on status flags like Zero, Sign, and Overflow. We also introduce the skip instruction (like the ISZ), which performs an action and skips the next instruction if a condition is met.
5:00 – Procedures and the Stack Frame A look at the procedure, a self-contained program that can be "called" and "returned" from. We visualize the stack frame, which stores the return point, old frame pointer, and local variables. This section explains how x86 uses ENTER and LEAVE instructions to manage these frames in a single step.
6:30 – MMX and SIMD Performance Discover how Single-Instruction-Multiple-Data (SIMD) allows a processor to perform one operation on multiple data elements simultaneously. Using MMX technology, we show how image processing instructions can be reduced from 1.4 billion to just 535 million.
7:30 – ARM’s Conditional Execution The video concludes with ARM’s unique 4-bit condition field, which allows virtually every instruction to be executed conditionally. This RISC-based design results in shorter programs and more efficient memory use.
Ask the user to enter an integer value, and then print the result of doubling that number. Use the ADD instruction.
Modify again the program shown in Figure 2.4. Ask the user whether he wants to repeat the program. Use service code 12 to read a character and the branch instruction to repeat the main function if the user input is character 'y'.
Write a MIPS program that asks the user to input his name and then prints Hello, followed by the name entered by the user.
Write an MIPS program that executes the statement: s = (a + b) (c + 101), where a, b, and c are user-provided integer inputs, and s is computed and printed as an output.
Write an MIPS program that inputs two integer values. The program should output if the two integers are equal. Otherwise, it should output. Use the branch instruction to check for equality.
Write a program that asks the user to enter an alphabetic character (either lower or upper case) and change the case of the character from lower to upper and from upper to lower and display it.
Write a program asking the user to enter and read an integer number. Then ask him to enter a bit position (between 0 and 31) and display the value of that bit.
Write a program that asks the user to enter an unsigned number and read it. Then swap the bits at odd positions with those at even positions and display the resulting number. For example, if the user enters the number 9, which has a binary representation of 1001, then bit 0 is swapped with bit 1, and bit 2 is swapped with bit 3, resulting in the binary number 0110. Thus, the program should display 6.
Write a program that asks the user to enter an integer and then displays the number of 1s in the
binary representation of that integer. For example, if the user enters 9, the program should
display 2.
Write a program that asks the user to enter two integers: n1 and n2, and prints the sum of all
numbers from n1 to n2 . For example, if the user enters n1=3 and n2 =7, then the program
should display the sum as 25.
Write a program that asks the user to enter an integer and then display the hexadecimal
representation of that integer.
This lecture details the architecture and management of a five-stage CPU pipeline, which functions like an efficient assembly line to process multiple instructions simultaneously. While the datapath provides the physical framework for movement, the Control Unit acts as a conductor by generating specific electronic signals that dictate how hardware components behave for different tasks. These command signals are pipelined alongside data, ensuring that each instruction receives the correct instructions for math, memory access, or writing results at the precise clock cycle. By synchronizing these operations, the processor achieves peak throughput, allowing various hardware units to work in parallel without conflict. This sophisticated orchestration transforms basic hardware into an intelligent machine capable of high-speed modern computation.
This lecture gives a comprehensive overview of processor pipelining, explaining how this technique uses the concept of an assembly line to significantly increase CPU performance. The materials first illustrate the inefficiency of processing instructions one at a time, where the overall time is dictated by the critical path or slowest step. By breaking instruction execution into multiple stages (like Fetch, Decode, Execute, Memory, and Write Back) and overlapping them, pipelining drastically improves throughput, though it does not reduce the latency of a single instruction. The sources further discuss how specialized hardware like pipeline registers enables this parallel execution and note that historical attempts to use overly deep pipelines, such as in the Pentium 4, demonstrated a trade-off where higher clock speeds increased the penalty for pipeline stalls. Ultimately, modern processor design aims for an optimal balance between clock speed and factors like Cycles Per Instruction (CPI) to maximize performance.
Modern processors face a significant bottleneck because approximately one-fifth of all instructions are branches, which can disrupt the smooth flow of data. To combat this, hardware utilizes branch prediction to guess the outcome of these decisions, preventing the massive performance losses that occur when a CPU must discard incorrectly processed work. The technology has evolved from simple static rules and basic one-bit sensors to sophisticated two-bit predictors that use "hysteresis" to avoid frequent errors. Advanced systems now even analyze global history to identify complex patterns and correlations across different parts of the code. By increasing the accuracy of these guesses, a processor can effectively double its performance and maximize the number of instructions it handles simultaneously. Ultimately, these integrated intelligence systems are the hidden engines that enable the high speeds of contemporary computing.
This lecture examines the complex world of CPU pipelining, a process that enhances speed by treating instruction execution like an assembly line. While this method aims for maximum efficiency, it is frequently interrupted by pipeline hazards, which are categorized into structural, data, and control conflicts. To address these issues, the text highlights hardware solutions like forwarding and dedicated memory ports, as well as software strategies such as compiler instruction scheduling. Furthermore, it explains how branch prediction and delayed branching help the processor manage uncertainty regarding future commands. Ultimately, the sources illustrate that modern computing power relies on the sophisticated coordination between hardware design and intelligent software to keep the processing flow steady and fast.
Welcome to the Computer Architectures and MIPS Assembly Programming Course!
***NEW*** Enrol in one course and receive a 100% discount coupon for any of my other courses.
After you sign up, please send me a message to let me know which course you’d like to take.
*Update- December 2025 - Tens of new lecture videos, slides, and resources are uploaded.
This course is a complete, hands-on journey into Computer Architecture and Organization, designed to take you from zero exposure to confidently understanding how modern computers really work—from the lowest-level instructions all the way up to advanced CPU design concepts.
You will start by learning MIPS assembly programming step by step, using clear explanations and dozens of carefully chosen examples. Even if you have never written assembly code before, you will quickly feel comfortable reading, writing, and debugging MIPS programs. The course emphasizes practical understanding: loops, conditionals, arrays, bitwise operations, system calls, and real problem-solving—not just theory.
As you progress, you will go deeper into functions, stack management, recursion, and calling conventions, gaining the skills needed to translate high-level language logic into low-level assembly code. Every major concept is reinforced with multiple examples, assignments, and full solution videos, so you always know not only what works, but why it works.
Beyond programming, the course carefully bridges software and hardware. You will learn how MIPS instructions are encoded, how addressing modes work, and how instructions flow through the processor. Step by step, you will build a strong intuition for datapaths, ALU design, register files, and control units. Single-cycle and multi-cycle processor designs are explained visually and logically, making complex hardware concepts approachable and memorable.
The course then expands into essential modern architecture topics such as pipelining, hazards, branch prediction, parallelism, memory hierarchy, caches, virtual memory, and I/O systems. These sections connect textbook theory to real CPU behavior, helping you understand performance, scalability, and design trade-offs used in real-world processors.
This course is ideal for:
Computer engineering, electrical engineering, and computer science students
Learners preparing for advanced architecture, operating systems, or embedded systems courses
Anyone who wants a deep, practical understanding of how software runs on hardware
By the end of this course, you will not only write MIPS programs with confidence, but also clearly understand how instructions move through a CPU, how memory systems are designed, and how performance is optimized in modern computers. If you have ever wanted to truly understand what happens “under the hood” of a computer, this course is your complete roadmap.
The emphasis of the course is on understanding how computers work. This will provide a basis for further study of computer architecture and computer software. The MIPS processor, the subject of this course, has a well designed architecture and is particularly fruitful to study. However, the goal of the course is not to turn you into a MIPS programmer, but to give you an understanding of all computer systems.
Course Outline
1. Introduction to MIPS Assembly Programming
Memory Operand: Load Word & Store Word in MIPS Assembly Language
Immediate Addressing Mode & Signed/ Unsigned data in MIPS Assembly Language
ADD, ADDI, ADDU, ADDIU, SUB, LW, and SW Instructions in MIPS
Branches and Jump Instruction in MIPS Assembly Language + how to read array[i]
Loop Structure in MIPS Assembly Language
The Other Comparison Instruction + Logical Instructions in MIPS
MIPS Alignment Restrictions: .align, .byte .half and .word Assembler's directive
How Data will be Stored in Memory in the MIPS Architecture?
MIPS System Call
Simple I/O and MIPS System Calls: Hello World!
Simple I/O and MIPS System Calls: Read 2 Numbers and Display their Summation
Simple I/O and MIPS System Calls: an Example of IF-ELSE Structure in MIPS
Simple I/O and MIPS System Calls: an Example of IF-ELSE-IF Structure in MIPS
MIPS Divide Instruction + Determine whether the input number is odd or even
MIPS Example: Read 5 Numbers and Print Their Average
MIPS Multiplication Instruction
MIPS Example: Display the Multiplication of 2 numbers + Factorial Example
MIPS Example: Add Two Integer Numbers
2. Learn MIPS Programming with Examples
MIPS Example: Read a char and determine whether it is an uppercase, lowercase or etc. in MIPS
MIPS Example: Determine the number of zeros in the binary notation of a number
MIPS Example: Read two numbers A and B and compute and print (A+2*B)/5
MIPS Example: Convert C code to MIPS Assembly
MIPS Examples: Learn How to Divide and Multiplication
MIPS Example: Find the Maximum Element of an Array in MIPS Assembly Language
MIPS Example: Find Both Maximum and Minimum of an Input Integer Array
MIPS Example: Nested IF-ELSE IF Structure
MIPS Example: Convert a capital letter to lowercase and vice versa
MIPS Example: Check the input character and determine is it alphabet, digit or .
MIPS Example: Read 2 operands and an operator and print the result
MIPS Example: Compute the sum of N integers: (1 + 2 + ... + N), While Structure
3.Functions in MIPS Assembly Language with Several Examples
Functions in MIPS - Jump and Link (jal) & jump Register(jr) Instructions
Functions in MIPS - How to Pass Arguments to the Functions?
Functions in MIPS - Who saves the register? Spilling Registers
Functions in MIPS - MIPS's conventions to split register spilling chores
Functions in MIPS - MIPS Stack and Push and Pop Implementations
Functions in MIPS - Factorial Function
MIPS Example: Write a function to read N numbers and store them in an array
MIPS Example: Write a function to reverse an input array
MIPS Example: Write a function to count the number of divisors of an argument
4.MIPS Instruction Encoding
MIPS Instruction Encoding: R-Type Instructions
MIPS Instruction Encoding: I-Type Instructions
MIPS Instruction Encoding : J-Type Instruction
5. Computer Architecture: Processor Datapath, ALU and Register File Design
Generic Datapath and Register Files Part 1
Generic Datapath and Register Files Part 2
ALU Design Part 1
ALU Design Part 2
6. Single-Cycle Datapath for MIPS Architecture
MIPS Datapath Overview
Datapath for Fetching an Instruction and increment PC in MIPS Architecture
Datapath for R-type Instruction in MIPS Architecture
MIPS Datapath for Load Word (LW) and Store Word (SW) Instructions
Datapath for Branch Instructions in MIPS Architecture
Combining the Datapaths of R-type Instructions and LW/SW Instructions
Integrating the datapaths of R-Type, Memory and Branch Instructions in MIPS Arc
R-Type + Memory Instructions Data Path
Control Unit for the Single-cycle MIPS Processor
ALU Control Unit Design for MIPS Architecture
7. Multi-Cycle Datapath for MIPS Architecture
Multi-Cycle Datapath for MIPS Architecture Part 1
Multi-Cycle Datapath for MIPS Architecture Part 2
Multi-Cycle Datapath for MIPS Architecture Part 3
Multi-Cycle Datapath for MIPS Architecture Part 4
8. Tutorials + Assignments
Tutorial + Assignment: Introduction to MARS
Tutorial + Assignment: Introduction to MIPS Assembly Programming
Tutorial + Assignment: Integer Arithmetic
Tutorial + Assignment: Flow Control
Tutorial + Assignment: Arrays and Files
Tutorial + Assignment: Integer Multiplication and Division
Tutorial + Assignment: MIPS Functions and the Stack Segment
Fibonacci sequence
Compute the summation of even numbers between 2 input numbers
Simple I/O in MIPS Assembly Language
IF-ELSE-IF Structure in MIPS Assembly Language
Single-Cycle Datapath Quiz with Video Solution
Multi-cycle Datapth
The course is Example-based. Almost every lecture and component of the course directly leads to a hands-on laboratory assignment with a solution. The more you practice with MIPS hardware and software, the more proficient you will become.
I use lots and lots of examples. I take you step-by-step through the lessons – each time providing sample code and documentation to make sure you are supported through the course.
The course does not waste your time. From the very beginning, we jump right into your first project – Let's Get Started.
I am here to help. I am an educator with a singular focus on providing a meaningful experience for my students. And, while I cannot do the work for you, I am willing to work WITH you to help you succeed.
The goal of this course is to shed light on the obscure interface layer between hardware and software. In this context, we will go over instruction set architectures, assembly programming, computer/memory organization, machine language conversion, data bus, and sub-routines, which are all important topics in computer architecture. This course teaches students about the core hardware components of a computer and how they interact with one another. It educates students about the computer's many layers, such as the application level, operating system level, assembly language level, and machine language level.
Computer architectures, which I recommend to anyone working on electronic system design or computer programming and who is interested in processor design, have opened many doors for me in my own career. I hope you find this tutorial useful as well.