Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Assembly Language Create the two programs described below. 1 . reorder.asm - rea

ID: 3668795 • Letter: A

Question

Assembly Language

Create the two programs described below.

1. reorder.asm - rearranges the values of the following array into this order: 43, 2, 21. Use only MOV and XCHG to accomplish the desired result. DO NOT use any immediate values. Use only direct offset addressing to accomplish the goal. Be as efficient as you can. arrayD DWORD 2,21,43

2. fibonacci.asm
- computes the following.

a. Compute fib(n) for n = 2, 3, …, 6 using an array.

b. Store each computed value in an array of the appropriate size and type.

c. Store fib(3) through fib(6) in consecutive bytes of the ebx register starting from the lowest byte; that is, fib(3) is stored in the low byte (bl) of ebx, fib(4) is stored in the next byte (bh), fib(5) is stored in the next byte of ebx and fib(6) is stored in the highest byte.

d. If you don’t know what the Fibonacci sequence is, there is a lot of information online that you can find.

Please answer the questions step by step. Thank you.

Explanation / Answer

1a)

data segment
org 2000h
series db 43h,2h,21h
count dw 3d
data ends
code segment
start:mov ax,data
mov ds,ax
mov dx,count
dec dx
go:mov cx,dx
lea si,series
nxt_byte:mov al,[si]
cmp al,[si+1]
jb next
xchg al,[si+1]
xchg al,[si]
next:inc si
loop nxt_byte
dec dx
jnz go
mov ah,4ch
int 21h
code ends
end start

2a)

Memory Address

Op-code

Operand

Comments

2000

MVI

D,05 H

Initialize counter

2002

MVI

B,00 H

Register for store previous number

2004

MVI

C,01 H

Store current number

2006

MOV

A,B

Store Previous number in A

2007

ADD

C

Add previous number and Current

2008

MOV

B,C

Current number is now previous no.

2009

MOV

C,A

Save result as new current no.

200A

DCR

D

Decrement counter

200B

JNZ

2006

If count is not zero then jump to 2006

200E

END

End the program

Memory Address

Op-code

Operand

Comments

2000

MVI

D,05 H

Initialize counter

2002

MVI

B,00 H

Register for store previous number

2004

MVI

C,01 H

Store current number

2006

MOV

A,B

Store Previous number in A

2007

ADD

C

Add previous number and Current

2008

MOV

B,C

Current number is now previous no.

2009

MOV

C,A

Save result as new current no.

200A

DCR

D

Decrement counter

200B

JNZ

2006

If count is not zero then jump to 2006

200E

END

End the program

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote