I need help with these two questions Especially the first on
I need help with these two questions! Especially the first one it confuses me a lot. Thanks
Indicate whether or not the jump happens (show work) a. MOV CL, 5 SUB AL, AL SHL AL, CL JNC LABEL1 b. MOV BH, 65H MOV AL, 48H OR AL, BH SHL AL, 1 JC LABEL1 Assume that array x has been loaded with 100 signed numbers. Write a program which copies the absolute value of each number in x into the corresponding location of y..data x db 100 dup (?) y db 100 dup (?).code; TO DO - place your code hereSolution
(1) a. Mov cl,5 ; it loads cl register with a number 5
sub al,al; subtracting one number with the same number results zero in that register al
shl al,cl; rotating al content cl times,since al contains zero, rotating o\'s cause zero in al register
jnc label 1; no carry, so jump doesn\'t take place.
Ans: No jump takes place for question 1 (a)
(b) mov bh,65; loads the number 65 into bh register, bh= 0110 0101b
mov al,48; loads the number 48 into al register, al= 0100 1000 b
or al,bh ; or operation between al & bh registers data which results al=6dh, or operation result is 1, if atleast one of the input is 1.
shl al,1 ; which shifts al content left side by 1 position, since msb of result is zero, so result is no carry.
jc label1; it doesn\'t jump to label1, because there is no carry .
Ans. 1 (b) Since the result of or operation has zero in msb, for left shift operation it results no carry.
2. .data
x db 100 dup (?)
y db 100 dup (?)
.code
start: mov ax,data; copy data into ax register
mov ds,ax; copy data in ax register to data segment register.
mov cx,100 ; take the count value into cx register
mov bx, offset x; copy address of array x into bx address register
mov al,[bx]; copy data in bx register content, i.e., array x into al register
xor al,al; xor opearation on al with al, to convert signed number to unsigned number
mov [si],al ; copy al register contents to si register address
mov di, offset y ; copy address of array y into di register
cld ; auto-increment both si & di offset registers (address registers)
rep movsb; repeat until all elements of array x are copied to array y.
hlt ; terminate the program
