How to Write the SRC Assembly language program to evaluate the Equation with appropriate directives.

Vu Old Solved Programming Based Assignments Codes are Available in this Section.
Post Reply
User avatar
ALI RAZA
★★★★★★★★★★★★★
★★★★★★★★★★★★★
Posts: 177
Joined: Fri Dec 22, 2017 8:10 am
Location: Lahore
Has thanked: 6 times
Been thanked: 7 times
Contact:
Status: Offline

How to Write the SRC Assembly language program to evaluate the Equation with appropriate directives.

Post by ALI RAZA » Wed Oct 03, 2018 7:37 am

Write the SRC Assembly language program to evaluate the Equation with appropriate directives.
Z =16(a-18)+25(b+c)

Answer:

Code: Select all

Source program with Assembler directives
		   .ORG		200		; start the next line at address 200
a:                             .DW     	1      		; reserve one word for the label a in the memory
b:                             .DW     	1      		; reserve a word for b, this will be at address 204
c:                             .DW     	1      		; reserve a word for c, will be at address 208

                               .ORG   		400		; start the code at address 400
                                                           		 ; All numbers are in decimal unless otherwise stated
ld R1, c						; c is a label used for a memory location
ld R2, b						; b is a label used for a memory location
add R3, R2, R1					; R3 contains (b+c)
mul R4, R3, 25					; R4 contains 25(b+c)
ld R5, a						; a is a label used for a memory location
addi  R6, R5, -18				;R6 contains (a-18)
mul R7, R6, 16					; R7 contains 16(a-d)
add R8, R7, R4					; R8 contains result
st R8, z						; store the result in memory location z



Post Reply

Last 10 Members Who Visited This Topic

User avatar Rauf ahmad (1), User avatar ALI RAZA (1)

  • Similar Topics
    Replies
    Views
    Last post

Who is online

Users browsing this forum: No registered users and 1 guest