ALP
ALP
two arrays from the given array such that one array P(j) contains all positive numbers and the other N(k) contains all the negative numbers in memory locations. Store the array of positive numbers starting at offset address B000H and the negative numbers starting at offset address C000H. start: mov ax,@data mov ds, ax mov SI, A000H mov DI, B000H mov BX, C000H mov CX, 100 aa: mov AX, [SI] mov dx, AX and ax, 8000h jz post mov [BX],dx inc BX inc BX jmp bb post: mov [DI],dx inc DI inc DI bb: inc SI inc SI loop aa mov ah,4ch int 21h end start end
2) Write a program that compares the elements of two arrays A(1) and B(1). Each array contains 100 16 bits signed numbers. Compare the corresponding numbers of the two arrays until either two elements are found to be unequal or all elements of the arrays have been compared and found to be equal. Assume that the arrays start in the current data segment at offset address A000H and B000H respectively. If the two arrays are found to be unequal, save the address of the first unequal element of A(1) in the memory location with offset address FOUND in the current data segment; Otherwise write all 0s into this location.
start: mov ax,@data mov ds, ax mov SI, A000H mov DI, B000H mov CX, 100 aa: mov AX, [SI] mov dx, [DI] cmp AX, DX jz bb mov found,SI jmp cc bb: inc SI inc SI inc DI inc DI loop aa mov found, 0000h cc: mov ah,4ch int 21h end start end
3) Draw a flow chart and write a program to reverse the word in String
.model small .data str1 db "abcd efgh ijkl$" str2 db 14 dup (0) .code start: mov ax, @data mov ds, ax mov cx, 0Eh mov si, offset str1 mov di, offset str1 mov bx, offset str2 add cx, si jmp cc aa: cc: Inc SI mov dl,20h cmp [SI],dl jz cd mov dl,24h cmp [SI], dl jnz aa cd: mov bp, SI dec SI bb: mov AL, [SI] mov [BX], AL inc BX dec SI CMP SI,DI JNC bb Mov SI, bp
MOV DI, bp mov al,[SI] mov [BX], al inc SI inc DI inc BX cmp cx, si ja cc lea dx, str2 mov ah, 09h int 21h mov ah, 4ch int 21h end start end
4) Write a program to transfer 100 bytes block starting from offset address BLK1 to the memory locations starting from BLK2. Both BLK1 and BLK2 are in the data segment DATASEGADDR.
start: mov ax,@data mov ds,ax mov cl, 100 mov bx, 0000h mov dx, 0000h aa: mov al,BLK1[BX] mov BLK2[BX], al inc BX inc DX loop aa lea DX, array2 mov ah, 09h int 21h mov ah, 4ch int 21h end start end
5) Find the values in the destination for each line of this program segment STC MOV AX, 5485H RCR AL, 01h MOV CL, 03H RCL AX, CL MOV CL, 05h ROR AX, CL ROL AX, 01h Ans: 1) C=1 2) AX => 5485h and C=1 3) AX => 54C2h and C=1 4) CL => 03h 5) AX => A615h and C=0 6) CL => 05h 7) AX => AD30h and C=1 8) AX => 5AC3h and C=1
6) Write an assembly language program to add bytes from the first two arrays and the sum is to be saved in third array by using register relative addressing mode. start: mov ax,@data mov ds,ax mov cl, 100 mov bx, 0000h aa: mov al,Array1[BX] mov dl,Array2[BX] Add al, dl Mov Array3[BX], al inc BX loop aa mov ah, 4ch int 21h end start end
start: mov ax,@data mov ds,ax mov cl, 10 mov bx, 0000h mov al,Array1[BX] aa: inc BX mov dl,Array1[BX] cmp al, dl jg bb mov al,dl bb: loop aa mov ah, 4ch int 21h end start end