0% found this document useful (0 votes)
17 views4 pages

Mc210401165 Cs501 Assignment 1 Solution

The document contains the solutions to three questions from a computer architecture assignment. Question 1 involves writing an assembly program to evaluate a mathematical expression without changing the source operands. Question 2 asks to convert two hexadecimal machine language instructions to their mnemonic equivalents. Question 3 has two parts: (a) calculates the maximum memory size of a computer with a 32-bit address bus and 16-bit data bus, (b) identifies the instruction type and op-code for four instructions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views4 pages

Mc210401165 Cs501 Assignment 1 Solution

The document contains the solutions to three questions from a computer architecture assignment. Question 1 involves writing an assembly program to evaluate a mathematical expression without changing the source operands. Question 2 asks to convert two hexadecimal machine language instructions to their mnemonic equivalents. Question 3 has two parts: (a) calculates the maximum memory size of a computer with a 32-bit address bus and 16-bit data bus, (b) identifies the instruction type and op-code for four instructions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Student Name:mc210401165

Student Name: Muqaadas Ghafoor


Cs501 Assignment No.1 Solution

Questions No 1:
Write an assembly program to evaluate the expression: Your code should not
change the source
operands.
𝑦 = 3(𝑥 + 4) − 2(𝑧 − 7)
Solution:
section .data
x dd 10 ; Define x as a doubleword (32 bits) with initial value 10
z dd 5 ; Define z as a doubleword (32 bits) with initial value 5
y dd 0 ; Define y as a doubleword (32 bits) with initial value 0

section .text
global _start
_start:
fld dword [x] ; Load x onto the FPU stack
fadd dword [four] ; Add 4 to the value on the FPU stack
fmul dword [three] ; Multiply the result by 3
fstp dword [y] ; Store the result in y

fld dword [z] ; Load z onto the FPU stack


fsub dword [seven] ; Subtract 7 from the value on the FPU stack
fmul dword [two] ; Multiply the result by 2
fsub dword [y] ; Subtract the result from the value in y
fstp dword [y] ; Store the final result in y

; Exit the program


mov eax, 1 ; syscall number for sys_exit
xor ebx, ebx ; Exit with return code 0
int 0x80 ; Perform the system call
section .data
three dd 3.0 ; Define constant 3
two dd 2.0 ; Define constant 2
four dd 4.0 ; Define constant 4
seven dd 7.0 ; Define constant 7
Questions No 2:
For the reverse assemble, convert the following SRC machine language instructions
in Hexadecimal, and mention the mnemonic:
1. 8A000000 h
2. 9C000000 h

Solution:
(1)8A000000h:

Hexadecimal Value: 8A000000h


Mnemonic: MOV AL, [EAX]
(2)9C000000h:

Hexadecimal Value: 9C000000h


Mnemonic: PUSHFD
Questions No 3:
a.) A computer has a 32-bit address bus and a 16-bit data bus. What is the
maximum amount of memory that can be addressed by this computer? How
many bytes of memory can be stored in this computer’s memory?
Solution FOR part (a)
Addressable Memory Space:
The address bus is 32bits, which means it can address 2 power 32
different memory locations. 2^32= 4.294.967.296(memory loaction)
Size of Data busy in bytes:
The data bus is 16bits,which means each memory location can store 16bits of data (2bytes).
To calculate the maximum memory size in bytes,multiply tge addressables memory space by the
size of data:
Maximum Memory Size= (2^32 memory locatons)*(2bytes per memory location)
= (4.264.267.296* 2bytes)

Maximum Memory Size= 8.589.934.592 bytes 4

16 data bits is two bytes per address,so one could argue the “ total size of the memory” is 8 GB.This is
the same as 64 GB ,SINCE 8 ITS Per Byte.

Total memory size= Number of Addressable Locations*Bytes per Location

Substituting in the given values:

Total Memory Size=2^32multiply *2 bytes

=2^33 bytes

Conversion to GB:

Total Memory Size in GB= Total memory size in bytes/2^30

Total Memory Size in GB=2^33/2^30

Total Memory Size in GB=2^3

Total Memory Size in GB=8GB

b.) Identify the instruction type and op-code for the following instructions:

Table Solution for part (b):


Instructions Instruction types Op-code Number of memory
operands
ADD R1, R2, R3 R-Type ADD 0
SUB R4, R1, R5 R-Type SUB 0
LOAD R1, 100 I-Type (Immediate Type) LOAD 1
STORE R2, 200 I-Type STORE 1

You might also like