0% found this document useful (0 votes)
19 views

Lab Mannual

Uploaded by

22-22411-071
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

Lab Mannual

Uploaded by

22-22411-071
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 65

FATIMA JINNAH WOMEN UNIVERSITY

LAB MANNUAL

 NAME : SYEDA FARWA BATOOL


 ROLL NO : 2022 - BSE - 071
 SECTION: B
 COURSE : COMPUTER ARCHITECTRE
AND LOGIC DESIGNS
 LAB: 01
 DATE : 12th–10–2023
 AND GATE:

 OR GATE:
 NOT GATE:

NAND GATE:
 XOR GATE:

 NOR GATE:
LAB : 02

WORKING WITH NAND GATE

1) NAND TO NOT GATE

2) NAND TO AND
3) NAND TO OR

WORKING WITH NOR GATE


1) NOR TO NOT GATE
2) NOR TO AND GATE

3) NOR TO OR
LAB : 03

IMPLEMENTATION OF XOR GATE USING NAND


GATE :
1. TRUTH TABLE :

A B X
0 0 0
0 1 1
1 0 1
1 1 0

2. BOOLEAN FUNTION :
3. DIAGRAM :

 CASE: 1

 CASE : 2
 CASE : 3

 CASE : 4
I PLEMENTATIONOFXNORGATEUSING
M
NANDGATE:

1. TRUTH TABLE:

A B X
0 0 1
0 1 0
1 0 0
1 1 1

2. BOOLEAN FUNCTION:
3. DIAGRAM:
 CASE : 1

 CASE : 2
 CASE : 3

CASE :4
LAB : 04

HALFADDER
 TRUTH TABLE AND LOGIC DESIGN:

 DIAGRAM:
FULLADDER
 TRUTH TABLE AND LOGIC DESIGN :

 DIAGRAM :
LAB 05
Questions

Modify the BCD to Decimal decoder circuit provided to give output of all
0’s when any invalid input combination occurs.

TRUTH TABLE:
LAB : 06

MUX:
2*1:

4*1:
ENCODER:

DECODER:
LAB : 08
Question 1: Comment on Architecture of the following
CPUs:

1. PIC18:

 Harvard Architecture: PIC18 utilizes Harvard architecture,


which separates program and data memory spaces, enabling efficient data
fetching and execution.
 RISC-based: Its Reduced Instruction Set Computing (RISC)
architecture simplifies instructions, making them faster and easier to
decode.
 8-bit core: Primarily focused on cost- and power-efficiency for
embedded systems.
 Limited features: Compared to more complex CPUs, PIC18 has
fewer registers and less complex addressing modes.

2. ATMEL:

 Diverse architectures: Atmel offers a broad portfolio of CPU


architectures, including RISC, AVR, and ARM cores, catering to
different performance and power requirements.
 Wide range of applications: Atmel CPUs are popular in various
applications, including IoT, automotive, industrial control, and consumer
electronics.
 Limited support: Compared to mainstream architectures like x86,
Atmel CPUs might have less readily available development tools and
community support.

3. IBM POWER2:

 High-performance RISC architecture: Designed for high-


performance computing applications, Power2 boasts a 64-bit instruction
set and superscalar execution.
 Advanced features: Offers features like speculative execution,
branch prediction, and large on-chip caches for improved performance.
 Server-oriented: Power2 is primarily used in high-end servers and
workstations.
 High cost and power consumption: Not suitable for cost-
sensitive or battery-powered devices.

4. ITANIUM:

 EPIC (Explicitly Parallel Instruction Computing)


architecture: Designed for high performance with a focus on instruction-
level parallelism.
 Complex instruction set: Itanium instructions are longer and more
complex, potentially leading to lower performance than simpler RISC
architectures.
 Limited adoption: Despite its potential, Itanium failed to gain
widespread adoption due to compatibility issues, software limitations, and
high cost.

5. EPIC:

 Concept architecture: EPIC is a concept architecture, not a


specific implementation.
 Focus on parallelism: EPIC aims to exploit instruction-level
parallelism by allowing simultaneous execution of multiple independent
instructions.
 Implementation challenges: Implementing EPIC requires
complex hardware and compiler support, which has hindered its practical
implementation.

6. INTEL I860:

 RISC-based architecture with VLIW (Very Long Instruction


Word): Combines RISC efficiency with VLIW technology for parallel
instruction execution.
 High performance: Achieved impressive performance results for
