Advance Computer Architecture Total marks = 20
Deadline
(CS501) 18 November
Assignment # 01 2024
Fall 2024
Please carefully read the following instructions before attempting the assignment.
RULES FOR MARKING
It should be clear that your assignment would not get any credit if:
The assignment is submitted after the due date.
The submitted assignment does not open, or the file is corrupted.
Strict action will be taken if the submitted solution is copied from any other student or the
internet.
You should consult the recommended books to clarify your concepts, as handouts are insufficient.
You are supposed to submit your assignment in Doc or Docx format.
Any other formats like scanned images, PDF, ZIP, RAR, PPT, BMP, etc. will not be accepted.
Topic Covered:
The objective of this assignment is to assess the understanding of students about:
Assembly Langue instructions
Different Operations
Addressing Modes
Topic Covered
Lecture # 1 to Lecture # 6
NOTE
No assignment will be accepted via email after the due date (whether it is due to load shedding, internet
malfunctioning, etc.). Hence, refrain from uploading assignments within the last hour of the deadline. It is
recommended that the solution be uploaded at least two days before its closing date.
If you find any mistakes or confusion in the assignment (Question statement), please consult your instructor
before the deadline. After the deadline, no queries will be entertained in this regard.
For any query, feel free to email me at:
[email protected]Total Marks :
(20)
Question:
Consider an Account accounting application whichwho calculates bonus and fine deductions on the
salary of a customer using an accounting application. The working mechanism of application is;is to
access initial values from memory cells, such that:
The initial account balance, stored at memory address 114, is 3000 (representing $30.00).
A fineThe salary deductions amount, stored at memory address 118, is 1500 (representing $15.00).
You are required to r task is to write an assembly program that can performs the following tasks:
Part Task A
Loads the current account balance into a register.
Adds a bonus of $20.00 (or 2000 cents) to the account balance.
Loads the fine salary deductions amount into another register.
Computes the new balance after doing the deductionsing the penalty.
Part Task B
After deducting the penalty from the new balancebalance, you need to show the working mechanism
(how you perform this operation).
Good Luck!
Below is a simple assembly program for a hypothetical architecture that performs the given tasks. This
program is written generically to explain the logic, so you might need to adapt it for specific
instruction sets (e.g., x86, ARM). Here, we use the following conventions for registers and operations:
R1 – Register to hold the initial account balance.
R2 – Register to hold the bonus amount.
R3 – Register to hold the deductions amount.
R4 – Register to store the new balance after addition and subtraction.
Assembly Program
; Task A: Load initial account balance and apply bonus, then deductions.
; Load the initial account balance from memory address 114
LDR R1, [114] ; Load initial balance (3000 cents or $30.00) into R1
; Load bonus amount of $20.00 (2000 cents) into R2
MOV R2, #2000 ; Load immediate value 2000 into R2 (bonus)
; Add the bonus to the initial balance
ADD R1, R1, R2 ; R1 = R1 + R2 (R1 now holds 5000 cents or $50.00)
; Load the salary deductions amount from memory address 118
LDR R3, [118] ; Load deductions (1500 cents or $15.00) into R3
; Subtract the deductions from the new balance
SUB R4, R1, R3 ; R4 = R1 - R3 (R4 now holds 3500 cents or $35.00)
; Store the final balance back to memory if required (e.g., at address 120)
STR R4, [120] ; Store the new balance at memory address 120
; Task B: Demonstrate the working mechanism of operations.
; Explanation of operations:
; 1. Initial balance in R1 is loaded from memory (3000 cents).
; 2. R2 holds the bonus amount (2000 cents).
; 3. ADD operation is performed: R1 = R1 + R2 → 5000 cents ($50.00).
; 4. R3 holds the deduction amount (1500 cents).
; 5. SUB operation is performed: R4 = R1 - R3 → 3500 cents ($35.00).
; End of program
HALT ; End of execution
Working Mechanism Explained:
[1.] Loading Initial Account Balance: The LDR instruction is used to load the initial account
balance of 3000 cents from memory address 114 into R1.
[2.] Adding Bonus: The MOV instruction loads the immediate value of 2000 cents into R2. The ADD
instruction then adds the bonus amount in R2 to the balance in R1, resulting in a new value of
5000 cents.
[3.] Loading and Applying Deductions: The LDR instruction loads the deductions of 1500 cents
from memory address 118 into R3. The SUB instruction subtracts this amount from the value in
R1, storing the final result in R4.
[4.] Final Balance: The result after adding the bonus and subtracting the deductions is stored in
R4, which holds the final balance of 3500 cents.
Assembly Program
; Task A: Load initial account balance and apply bonus, then deductions.
; Load the initial account balance from memory address 114
LDR R1, [114] ; Load initial balance (3000 cents or $30.00) into R1
; Load bonus amount of $20.00 (2000 cents) into R2
MOV R2, #2000 ; Load immediate value 2000 into R2 (bonus)
; Add the bonus to the initial balance
ADD R1, R1, R2 ; R1 = R1 + R2 (R1 now holds 5000 cents or $50.00)
; Load the salary deductions amount from memory address 118
LDR R3, [118] ; Load deductions (1500 cents or $15.00) into R3
; Subtract the deductions from the new balance
SUB R4, R1, R3 ; R4 = R1 - R3 (R4 now holds 3500 cents or $35.00)
; Store the final balance back to memory if required (e.g., at address 120)
STR R4, [120] ; Store the new balance at memory address 120
; Task B: Demonstrate the working mechanism of operations.
; Explanation of operations:
; 1. Initial balance in R1 is loaded from memory (3000 cents).
; 2. R2 holds the bonus amount (2000 cents).
; 3. ADD operation is performed: R1 = R1 + R2 → 5000 cents ($50.00).
; 4. R3 holds the deduction amount (1500 cents).
; 5. SUB operation is performed: R4 = R1 - R3 → 3500 cents ($35.00).
; End of program
HALT ; End of execution
Working Mechanism Explained:
1. Loading Initial Account Balance: The LDR instruction is used to load the initial account balance
of 3000 cents from memory address 114 into R1.
2. Adding Bonus: The MOV instruction loads the immediate value of 2000 cents into R2. The ADD
instruction then adds the bonus amount in R2 to the balance in R1, resulting in a new value of
5000 cents.
3. Loading and Applying Deductions: The LDR instruction loads the deductions of 1500 cents
from memory address 118 into R3. The SUB instruction subtracts this amount from the value in
R1, storing the final result in R4.
Final Balance: The result after adding the bonus and subtracting the deductions is stored in R4, which
holds the final balance of 3500 cents.