Basic assembly language programs
================================
Please run the below programs using tasm.(turbo assembler)
PROGRAM 1 : PROGRAM TO FIND OUT AVERAGE OF GIVEN NUMBERS
.MODEL SMALL
.STACK 64
.DATA
NM DW 100,200,150
AVG DW ?
.CODE
BEGIN PROC NEAR
MOV AX,@DATA
MOV DS,AX
MOV CX,3
LEA BX,NM
MOV AX,0
SUMLOP:
ADD AX,[BX]
ADD BX,2
LOOP SUMLOP
MOV CX,3
DIV CX
MOV AVG,AX
MOV AX,4C00H
INT 21H
BEGIN ENDP
END
PROGRAM 2: PROGRAM TO DEMONSTRATE UNCONDITIONAL JUMP
.MODEL SMALL
.CODE
MAIN PROC NEAR
MOV AX,01
MOV BX,01
MOV CX,03
A20 : ADD AX,01
ADD BX,AX
DEC CX
JNZ A20
MOV AX,4C00H
INT 21H
MAIN ENDP
END MAIN
PROGRAM 2: PROGRAM TO DEMONSTRATE UNCONDITIONAL JUMP
.MODEL SMALL
.CODE
MAIN PROC NEAR
MOV AX,01
MOV BX,01
MOV CX,01
A20 : ADD AX,01
ADD BX,AX
SHL CX,1
JMP A20
MAIN ENDP
END MAIN
PROGRAM 3: PROGRAM TO DEMONSTRATE ECHO
.MODEL SMALL
.STACK 64
.DATA
MSG DB 'ENTER YOUR GOOD NAME :'
NM DB 22 DUP (?)
MSG1 DB 'YOUR BAD NAME IS :'
.CODE
BEGIN PROC NEAR
MOV AX,@DATA
MOV DS,AX
MOV DX,OFFSET MSG ;LEA DX,MSG
CALL PRNT
MOV AH,3FH
MOV BX,0
MOV CX,22
LEA DX,NM
INT 21H
LEA DX,MSG1
CALL PRNT
LEA DX,NM
CALL PRNT
MOV AX,4C00H
INT 21H
BEGIN ENDP
PRNT PROC
MOV AH,40H ; SCREEN DISPLAY REQUEST PARAMETER
MOV BX,01; FILE HANDLER FOR SCREEN DISPLAY
MOV CX,22
INT 21H
RET
PRNT ENDP
END
PROGRAM 4: PROGRAM TO DEMONSTRATE ECHO
.MODEL SMALL
.STACK 64
.DATA
ID DB 50 DUP(' ')
IC DW 10H
IM DB 'ENTER STRING : ',
.CODE
BEGIN PROC FAR
MOV AX,@DATA
MOV DS,AX
MOV AH,40H
MOV BX,01
MOV CX,IC
LEA DX,IM
INT 21H
GETI : MOV AH,3FH
MOV BX,00
MOV CX,50
LEA DX,ID
INT 21H
MOV IC,AX
DIS : MOV AH,40H
MOV BX,01
MOV CX,IC
LEA DX,ID
CONT: INT 21H
MOV AX,4C00H
INT 21H
BEGIN ENDP
END
PROGRAM 5: PROGRAM TO DEMONSTRATE IF/ELSE
.MODEL SMALL
.STACK 64
.DATA
TXTA DB 50
TXTB DB 3
TXTC DW 1
TXTD DW 3 DUP(?)
.CODE
BEGIN PROC NEAR
MOV AX,@DATA
MOV DS,AX
MOV CL,TXTB
MOV SI,0
MOV BX,OFFSET TXTD ; OR U CAN USE LEA BX,TXTD
LAB : MOV AL,TXTA
MUL CX
MOV [BX+SI],AX
INC SI
DEC CX
JNZ LAB
MOV AX,4C00H
INT 21H
BEGIN ENDP
END
PROGRAM 6: PROGRAM TO DEMONSTRATE THE SUM OPERATION
.MODEL SMALL
.STACK 64
.DATA
FLDC DW ?
.CODE
BEGIN PROC FAR
MOV AX, @DATA
MOV DS, AX
MOV AX,250
ADD AX,125
MOV FLDC,AX
MOV AX,4C00H
INT 21H
BEGIN ENDP
END BEGIN
PROGRAM 7: PROGRAM TO DEMONSTRATE THE SUM OPERATION
.MODEL SMALL
.STACK 64
.DATA
FLDA DW 250
;FLDB DW 125
FLDC DW ?
.CODE
BEGIN PROC FAR
MOV AX, @DATA
MOV DS, AX
MOV AX,FLDA
ADD AX,125
MOV FLDC,AX
MOV AX,4C00H
INT 21H
BEGIN ENDP
END BEGIN
PROGRAM 8: PROGRAM TO DEMONSTRATE MULTIPLICATION
.MODEL SMALL
.STACK 64
.DATA
MSG DB 'ENTER YOUR NUMBER :'
NM DB ?
MSG1 DB 'YOUR NUMBER X 3 IS :'
.CODE
BEGIN PROC NEAR
MOV AX,@DATA
MOV DS,AX
MOV DX,OFFSET MSG;LEA DX,MSG
CALL PRNT
MOV AH,3FH
MOV BX,0
MOV CX,3
LEA DX,NM
INT 21H
MOV CX,8
MOV AL,0
MOV BX,3
MOV AH,NM
SUB AH,48
MULTILOOP : SHL AL,1
SHL AH,1
JNC CONT
ADDBX : ADD AX,BX
CONT : LOOP MULTILOOP
ADD AX,48
MOV NM,AL
LEA DX,MSG1
CALL PRNT
LEA DX,NM
CALL PRNT
MOV AX,4C00H
INT 21H
BEGIN ENDP
PRNT PROC
MOV AH,40H ; SCREEN DISPLAY REQUEST PARAMETER
MOV BX,01; FILE HANDLER FOR SCREEN DISPLAY
MOV CX,22
INT 21H
RET
PRNT ENDP
END
PROGRAM 9: PROGRAM TO DEMONSTRATE THE PROCEDURES
.MODEL SMALL
.STACK 64
.DATA
N1 DB 'ABCDEFGHI'
N2 DB 'JKLMNOPQR'
N3 DB 'STUVWXYZ*'
.CODE
BEGIN PROC FAR
MOV AX,@DATA
MOV DS,AX
MOV ES,AX
CALL B10
CALL C10
MOV AX,4C00H
INT 21H
BEGIN ENDP
B10 PROC
LEA SI,N1
LEA DI,N2
MOV CX,09
B20 : MOV AL,[SI]
MOV [DI],AL
INC SI
INC DI
DEC CX
JNZ B20
RET
B10 ENDP
C10 PROC
LEA SI,N2
LEA DI,N3
MOV CX,09
C20 : MOV AL,[SI]
MOV [DI],AL
INC DI
INC SI
LOOP C20
RET
C10 ENDP
END BEGIN
No comments:
Post a Comment