its time.
 Difficult to program: VLIW architecture requires complex
compiler optimization, making it challenging to write efficient code.
 Commercial failure: Despite its performance, the i860 failed
commercially due to its high cost and programming difficulty.

7. TRANSMETA CRUSOE:

 Code morphing technology: Translated x86 instructions into


simpler RISC instructions for efficient execution on low-power hardware.
 Low power consumption: Achieved significant power savings
compared to traditional x86 designs.
 Limited performance: Code morphing added overhead, resulting
in slightly lower performance than native x86 CPUs.
 Discontinued: Transmeta eventually discontinued the Crusoe
architecture due to competition and market consolidation.

8. STARCORE (LUCENT/MOTOROLLA):

 VLIW architecture with DSP extensions: Designed for high-


performance signal processing applications.
 Scalable architecture: Offers different configurations with
varying performance and power consumption.
 Limited market share: Despite its capabilities, StarCore has not
achieved widespread adoption compared to other DSP architectures.

9. TIGERSHARC (ADI):

 VLIW architecture with specialized DSP instructions:


Optimized for high-performance audio and image processing
applications.
 On-chip memory and peripherals: Integrated memory and
peripherals reduce system complexity and improve performance.
 Limited general-purpose computing: While excelling in DSP
tasks, TigerSHARC might not be ideal for general-purpose computing
applications.

10. INFENON X:

 Mixed VLIW and superscalar architecture: Combines VLIW


for parallel execution with superscalar techniques for improved efficiency.
 High-performance computing: Designed for high-performance
applications like scientific computing and data analytics.
 Complex architecture: Requires specialized compilers and
programming expertise to achieve optimal performance.
 Limited adoption: Similar to other VLIW architectures, Infenon X
has faced challenges gaining widespread adoption

Question 2 : Daily life examples of embedded systems / special


purpose processors around us (At least 30)

Home Appliances:

1. Microwave oven: Controls cooking time and temperature with a


dedicated microcontroller.
2. Coffee machine: Manages brewing cycles and monitors water
levels with an embedded processor.
3. Refrigerator: Maintains temperature and manages defrosting with
embedded control systems.
4. Washing machine: Controls washing cycles and water levels with
a dedicated microprocessor.
5. Television: Decodes video signals and provides user interface
functionality with an embedded SoC (System on Chip).
6. Vacuum cleaner: Controls movement and adjusts suction power
with embedded processors.
7. Air conditioner: Regulates temperature and airflow with
embedded control systems.
8. Security alarm system: Monitors sensors and triggers alarms with
an embedded microprocessor.

Consumer Electronics:

1. Smartphone: Powerful SoC handles various tasks like


communication, multimedia, and gaming.
2. Smartwatch: Tracks fitness data and provides notifications with a
dedicated processor.
3. Wireless earbuds: Manage audio playback and connectivity with
embedded chips.
4. Game console: Dedicated graphics processing unit (GPU) delivers
high-performance graphics.
5. Digital camera: Image processing and camera control handled by
specialized processors.
6. Virtual reality headset: Dedicated processors handle
tracking, display, and audio processing.
7. Digital picture frame: Displays images and manages memory
with a dedicated processor.

Transportation:

1. Car engine control unit: Manages engine performance and fuel


efficiency with a dedicated ECU.
2. Anti-lock braking system (ABS): Regulates brake pressure to
prevent wheel lockup with an embedded processor.
3. Airbag control unit: Deploys airbags in milliseconds based on
sensor data and embedded algorithms.
4. Traffic light controller: Manages traffic flow with embedded
timing circuits and logic.
5. Airplane autopilot: Maintains flight stability and navigation with
advanced avionics systems.

Healthcare:

1. Medical imaging devices: Generate X-rays, MRIs, and other


images with dedicated image processing hardware.
2. Pacemaker: Regulates heart rhythm with a dedicated
microcontroller.
3. Insulin pump: Delivers insulin doses based on blood sugar levels
and embedded algorithms.
4. Diagnostic equipment: Analyzes blood, urine, and other samples
with embedded processors.
Other:

1. ATM machine: Processes financial transactions with a dedicated


computer system.
2. POS terminal: Handles credit card payments with an embedded
processor.
3. Barcode scanner: Reads product codes with a dedicated laser and
decoder.
4. Vending machine: Dispenses products and processes payments
with an embedded system.
5. Automatic doors: Open and close automatically with sensors and
embedded control systems.
6. Smart home devices: Thermostats, lights, and other devices
controlled with embedded processors and network connectivity.

Question 3 : Name and Comment on Architecture of the processor of


your PC and Mobile.
 LAPTOP:
Processor: Intel Core i5 G5 (5th generation)

Architecture: Skylake

Comments:

 14nm process technology, offering increased performance and


efficiency compared to previous generations.
 4 cores, 4 threads, enabling good multitasking performance for
everyday tasks.
 Up to 3.4 GHz clock speed, providing sufficient power for most
applications.
 Integrated Intel HD Graphics 530, suitable for basic graphics tasks
and multimedia playback.
 PHONE :
Processor: Exynos 7870 Architecture:

ARM Cortex-A53 Comments:

 14nm process technology, similar to the laptop processor for


improved efficiency.
 8 cores, 8 threads, offering good multithreading capabilities for
smooth performance.
 Up to 1.6 GHz clock speed, sufficient for everyday phone usage
but may struggle with demanding tasks.
 Integrated Mali-T830 MP2 GPU, suitable for basic graphics and
gaming but not high-end applications.
LAB 08:
TASKS
Assemble and trace following programs using DEBUG. For each program,
write down the contents of only those registers and flag bits which have
been modified by the given program
Program 1: [AX=0020, BX=00AA]
mov ah, bl
Program 2: [AX=06AF]
mov ah,3
Program 3: [Assume registers and flag bits are set to default values]
mov ah,7F
mov ax,1234
mov bh, al
mov bl, ah
Program 4: [Assume registers and flag bits are set to default values]
mov al,81
add al,FE
Program 5: [Assume registers and flag bits are set to default values]
mov ax, 5510
sub al,2
Program 6: [Assume registers and flag bits are set to default values]
mov al, 3e
add al, 3e
Program 7: [Assume registers and flag bits are set to default values]
mov ah,2
mov dl,41
Program 8: [Assume registers and flag bits are set to default values]
mov ax, 5
mov bx,10
add ax,bx
Program 9: [Assume registers and flag bits are set to default values]
mov al,FFFE
sub al,2
mov bl,8c
mov bh,2D
add bx,ax
Program 10: [Assume registers and flag bits are set to default values]
mov ax, 1234
mov bx,ax
mov cx,ax
add ch, al
add bl, ah
add ax, FFFF
dec bx
LAB: 09
Exercise 9.1
Write a program that input a character from user is in lowercase, the program
will convert it to uppercase and will display it on console after conversion . (Hint:
- The ASCII codes for lowercase letters (a-z) are 97-122. In order to convert a
lowercase letter to uppercase letter, just subtract 32 from its ASCII code.)

CODE:
CONSOLE:

Exercise 9.2
Write a program that input a character from user. The program will display it
ten times on screen in newline.

CODE:
CONSOLE:
LAB: 10

Activity #3.1

Activity #3.2
Activity #3.3:
Activity 3.3: Addition of two single digits numbers
.model small

.stack 100h

.data

Num1 db 0

Num2 db 0
msgNum1 db "Enter the 1st No: $"

msgNum2 db 10,13,"Enter the 2nd No: $"

msgAns db 10,13,"The answer is: $"

.code

main proc

mov ax, @data

mov ds, ax ; Initialize data segment once

; Input for Num1

mov dx, offset msgNum1

mov ah, 09h

int 21h

mov ah, 1

int 21h

sub al, 30h

mov Num1, al

; Input for Num2

mov dx, offset msgNum2

mov ah, 09h

int 21h

mov ah, 1

int 21h

sub al, 30h


mov Num2, al

; Addition

mov bh, Num1

add bh, Num2

; Check for overflow (optional)

cmp bh, 9

ja overflow ; Jump to overflow handler if needed

; Print the result

add bh, 30h

mov dx, offset msgAns

mov ah, 09h

int 21h

mov dl, bh

mov ah, 2

int 21h

; Exit

mov ah, 4ch

int 21h

overflow: ; Overflow handling (if implemented)

; ...
main endp

end main
Activity #3.4

include emu8086.inc ;include library

.data

num1 dw 0

num2 dw 0

; get the multi-digit signed number from the keyboard, and store the

; result in cx register:

call scan_num ; Get first number

mov num1, cx ; store first number:

call scan_num ; Get second number

mov num2, cx ; store second number:

mov ax, num1 ; Can not add two memory variables

