Mc210401165 Cs501 Assignment 1 Solution
Mc210401165 Cs501 Assignment 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
Solution:
(1)8A000000h:
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.
=2^33 bytes
Conversion to GB:
b.) Identify the instruction type and op-code for the following instructions: