Provide Again, It Seems Like There Is Error
Provide Again, It Seems Like There Is Error
○ Control Hazards: Occur due to branch instructions. The next instruction's address
may not be known until the branch is executed.
■ Example:
JNZ target ; If not zero, jump
; Instructions here might be wrong
target:
; Correct instructions
Question 6: Write an 8086 program to load a value from memory location 2000h into AX
and display.
● Include the 8086 assembly code.
● Provide screenshots of the Emu8086 output showing the value in AX.
ORG 100h
MOV AX, 2000h ; Load segment address into AX
MOV DS, AX ; Set Data Segment register
MOV AX, [0] ; Load word from DS:0000 into AX (2000:0000)
; Code to display AX (using Emu8086's features)
; ... (Emu8086 display code) ...
MOV AH, 4Ch
INT 21h
Question 7: Write an 8086 program to copy contents of AX register into five consecutive
memory locations.
● Include the 8086 assembly code.
● Provide screenshots of the Emu8086 memory view showing the copied values.
ORG 100h
MOV AX, 1234h ; Example value
MOV BX, 3000h ; Starting segment address
MOV DS, BX ; Set Data Segment register
MOV [0], AX
MOV [2], AX
MOV [4], AX
MOV [6], AX
MOV [8], AX
MOV AH, 4Ch
INT 21h
Question 8: Write an 8086 program to find the sum of digits of a 2-digit number.
● Include the 8086 assembly code.
● Provide screenshots of the Emu8086 output showing the sum.
ORG 100h
MOV AX, 45h ; Example number (assuming decimal for simplicity)
MOV BL, 10 ; Divisor
XOR DX, DX ; Clear DX for division
DIV BL ; AX = quotient, DX = remainder
MOV CL, AL ; Save ones digit
MOV AL, AH ; Move tens digit to AL
ADD AL, CL ; Sum digits
; Result is in AL
MOV AH, 4Ch
INT 21h
Question 9: Write an 8086 program to calculate the difference between two hexadecimal
numbers.
● Include the 8086 assembly code.
● Provide screenshots of the Emu8086 output showing the difference.
ORG 100h
MOV AX, 50h ; Example number 1
MOV BX, 20h ; Example number 2
SUB AX, BX ; AX = AX - BX
; Result in AX
MOV AH, 4Ch
INT 21h
Question 10: Write an 8086 program to calculate the product of elements in an array of
five numbers.
● Include the 8086 assembly code.
● Provide screenshots of the Emu8086 output showing the product.
ORG 100h
MOV CX, 5 ; Array size
MOV SI, 4000h ; Array address
MOV DS, SI ; Set Data Segment
MOV AX, 1 ; Initialize product to 1 (important!)
LOOP_START:
MOV BX, [SI] ; Get array element
MUL BX ; Multiply with product
ADD SI, 2 ; Next word
LOOP LOOP_START ; Repeat CX times
; Result in AX
MOV AH, 4Ch
INT 21h