add ax, num2 ; add num2 in ax and store result in ax

call print_num ; print ax value.

DEFINE_PRINT_NUM ; used by print_num proc

DEFINE_PRINT_NUM_UNS ; used by print_num proc

DEFINE_SCAN_NUM ; used by scan_num proc

END
Exercise #3.1:
include emu8086.inc

.data

num1 dw 0

num2 dw 0

.code

main proc

; Get first number:

GOTOXY 0, 0 ; Move cursor to top-left corner

PRINT "Enter first number: "

call scan_num

mov num1, cx
; Get second number:

GOTOXY 0, 1 ; Move cursor to second line

PRINT "Enter second number: "

call scan_num

mov num2, cx

; Add the numbers:

mov ax, num1

add ax, num2

; Print the formatted output:

GOTOXY 0, 2 ; Move cursor to third line

PRINT "The sum of two numbers is: "

call print_num

main endp

DEFINE_PRINT_NUM

DEFINE_PRINT_NUM_UNS

DEFINE_SCAN_NUM

END main
Exercise#3.2

Exercise 3.2:

Write a program that reads five unsigned integers from user and display sum of those

five integers on the screen.

Code:

include emu8086.inc ;include library

.data

num1 dw 0 ; Define variables for each number

num2 dw 0

num3 dw 0

num4 dw 0

num5 dw 0

sum dw 0 ; Variable to store the sum

msgFirst db "Enter first number: $"

msgSecond db 10, 13, "Enter second number: $"

msgThird db 10, 13, "Enter third number: $"


msgFourth db 10, 13, "Enter fourth number: $"

msgFifth db 10, 13, "Enter fifth number: $"

msgResult db 10, 13, "The sum of five numbers is: $"

.code

main:

mov ax, @data

mov ds, ax

; Input for the first number

mov dx, offset msgFirst

mov ah, 09h

int 21h

call scan_num ; Get first number

mov num1, cx ; Store first number

; Input for the second number

mov dx, offset msgSecond

mov ah, 09h

int 21h

call scan_num ; Get second number

mov num2, cx ; Store second number


; Input for the third number

mov dx, offset msgThird

mov ah, 09h

int 21h

call scan_num ; Get third number

mov num3, cx ; Store third number

; Input for the fourth number

mov dx, offset msgFourth

mov ah, 09h

int 21h

call scan_num ; Get fourth number

mov num4, cx ; Store fourth number

; Input for the fifth number

mov dx, offset msgFifth

mov ah, 09h

int 21h

call scan_num ; Get fifth number

mov num5, cx ; Store fifth number

; Calculate the sum


mov ax, num1 ; Move the first number to ax

add ax, num2 ; Add the second number

add ax, num3 ; Add the third number

add ax, num4 ; Add the fourth number

add ax, num5 ; Add the fifth number

mov sum, ax ; Store the final sum

; Display the sum

mov dx, offset msgResult

mov ah, 09h

int 21h

mov ax, sum ; Move the sum to ax for printing

call print_num ; Print the sum

mov ax, 4C00h ; Exit to DOS

int 21h

DEFINE_PRINT_NUM ; used by print_num proc

DEFINE_PRINT_NUM_UNS ; used by print_num proc

DEFINE_SCAN_NUM ; used by scan_num proc

END main

Output:
Exercise 3.3:
Write a program using instruction shown in table and fill in the table with the offsets

of the instructions in the code segment.

Code:

.data

number dw 100

sum dw 0
.code

main PROC

mov ax, number

add ax, 158

mov sum, ax

mov ax, 0

mov ah, 4Ch ; exit to DOS

int 21h

main ENDP

END main ; end of program

Output:

Instruction Segment and Offset

mov ax, number 0000

add ax, 158 0003

mov sum, ax 0006

mov ax, 0 0009


Lab : 11
EXERCISE 4.1
INSTRUCTION 1:

INSTRUCTION 3:
EXERCISE 4.2:
Calculate the range of signed and unsigned numbers that db, dw, dd, dq and dt
directives can specify. Mention the adopted method i.e how you will calculate therange.
EXERCISE 4.3:
byte1 db 10110111b : 183
byte2 db 35q :29
byte3 db 0E8h :232
byte4 db 150 : 150
byte5 db -91 : 165
byte6 db ‘K’ : 75
byte7 db ‘k’ :107
byte8 db “Ali’s book” : 065
byte9 db 5 DUP("< >") : 060
byte10 dw 1000000 : overflow error
Byte11 dw "Maria Sultan": 4D077- 90144

