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

Write in 80x86 assembly language code. Comment each line of instruction. 1) Decl

ID: 3599726 • Letter: W

Question

Write in 80x86 assembly language code. Comment each line of instruction.

1) Declare two arrays of size 5 and initialize the first one to odd numbers 1, 3, 5, 7 and 9. Initialize the second one to even numbers 2, 4, 6, 8 and 10. Add the corresponding elements of the two arrays and place the result into the third array called result.

2) Write a program to declare an array containing a string (character array). Write a function to check if this string is palindrome or not. The function should return 1 in al if it is palindrome. An example of palindrome string is racecar. Place zero in al if it is not palindrome.

Explanation / Answer

code 1:-

data segment
arr1 db 01h,03h,05h,07h,09h #declare odd array
arr2 db 02h,04h,06h,08h,10h #declare even std::array
arr3 db 5 dup (0) #declareresult array
data ends

code segment
assume cs:code , ds:data

start:

mov ax,data
mov ds,ax

lea si,arr1 #load arr1 into si
lea di,arr2 #load arr2 into di
lea bx,arr3 #load arr3 into bx

mov cl,5 #intialised c1 to the no. of elements of array

l1:
mov al,[si] #load arr1 into al
add al,[di] #add arr1+arr2
mov [bx],al #move the result into arr3 i.e. arr1+arr2 = bx
inc si #increament arr1 index
inc di #increament arr2 index
inc bx #increament arr3 index
dec cl #decreament c1
jnz l1 #loop

mov ah,4ch
int 21h
code ends
end start

code 2:-

DATA SEGMENT

BLOCK1 DB 'racecar'
MSG1 DB "IT IS PALINDROME $"
MSG2 DB "IT IS NOT PALINDROME $"
PAL DB 00H

DATA ENDS

PRINT MACRO MSG

MOV AH,09H
LEA DX,MSG
INT 21H
INT 3H

ENDM

EXTRA SEGMENT

BLOCK2 DB 7 DUP(?)
EXTRA ENDS

CODE SEGMENT
ASSUME CS:CODE,DS:DATA,ES:EXTRA
START: MOV AX,DATA
MOV DS,AX
MOV AX,EXTRA
MOV ES,AX
LEA SI,BLOCK1
LEA DI,BLOCK2+6
MOV CX,00007H
BACK: CLD
LODSB
STD
STOSB
LOOP BACK
LEA SI,BLOCK1
LEA DI,BLOCK2
MOV CX,0007H
CLD
REPZ CMPSB
JNZ SKIP
PRINT MSG1
SKIP: PRINT MSG2
CODE ENDS
END START


Output::-

C:TASM>debug AMPN7.exe
-g
IT IS PALINDROM

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