0% found this document useful (0 votes)
2 views8 pages

Micro Lab 110826

The document contains three assembly language programs. The first program swaps two numbers using arithmetic operations, the second calculates the sum of two numbers and displays it if greater than 10, and the third takes a string input from the user and prints it. Each program includes data declarations, input/output handling, and exit procedures.
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)
2 views8 pages

Micro Lab 110826

The document contains three assembly language programs. The first program swaps two numbers using arithmetic operations, the second calculates the sum of two numbers and displays it if greater than 10, and the third takes a string input from the user and prints it. Each program includes data declarations, input/output handling, and exit procedures.
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

Swap using arithmetic operations

.MODEL SMALL

.STACK 100 H

.DATA

MSG1 DB 'Enter 1st number: $'

MSG2 DB 'Enter 2nd number: $'

MSG3 DB 'Number you entered; $'

MSG4 DB 'After swapping: $'

.CODE

MAIN PROC

;INITIALIZING VARIABLE

MOV AX,@DATA

MOV DS,AX

;LOADING AND PRINTING MESSAGE

LEA DX,MSG1

MOV AH,9

INT 21H

;TAKING INPUTS

MOV AH,1
INT 21H

MOV CH,AL

;NEW LINE

MOV AH,2

MOV DL,0AH

INT 21H

MOV DL,0DH

INT 21H

;LOADING AND PRINTING DATA

LEA DX,MSG2

MOV AH,9

INT 21H

;TAKING INPUT 2

MOV AH,1

INT 21H

MOV CL,AL

;NEW LINE

MOV AH,2

MOV DL,0AH
INT 21H

MOV DL,0DH

INT 21H

;LOAD AND PRINT

LEA DX,MSG3

MOV AH,9

INT 21H

MOV AH,2

MOV DL,CH

INT 21H

MOV DL,' '

INT 21H

MOV DL,CL

INT 21H

;NEW LINE

MOV AH,2

MOV DL,0AH

INT 21H

MOV DL,0DH

INT 21H

;LOAD AND PRINT


LEA DX,MSG4

MOV AH,9

INT 21H

;ARITHMATIC OPERATIONS

ADD CH,CL

MOV BH,CH

SUB BH,CL

MOV CL,BH

SUB CH,CL

;PRINTING SWAPED NUMBERS

MOV AH,2

MOV DL,CH

INT 21H

MOV DL,' '

INT 21H

MOV DL,CL

INT 21H

MOV AH,4CH

INT 21H

MAIN ENDP
END MAIN

Sum greater than 10


.MODEL SMALL

.STACK 100H

.DATA

NUM1 DB ?

NUM2 DB ?

.CODE

MAIN PROC

MOV AX,@DATA

MOV DS,AX

MOV AH,1

INT 21H

SUB AL,30H

MOV NUM1,AL

INT 21H

SUB AL,30H

MOV NUM2,AL

INT 21H
SUB AL,30H

ADD AL,NUM1

MOV AH,0

AAA

ADD AL,NUM2

AAA

MOV BX,AX

MOV AH,2

;NEW LINE

MOV DL,0AH

INT 21H

MOV DL,0DH

INT 21H

ADD BH,30H

ADD BL,30H

MOV DL,BH

INT 21H

MOV DL,BL

INT 21H
MOV AH, 4CH

INT 21H

MAIN ENDP

END MAIN

String Input and Print


.MODEL SMALL

.STACK 100H

.DATA

MSG DB 'Enter a string: $'

STR DB 50, ?, 50 DUP('$')

.CODE

MAIN PROC

MOV AX, @DATA

MOV DS, AX

; Display message

MOV AH, 09H

LEA DX, MSG

INT 21H

; Take string input

MOV AH, 0AH


LEA DX, STR

INT 21H

; New line

MOV AH, 02H

MOV DL, 0DH

INT 21H

MOV DL, 0AH

INT 21H

; Display string

MOV AH, 09H

LEA DX, STR+2

INT 21H

; Exit

MOV AH, 4CH

INT 21H

MAIN ENDP

END MAIN

You might also like