These are two programs. I need someone to write Assembly Programming codes for t
ID: 3532999 • Letter: T
Question
These are two programs. I need someone to write Assembly Programming codes for these two programs. The Architecture is 8086. File format .asm and it should work in NASM.
1. Write a program to search a particular element from an array using binary search. If the element is found set AX to one and otherwise to zero. It needs to be sorted first. Code should do the sorting part and then same code implements binary search. Code should be generic, take array elements and array size in memory. 2. Take two arrays in memory as input sets, and find; a) union b) intersection c) difference of these two sets and store the result sets in the memory.
Explanation / Answer
;binary search.MODEL SMALL.STACK.DATA ARR DW 0111H,0112H,0113H,0114H,0115H LEN DW ($-ARR)/2 KEY EQU 0115H MSG1 DB "KEY IS FOUND AT "RES DB " POSITION",13,10,"$" MSG2 DB 'KEY NOT FOUND!!!!!!!!!!!!!. $'.CODE MOV AX,@DATA MOV DS,AX MOV BX,00 MOV DX,LEN MOV CX,KEY AGAIN:CMP BX,DX JA FAIL MOV AX,BX ADD AX,DX SHR AX,1 MOV SI,AX ADD SI,SI CMP CX,ARR[SI] JAE BIG DEC AX MOV DX,AX JMP AGAIN BIG:JE SUCCESS INC AX MOV BX,AX JMP AGAINSUCCESS:ADD AL,01 ADD AL,'0' MOV RES,AL LEA DX,MSG1 JMP DISP FAIL:LEA DX,MSG2 DISP:MOV AH,09H INT 21H MOV AH,4CH
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.