byte12 dw “1010b”: 31049-62098


byte13 dw “BSE 5A&B”:42066-42066
byte14 dw “Computer Architecture”:43067-45101
byte15 dw 6 DUP (“<:p>”):06006

Exercise 4.4
Define 5 different 8-bit Numbers. Write a programme to do the
following : Use the DB directive to define the following list of numbers and
name it myarray.
• 36h, 37h, 39h, 40h
• Display the array in reverse order.
OPEN ENDED LAB
Exercise 5.1
Write a program to use the SCAN_NUM to input prompt for values for three
variables x, y and z and the PRINT_NUM to display an appropriate label and
value of the expression x – y + 2z – 1.
CODE:
include emu8086.inc ;include library
.data
x dw 0 ; Define variable for x
y dw 0 ; Define variable for y
z dw 0 ; Define variable for z
result dw 0 ; Variable to store the result
msgX db "Enter value for x: $"
msgY db 10, 13, "Enter value for y: $"
msgZ db 10, 13, "Enter value for z: $"
msgResult db 10, 13, "Result (x-y + 2z- 1): $"
.code
main:
mov ax, @data
mov ds, ax
; Input for x
mov dx, offset msgX
mov ah, 09h
int 21h
call scan_num ; Get value for x
mov x, cx ; Store value for x
; Input for y
mov dx, offset msgY
mov ah, 09h
int 21h
call scan_num ; Get value for y
mov y, cx ; Store value for y
; Input for z
mov dx, offset msgZ
mov ah, 09h
int 21h
call scan_num ; Get value for z
mov z, cx ; Store value for z
; Calculate the result
mov ax, x ; Move the value of x to ax
sub ax, y ; Subtract the value of y
shl z, 1 ; Multiply the value of z by 2
add ax, z ; Add the doubled value of z
sub ax, 1 ; Subtract 1
mov result, ax ; Store the final result
; Display the result
mov dx, offset msgResult
mov ah, 09h
int 21h
mov ax, result ; Move the result to ax for printing
call print_num ; Print the result
mov ax, 4C00h ; Exit to DOS
int 21h
DEFINE_PRINT_NUM ; used by print_num proc
DEFINE_PRINT_NUM_UNS ; used by print_num proc
DEFINE_SCAN_NUM ; used by scan_num proc
END main
OUTPUT:

Exercise 5.2
Write an assembly language program that prompts for and inputs the length,
width, and height of a box and calculates and displays its surface area surface
area = 2 * (length * width + length * height + width * height)
CODE:
include emu8086.inc ;include library
.data
length dw 0 ; Define variable for length
width dw 0 ; Define variable for width
height dw 0 ; Define variable for height
surface_area dw 0 ; Variable to store the surface area
msgLength db "Enter Length: $"
msgWidth db 10, 13, "Enter Width: $"
msgHeight db 10, 13, "Enter Height: $"
msgResult db 10, 13, "Surface Area: $"
.code
main:
mov ax, @data
mov ds, ax
; Input for length
mov dx, offset msgLength
mov ah, 09h
int 21h
call scan_num ; Get length
mov length, cx ; Store length
; Input for width
mov dx, offset msgWidth
mov ah, 09h
int 21h
call scan_num ; Get width
mov width, cx ; Store width
; Input for height
mov dx, offset msgHeight
mov ah, 09h
int 21h
call scan_num ; Get height
mov height, cx ; Store height
; Calculate surface area
mov ax, length
imul width ; Multiply length by width and store the result in ax
mov bx, length
imul height ; Multiply length by height and store the result in bx
mov cx, width
imul height ; Multiply width by height and store the result in cx
shl ax, 2 ; 2 * (length * width)
add ax, bx ; 2 * (length * width + length * height)
add ax, cx ; 2 * (length * width + length * height + width * height)
mov surface_area, ax ; Store the surface area
; Display the result
mov dx, offset msgResult
mov ah, 09h
int 21h
mov ax, surface_area ; Move the surface area to ax for printing
call print_num ; Print the surface area
mov ax, 4C00h ; Exit to DOS
int 21h
DEFINE_PRINT_NUM ; used by print_num proc
DEFINE_PRINT_NUM_UNS ; used by print_num proc
DEFINE_SCAN_NUM ; used by scan_num proc
END main
OUTPUT:

You might also like