0% found this document useful (0 votes)
19 views4 pages

Mic Assingment

The document contains a series of assembly language program examples, including program structure, addition of two 16-bit numbers, summing a series of five numbers, reversing a string, and counting the number of 1's in a 16-bit number stored in a register. Each example includes the necessary code with comments explaining the purpose of different sections. The programs are structured using the .MODEL SMALL directive and follow a standard format for data and code segments.

Uploaded by

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

Mic Assingment

The document contains a series of assembly language program examples, including program structure, addition of two 16-bit numbers, summing a series of five numbers, reversing a string, and counting the number of 1's in a 16-bit number stored in a register. Each example includes the necessary code with comments explaining the purpose of different sections. The programs are structured using the .MODEL SMALL directive and follow a standard format for data and code segments.

Uploaded by

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

MIC ASSINGMENT – 4TH ANSWERS

1. Write the program structure for writing program in assembly language. with suitable
comment
ANSWER:
.MODEL SMALL ; Define memory model
.STACK 100H ; Define stack size
.DATA ; Data segment starts
; Declare variables here
.CODE ; Code segment starts
MAIN PROC ; Main procedure
MOV AX, @DATA
MOV DS, AX ; Initialize data segment

; Write your assembly instructions here

MOV AH, 4CH ; DOS interrupt to terminate program


INT 21H
MAIN ENDP
END MAIN ; End of program
2. Write an assembly level language program to add two add 2 16-bit number.
ANSWER:
.MODEL SMALL
.STACK 100H
.DATA
NUM1 DW 1234H
NUM2 DW 5678H
RESULT DW ?
.CODE
MAIN PROC
MOV AX, @DATA
MOV DS, AX

MOV AX, NUM1


ADD AX, NUM2
MOV RESULT, AX

MOV AH, 4CH


INT 21H
MAIN ENDP
END MAIN
3. Write an assembly level language program to add the series of 5 numbers.
ANSWER:
.MODEL SMALL
.STACK 100H
.DATA
SERIES DW 100H, 200H, 300H, 400H, 500H
COUNT DW 5
RESULT DW ?
.CODE
MAIN PROC
MOV AX, @DATA
MOV DS, AX

MOV CX, COUNT


MOV SI, 0
MOV AX, 0

LOOP_ADD:
ADD AX, SERIES[SI]
ADD SI, 2
LOOP LOOP_ADD

MOV RESULT, AX

MOV AH, 4CH


INT 21H
MAIN ENDP
END MAIN
4. Write an assembly level language program to add 16-bit BCD number.
ANSWER:
.MODEL SMALL
.STACK 100H
.DATA
STR DB 'HELLO$', 0
LEN EQU $-STR-1
.CODE
MAIN PROC
MOV AX, @DATA
MOV DS, AX
MOV SI, 0
MOV DI, LEN-1

REVERSE_LOOP:
CMP SI, DI
JGE END_LOOP

MOV AL, STR[SI]


MOV BL, STR[DI]
MOV STR[SI], BL
MOV STR[DI], AL

INC SI
DEC DI
JMP REVERSE_LOOP
END_LOOP:
MOV AH, 4CH
INT 21H
MAIN ENDP
END MAIN
5. Write an assembly level language program to reverse the string.
ANSWER:
.MODEL SMALL
.STACK 100H
.DATA
STR DB 'HELLO$', 0
LEN EQU $-STR-1
.CODE
MAIN PROC
MOV AX, @DATA
MOV DS, AX
MOV SI, 0
MOV DI, LEN-1

REVERSE_LOOP:
CMP SI, DI
JGE END_LOOP

MOV AL, STR[SI]


MOV BL, STR[DI]
MOV STR[SI], BL
MOV STR[DI], AL

INC SI
DEC DI
JMP REVERSE_LOOP

END_LOOP:
MOV AH, 4CH
INT 21H
MAIN ENDP
END MAIN

6. Write an assembly level language program to count numbers of 1's in 16-bit number
stores in BX register.
ANSWER:
.MODEL SMALL
.STACK 100H
.DATA
BX_VAL DW 0F0Fh
COUNT DB 0
.CODE
MAIN PROC
MOV AX, @DATA
MOV DS, AX

MOV CX, 16
MOV BX, BX_VAL
MOV AL, 0

COUNT_LOOP:
SHR BX, 1
JNC SKIP_INC
INC AL

SKIP_INC:
LOOP COUNT_LOOP

MOV COUNT, AL

MOV AH, 4CH


INT 21H
MAIN ENDP
END MAIN

--------------------------------------E----------------------N-------------------------D--------------------------------

You might also like