0% found this document useful (0 votes)
56 views6 pages

Assignment No 6 On CH 4

The document contains three assembly language programming problems and their solutions. It asks to subtract two 16-bit numbers, count the number of 0s in a 16-bit number, and add two BCD numbers using a procedure. It also contains a problem and solution for block transfer without string instructions and summing a series of 10 numbers using a procedure and flowchart.

Uploaded by

xboyxman1000
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views6 pages

Assignment No 6 On CH 4

The document contains three assembly language programming problems and their solutions. It asks to subtract two 16-bit numbers, count the number of 0s in a 16-bit number, and add two BCD numbers using a procedure. It also contains a problem and solution for block transfer without string instructions and summing a series of 10 numbers using a procedure and flowchart.

Uploaded by

xboyxman1000
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Assignment no: 6 on chapter no-4

31) Write ALP to Subtract two 16 bit numbers

Ans: DATA SEGMENT

NUM1 DW 3210H
NUM2 DW 1200H
R DW ?
DATA ENDS
CODE SEGMENT
ASSUME CS: CODE, DS: DATA
START: MOV AX, DATA
MOV DS, AX
MOV AX, NUM1
MOV BX, NUM2
SUB AX, BX
MOV R, AX
MOV AH, 4CH
INT 21H
CODE ENDS
END START

32) Write ALP to count number of 0’s in a 16 bit number stored in AX register

Ans: DATA SEGMENT


NUM DW 1102H
C DB 00H
DATA ENDS
CODE SEGMENT

ASSUME CS:CODE, DS:DATA


START:
MOV DX, DATA
MOV DS, DX
MOV CX, 10H
MOV AX, NUM
UP: ROR AX, 1
JC DN
INC C
DN: LOOP UP
MOV AX, 4C00H
INT 21H
CODE ENDS
END START

1
33) Write ALP using Procedure to add two BCD numbers

Ans: MODEL SMALL

.DATA

NUM1 DB 04H

NUM2 DB 06H

BCD_SUM DB ?

.CODE
MOV AX,@DATA
MOV DS, AX
CALL BCD_ADD
MOV AH,4CH
INT 21H

BCD_ADD PROC
MOV AL, NUM1
MOV BL, NUM2
ADD AL,BL
DAA
MOV BCD_SUM, AL
RET
BCD_ADD ENDP
END

2
34) Write ALP and draw flow chart to perform Block Transfer without using String
Instruction.

ANS:

3
35) Write ALP for SUM of series of 10 numbers using Procedure. Also draw a flow chart

for the same.

Ans: Program: Using 8 bit data

DATA SEGMENT
NUM1 DB 10H,20H,30H,40H,50H
RESULT DB 0H
CARRY DB 0H
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE, DS:DATA
START: MOV DX,DATA
MOV DS, DX
MOV CL,05H
MOV SI, OFFSET NUM1
UP: CALL SUM
INC SI
LOOP UP
MOV AH,4CH
INT 21H
SUM PROC ; Procedure to add two 8 bit numbers
MOV AL,[SI]
ADD RESULT, AL
JNC NEXT

INC CARRY
NEXT: RET
SUM ENDP
CODE ENDS
END START

-or-
Program using 16 bit data:
DATA SEGMENT
NUM1 DW 1000H,2000H,3000H,4000H,5000H
RESULT DW 0H
CARRY DB 0H
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE, DS:DATA
START: MOV DX,DATA
MOV DS, DX
4
MOV CL,05H
MOV SI, OFFSET NUM1
UP: CALL SUM
INC SI
INC SI
LOOP UP
MOV AH,4CH
INT 21H
SUM PROC ; Procedure to add two 16 bit numbers
MOV AX,[SI]
ADD RESULT,AX
JNC NEXT

INC CARRY
NEXT: RET
SUM ENDP
CODE ENDS
END START

5
6

You might also like