Practical No 14
Page No: 88
Observations:
1) Observe and write the contents of Register using debugger TD or debug after and before the
execution of the program.
Table 1: Content of Registers
Registers
Flag Register
After Before
AX 00DCH 0000H Carry Flag CF 1
BX 0007H 0000H Zero Flag ZF 1
CX 0000H 0008H Sign Flag SF 0
DX 0000H 0000H Overflow Flag OF 0
SI 0000H 0000H Parity Flag PF 1
DI 0000H 0000H Auxiliary Carry Flag AF 0
BP 0000H 0000H Interrupt Flag IF 1
SP 0000H 0000H Direction Flag DF 0
DS 48ADH 48ADH
ES 489DH 489DH
SS 48ACH 48ACH
CS 48AEH 48AEH
IP 0023H 000FH
2) Observe and write the contents of memory location in Data Segment using debugger TD or
debug.
Table 3: Content of Memory Location in Data Segment
Address Contents Address Contents
DS: 0000H 0AH DS: 0008H 08H
DS: 0001H F1H DS: 0009H 05H
DS: 0002H 48H DS: 000AH 03H
DS: 0003H 53H DS: 000BH -
DS: 0004H C1H DS: 000CH -
DS: 0005H 2FH DS: 000DH -
DS: 0006H 2CH DS: 000EH -
DS: 0007H EEH DS: 000FH -
Page No: 88
Program Code with Comments:
.model small
.data
arr db 10d, -15d, 72d, 83d, -63d, 47d, 44d, -18d
n db 08h
p_cnt db 00h
n_cnt db 00h
.code
mov ax, @data
mov ds, ax
mov ax, 0000h
lea bx, arr
mov cl, n
l1: mov al, byte ptr [bx]
shl al, 01h
jc l2
inc p_cnt
jmp l3
l2: inc n_cnt
l3: inc bx
dec cl
jnz l1
ends
end
Page No: 88
Results: (Output of the Program)
Count of Positive numbers: 05
Count of Negative numbers: 03
Page No: 88
Practical related questions:
1. Write the flag used to check whether the number is Positive or Negative.
The Carry flag (CF) is used to check whether the number is Positive or Negative.
2. Which bit of 8-bit/16-bit number is used to decide if number is Positive or Negative?
The msb, that is D15 bit of 8-bit/16-bit number is used to decide if number is positive or
negative.
Page No: 89, 90 and 91
Exercise:
1. Write an ALP to count Positive as well as Negative numbers in array of 10 numbers.
2. Write an ALP to add the all Positive numbers in array of 10 numbers.
.model small
.data
arr db 10d, -15d, 72d, 83d, -63d, 47d, 44d, -18d
n db 08h
sum dw ?
.code
mov ax, @data
mov ds, ax
mov ax, 0000h
mov dx, 0000h
lea bx, arr
mov cl, n
l1: mov al, byte ptr [bx]
shl al, 01h
jc l2
mov al, byte ptr [bx]
add dx, ax
l2: inc bx
dec cl
jnz l1
mov sum, dx
ends
end
Output:
Sum = 0100H