Beruflich Dokumente
Kultur Dokumente
show macro x
push ax
push bx
mov al, x
aam
mov bx, ax
or bx, 3030h
write bh
write bl
pop bx
pop ax
endm
_data segment
msg1 db ' enter the no. of terms present (max 10) : $'
msg2 db ' make your entry : $'
msg3 db ' the sorted array is (in ascending order) : $'
msg4 db ' no. of items exceeds the limit$'
vars db maxi dup (0)
var1 db ?
var2 db ?
_data ends
_code segment
assume cs : _code , ds : _data , ss : _stack
start: mov ax, _data
mov ds, ax ; initialise ds register with segment
address of data
mov ax, _stack
mov ss, ax ; initialise ss register with segment
address of stack
lea sp, stack_top ; initialise stack pointer
xor cx, cx
make_entry cl ; cl contains the no. of terms
write 0ah
write 0dh
print msg3
lea si , vars
xor ch, ch
loop5: mov bl, byte ptr [si]
show bl
write 20h
inc si
inc ch
cmp ch, cl
jne loop5
_code ends
end start
data segment
msg1 db "enter the expression = $"
msg2 db "the result = $"
ends data
code segment
assume cs:code,ds:data
mov ah,01h
int 21h
mov bh,al
sub bh,30h
int 21h
mov bl,al
cmp bl,197d
je plus
cmp bl,196d
je minus
mov ah,02h
mov dl,bh
int 21h
jmp last
mov ah,02h
mov dl,bh
int 21h
jmp last
last : mov ax,4c00h
int 21h
code ends
end start
data segment
msge1 db 'dir-name changed$'
msge2 db 'error$'
dir db 'raj',0
data ends
code segment
assume cs:code,ds:data
start: mov ax,data
mov ds,ax
mov ah,38h
mov dx,offset dir
int 21h
jc loop1
mov dx,offset msge1
mov ah,09h
int 21h
mov ax,4c00h
int 21h
loop1: mov dx,offset msge2
code ends
end
;----------------------------------------------------------------------
; program to clear screen (scroll up) and place cursor at bottom left
;----------------------------------------------------------------------
; programmed by indranil gupta ( regn. no. 98011015 )
; c:\tasm\bin\indranil\cls_bl.asm ( 8086 program)
; dated : 30-11-2000.
;----------------------------------------------------------------------
attri equ 02h ; attribute to be used in specified area
code segment
assume cs : code
start: mov ah, 0fh
int 10h ; get current video mode
mov bl, bh ; active display page
;----------------------------------------------------------------------
; end of program
;----------------------------------------------------------------------
;----------------------------------------------------------------------
; program to clear screen (scroll up) and place cursor at bottom left
;----------------------------------------------------------------------
; programmed by indranil gupta ( regn. no. 98011015 )
; c:\tasm\bin\indranil\cls_bl.asm ( 8086 program)
; dated : 30-11-2000.
;----------------------------------------------------------------------
attri equ 02h ; attribute to be used in specified area
code segment
assume cs : code
start: mov ah, 0fh
int 10h ; get current video mode
mov bl, bh ; active display page
;------------------------------------------------------------------------
; program to clear a specified portion of the screen
;------------------------------------------------------------------------
data segment
msg1 db ' enter the top left x co-ordinate ( 2 digits) :
$'
msg2 db ' enter the top left y co-ordinate ( 2 digits) :
$'
msg3 db ' enter the bottom right x co-ordinate ( 2
digits) : $'
msg4 db ' enter the bottom right y co-ordinate ( 2
digits) : $'
msg5 db ' invalid entry made$'
data ends
code segment
assume cs : code , ds : data
start: mov ax, data
mov ds, ax ; initialise ds register
print msg1 ; display msg1
take_val ; input the top left x co-ordinate
cmp al, 50h ; al should be less than 80d (i.e. 50h)
jg errormsg
mov cl, al ; top left x co-ordinate
write 0ah
write 0dh ; move cursor to next line
print msg2 ; display msg2
take_val ; input the top left y co-ordinate
cmp al, 19h ; al should be less than 25d (i.e. 19h)
jg errormsg
mov ch, al ; top left y co-ordinate
jmp loop0
;-----------------------------------------------------------------------------
;-----------------------------------------------------------------------------
; end of program
;-----------------------------------------------------------------------------
data segment
msge1 db 'file-deleted$'
msge2 db 'error$'
file db 'raj.txt',0
data ends
code segment
assume cs:code,ds:data
start: mov ax,data
mov ds,ax
mov ah,41h
mov dx,offset file
int 21h
jc loop1
mov dx,offset msge1
mov ah,09h
int 21h
mov ax,4c00h
int 21h
loop1: mov dx,offset msge2
code ends
end
;-------------------------------------------------------------------------
; program to display the ascii code of a character pressed
;-------------------------------------------------------------------------
data segment
msg1 db 'enter any character : $'
msg2 db 'the equivalent ascii code in hex is $'
data ends
code segment
assume cs:code, ds:data
start: mov ax, data
mov ds, ax ; initialise ds register
mov al, bl
and bl, 0fh ; masking lower nibble of bl
code ends
end start
;-------------------------------------------------------------------------
; end of program
;-------------------------------------------------------------------------
;---------------------------------------------------------------------------
data segment
msg1 db 0ah,0dh,' enter the two digit hex code (0-9,a-f)
: $'
msg2 db 0ah,0dh,' the equivalent character is : $'
msg3 db 0ah,0dh,' error in input$'
data ends
code segment
assume cs:code , ds:data
start: mov ax, data
mov ds, ax
code ends
end start
;---------------------------------------------------------------------------
; end of program
;---------------------------------------------------------------------------
;---------------------------------------------------------------------
; program to find wheather a no. is even or odd.
;---------------------------------------------------------------------
; programmed by indranil gupta ( regn. no. 98011015)
; j:\tasm12\bin\indranil\even_odd.asm (8086 program)
; dated : 30-11-2000.
;---------------------------------------------------------------------
data segment
msg1 db ' enter any two digit decimal no. : $'
msg2 db ' the no. is even.$'
msg3 db ' the no. is odd.$'
msg4 db ' invalid input$'
data ends
code segment
assume cs:code , ds:data
start: mov ax, data
mov ds, ax
print msg1
read
cmp al, 30h
jl errormsg
cmp al, 39h
jg errormsg
mov bh, al
read
cmp al, 30h
jl errormsg
cmp al, 39h
jg errormsg
mov bl, al
write 0ah
write 0dh
; end of program
;---------------------------------------------------------------------
data segment
msg1 db "enter a 2-digit no = $"
msg2 db "the no is even$"
msg3 db "the no is odd$"
data ends
code segment
assume cs:code,ds:data
print msg1
mov ah,01h
int 21h
mov bh,al
int 21h
mov bl,al
and bx,0f0fh
better_display
mov ax,bx
mov bl,02h
div bl
cmp ah,0h
je iseven
print msg3
jmp last
code ends
end start
;--------------------------------------------------------------------
; program to find the factorial of a no. by iterative methord
;--------------------------------------------------------------------
; programmed by indranil gupta ( regn. no. 98011015)
; c:\tasm\bin\fact_hex.asm ( 8086 program)
; dated : 30-11-2000.
;--------------------------------------------------------------------
data segment
msg1 db ' enter any single digit decimal no. < 9 : $'
msg2 db ' the factorial in hex is $'
msg3 db ' invalid input or out of range$'
var1 db ?
data ends
code segment
assume cs:code , ds:data
start: mov ax, data
mov ds, ax ; initialise ds
print msg1
write 0ah
write 0dh ; move cursor to new line
print msg2
xor ax, ax
mov al, var1
mov cx, ax ; cx <- ax
dec cx
xor cx, cx
mov bx, ax ; bx contains the factorial
loop2: xor cl, cl
xor dh, dh
loop3: shl bx, 01h ; shift msb of bx to carry bit
rcl dh, 01h ; rotate dh left through carry bit
inc cl
cmp cl, 04h
jne loop3
;--------------------------------------------------------------------
; end of program
;--------------------------------------------------------------------
;-------------------------------------------------------------------------
; program to find the factorial of a number using recursion
;-------------------------------------------------------------------------
; programmed by indranil gupta ( regn. no. 98011015)
; c:\tasm\bin\indranil\fact_rec.asm ( 8086 program )
; dated : 30-11-2000.
;-------------------------------------------------------------------------
read macro
push ax
mov ah, 01h
int 21h
mov bl, al
pop ax
endm
write macro x
push ax
push dx
mov dl, x
mov ah, 02h
int 21h
pop dx
pop ax
endm
print macro x
push ax
push dx
mov dx, offset x
mov ah, 09h
int 21h
pop dx
pop ax
endm
_data segment
msg1 db ' enter the number ( < 9 ) : $'
msg2 db ' the factorial in hex is : $'
msg3 db ' invalid input or out of range$'
_data ends
_code segment
assume cs : _code , ds : _data , ss : _stack
start: mov ax, _data
mov ds, ax
mov ax, _stack
mov ss, ax
lea sp, stack_top
print msg1
read
cmp bl, 30h
jl errormsg
cmp bl, 38h
jg errormsg
and bl, 0fh
xor cx, cx
mov cl, bl
jmp l0
print msg2
xor ax, ax
mov ax, 0001h
call fact
mov bl, ah
call show
mov bl, al
call show
write 'h'
jmp last
_code ends
end start
;-------------------------------------------------------------------------
; end of program
;-------------------------------------------------------------------------
data segment
msg1 db "enter the no of terms(max 5) = $"
msg2 db "the fibonacci series = $"
n db ?
var db ?
data ends
code segment
assume cs:code,ds:data
mov ah,01h
int 21h
and al,0fh
mov n,al
mov cl,00h
mov bl,00h
mov bh,01h
mov ch,01h
mov ah,02h
mov dl,30h
int 21h
mov dl,31h
int 21h
code ends
end start
print macro x
mov ah, 09h
mov dx, offset x
int 21h
endm
read macro
mov ah, 01h
int 21h
endm
write macro x
mov ah, 02h
mov dl, x
int 21h
endm
data segment
msg1 db ' enter the two digit no. of terms (max 11) : $'
msg2 db ' the fibonacii terms are :-$'
msg3 db ' invalid entry or out or range$'
var1 db ?
var2 db ?
data ends
code segment
assume cs:code , ds: data
start: mov ax, data
mov ds, ax
print msg1
read
cmp al, 30h
jl errormsg
cmp al, 31h
jg errormsg
mov bh, al
read
cmp al, 30h
jl errormsg
cmp al, 39h
jg errormsg
mov bl, al
code ends
end start
;----------------------------------------------------------------------
; program to copy contents of source file to destination file
;----------------------------------------------------------------------
; programmed by indranil gupta (regn. no. 98011015)
; j:\tasm12\bin\fil_copy.asm (8086 program)
; dated : 23-10-2000.
;----------------------------------------------------------------------
data segment
srcfile db 'abc.txt',0 ; source file
dstfile db 'xyz.txt',0 ; destination file
fhan1 dw ? ; file handlers
fhan2 dw ?
buffer db 100 dup (0)
msg1 db 'successful$'
msg2 db 'not successful$'
data ends
code segment
assume cs:code , ds:data
start: mov ax, data
mov ds, ax ; initialize ds register
mov cx, ax
mov ah, 40h
mov bx, fhan2
mov dx, offset buffer
int 21h ; write the contents of second file
jc errormsg
;----------------------------------------------------------------------
; end of program
;----------------------------------------------------------------------
;---------------------------------------------------------------------------
; program to set or get file attributes
;---------------------------------------------------------------------------
; programmed by indranil gupta ( regn. no. 98011015 )
; c:\tasm\bin\file_att.asm ( 8086 program )
;---------------------------------------------------------------------------
data segment
filename db 15 dup (0)
msg1 db 0ah,0dh,' enter 1 to set file attributes $'
msg2 db 0ah,0dh,' or any other key to set file attributes
: $'
msg3 db 0ah,0dh,' enter the file name : $'
msg4 db 0ah,0dh,' enter the no. of attributes you want to
have : $'
msg5 db 0ah,0dh,' the file attributes are : $'
msg6 db 0ah,0dh,' enter $'
msg7 db 0ah,0dh,' enter the attribute to be set : $'
code segment
assume cs:code , ds:data
start: mov ax, data
mov ds, ax
print msg1
print msg2
read
mov cl, al
print msg3
lea si, filename
l1: read
cmp al, 0dh
je l2
mov byte ptr [si], al
inc si
jmp l1
print msg4
read
mov cl, al
and cl, 0fh
print msg7
xor ch, ch
xor bl, bl
l8: read
cmp al, 'r'
jne l9
or bl, 01h
jmp ld
l9: cmp al, 'h'
jne la
or bl, 02h
jmp ld
la: cmp al, 's'
jne lb
or bl, 04h
jmp ld
lb: cmp al, 'v'
jne lc
or bl, 08h
jmp ld
lc: or bl, 20h
ld: inc ch
cmp ch, cl
jne l8
code ends
end start
;---------------------------------------------------------------------------
; end of program
;---------------------------------------------------------------------------
data segment
source db 80 dup(0)
dest db 80 dup(0)
recsize equ 512
rdcount dw ?
buff db recsize dup(0)
handle1 dw ?
handle2 dw ?
msg1 db "enter source filename$"
msg2 db 0ah,0dh,"enter destination filename$"
error_msg db "error$"
success_msg db "1 file copied$"
data ends
text segment
assume cs:text,ds:data
file_end :
mov ah,3eh
mov bx,handle1
int 21h
mov ah,3eh
mov dx,handle2
int 21h
jmp quit
data segment
msg1 db "enter the hexadecimal no = $"
msg2 db "its decimal equivalent = $"
data ends
code segment
assume cs:code,ds:data
print msg2
cmp bh,3ah
jg l1
sub bh,30h
jmp l2
l1 : sub bh,37h
l2 : cmp bl,3ah
jg l3
sub bl,30h
jmp l4
l3 : sub bl,37h
l4 : shl bh,04h
or bh,bl
xor ax,ax
mov al,bh
aam
mov bx,ax
or bx,3030h
mov ah,02h
mov dl,bh
int 21h
mov dl,bl
int 21h
mov ax,4c00h
int 21h
code ends
end start
data segment
msg1 db ' enter any two digit hexadecimal no. (<64h) : $'
msg2 db ' the equivalent bcd no. is : $'
msg3 db ' invalid entry or out of range$'
data ends
code segment
assume cs: code, ds: data
start: mov ax, data
mov ds, ax
xor bl, bl
loop3: shl bh, 01h
jc loop4
mov dl, 30h
jmp loop5
loop4: mov dl, 31h
loop5: mov ah, 02h
int 21h
inc bl
cmp bl, 08h
je loop6
cmp bl, 04h
jne loop3
mov dl, 20h
int 21h
jmp loop3
code ends
end start
;--------------------------------------------------------------------------
; program to convert hexadecimal no. to binary no.
;--------------------------------------------------------------------------
; programmed by indranil gupta (regn. no. 98011015)
; j:\tasm12\bin\hex_bin.asm (8086 program)
; dated : 30-10-2000.
;--------------------------------------------------------------------------
data segment
msg1 db ' enter any hexadecimal no. : $'
msg2 db ' the equivalent binary is : $'
msg3 db 'invalid entry made$'
hex_val db 5 dup (0)
data ends
code segment
assume cs:code , ds:data
start: mov ax, data
mov ds, ax ; initialize ds register
cmp al, 2fh ; to check that input character lies beyond 2fh
jl errormsg
cmp al, 66h ; to chech that input character lies before 66h
jg errormsg
cmp al, 40h ; to chech that input character lies after 3ah &
before 40h
jl errormsg
inc bx
cmp byte ptr [bx], 0dh ; continue until enter key is obtained
jne loop3
jmp loop9
;--------------------------------------------------------------------------
; end of program
;--------------------------------------------------------------------------
;-----------------------------------------------------------------------
; program to convert hexadecimal no. to binary no.
;-----------------------------------------------------------------------
; programmed by indranil gupta (regn. no. 98011015)
; j:\tasm12\bin\hex_dec.asm (8086 program)
; dated: 30-10-2000.
;-----------------------------------------------------------------------
data segment
msg1 db ' enter a two digit hexadecimal no. ( < 63h ) : $'
msg2 db ' the decimal equivalent is $'
data ends
code segment
assume cs:code , ds:data
start: mov ax, data
mov ds, ax
xor ax, ax
mov al, bh
aam
mov bx, ax
;-----------------------------------------------------------------------
; end of program
;-----------------------------------------------------------------------
val equ 0abh
_data segment
msg1 db ' the equivalent decimal is : $'
_data ends
_code segment
assume cs : _code , ds : _data , ss : _stack
start: mov ax, _data
mov ds, ax ; initialise ds register with segment
address of data
mov ax, _stack
mov ss, ax ; initialise ss register with segment
address of stack
lea sp, stack_top ; initialise stack pointer
write 0ah
write 0dh
print msg1
_code ends
end start
;---------------------------------------------------------------------------
; program to convert a hexadecimal no to decimal upto ( 65535d )
;---------------------------------------------------------------------------
; programmed by indranil gupta ( regn no 98011015 )
; c:\tasm\bin\indranil\hx_dc_l.asm ( 8086 program )
;---------------------------------------------------------------------------
_data segment
msg1 db ' the equivalent decimal no. is : $'
array db 5 dup (0)
_data ends
_code segment
assume cs : _code , ds : _data , ss : _stack
start: mov ax, _data
mov ds, ax ; initialise ds register with segment
address of data
mov ax, _stack
mov ss, ax ; initialise ss register with segment
address of stack
lea sp, stack_top ; initialise stack pointer
l2: dec si
mov ch, byte ptr [si]
or ch, 30h
write ch
dec cl
cmp cl, 00h
jne l2
_code ends
end start
;---------------------------------------------------------------------------
; end of program
;---------------------------------------------------------------------------
;-----------------------------------------------------------------------------
; program for insertion sorting of numbers
;-----------------------------------------------------------------------------
; programmed by indranil gupta ( regn. no. 98011015 )
; j:\tasm12\bin\indranil\inst_st.asm ( 8086 program )
;-----------------------------------------------------------------------------
_data segment
arry db maxi dup (0)
msg1 db 0ah,0dh,' enter the 2 digit no. of terms (max
10d) : $'
msg2 db 0ah,0dh,' make your entry (2 digits) : $'
msg3 db 0ah,0dh,' the sorted list in ascending order is :
$'
msg4 db 0ah,0dh,' overflow error$'
_data ends
_code segment
assume cs : _code , ds : _data , ss : _stack
start: mov ax, _data
mov ds, ax ; initialise ds register with segment
address of data
mov ax, _stack
mov ss, ax ; initialise ss register with segment
address of stack
lea sp, stack_top ; initialise stack pointer
print msg1
take_in cl ; cl contains the no. of terms
cmp cl, maxi
jle l0
print msg4
jmp last
_code ends
end start
;-----------------------------------------------------------------------------
; end of program
;-----------------------------------------------------------------------------
;-----------------------------------------------------------------------
; program to find the largest of n-2-digit nmbers
data segment
msg1 db ' enter any two digit no. of terms (in decimal): $'
msg2 db ' make a two digit unsigned entry : $'
msg3 db ' the largest is $'
msg4 db ' invalid input$'
terms db ?
i db ?
data ends
code segment
assume cs:code , ds:data
start: mov ax, data
mov ds, ax ; initialise ds register
print msg1 ; display msg1
read ; make entry of the no. of terms
cmp al, 30h
jl errormsg
cmp al, 39h
jg errormsg
mov bh, al
read
cmp al, 30h
jl errormsg
cmp al, 39h
jg errormsg
mov bl, al
and bx, 0f0fh ; masking higher nibble
mov ax, bx
aad ; convert unpacked bcd to binary in al
mov terms, al ; 'terms' contains the no. of terms
jmp loop0
write 0ah
write 0dh ; move cursor to next line
print msg3 ; display msg3
write bh ; display bx, the largest no.
write bl
;-----------------------------------------------------------------------
; end of program
;-----------------------------------------------------------------------
show macro x
push ax
push bx
mov al, x
aam
mov bx, ax
or bx, 3030h
write bh
write bl
pop bx
pop ax
endm
_data segment
msg1 db ' enter the first two digit no. : $'
msg2 db ' enter the second two digit no. : $'
msg3 db ' the hcf is : $'
msg4 db ' the lcm is : $'
; var1 db ?
; var2 db ?
_data ends
_code segment
assume cs : _code , ds : _data , ss : _stack
start: mov ax, _data
mov ds, ax ; initialise ds register with segment
address of data
mov ax, _stack
mov ss, ax ; initialise ss register with segment
address of stack
lea sp, stack_top ; initialise stack pointer
write 0ah
write 0dh
print msg2
make_entry bl
; mov var2 , bl
mov dx, bx
cmp bh, bl
jg loop1
mov cl, bl
mov bl, bh
mov bh, cl
; bh > bl
loop1: xor ax, ax
mov al, bh
div bl
mov bh, bl
mov bl, ah
cmp bl, 00h
jne loop1
write 0ah
write 0dh
print msg3
show bh
write 0ah
write 0dh
print msg4
xor ax, ax
mov al, dh
mul dl
div bh
show al
_code ends
end start
_data segment
msg1 db ' enter the no. of terms present (max 10) : $'
msg2 db ' make your entry : $'
msg3 db ' match found.$'
msg4 db ' match not found.$'
msg5 db ' enter the item to be searched : $'
msg6 db ' no. of items exceeds the limit$'
vars db maxi dup (0)
_data ends
; --------- stack segment ------------------------
_code segment
assume cs : _code , ds : _data , ss : _stack
start: mov ax, _data
mov ds, ax ; initialise ds register with segment
address of data
mov ax, _stack
mov ss, ax ; initialise ss register with segment
address of stack
lea sp, stack_top ; initialise stack pointer
xor cx, cx
make_entry cl ; cl contains the no. of terms
cmp cl, maxi
jg errormsg
write 0ah
write 0dh
write 0ah
jmp l1
make_entry bh
_code ends
end start
;---------------------------------------------------------------------------
;==========================
; program is not complete
;===========================
_data segment
msg1 db 0ah,0dh,' program to demonstrate linked list
operations :-$'
msg2 db 0ah,0dh,' the options are as :-$'
msg3 db 0ah,0dh,' enter 1 to create$'
msg4 db 0ah,0dh,' enter 2 to insert$'
msg5 db 0ah,0dh,' enter 3 to delete$'
msg6 db 0ah,0dh,' enter 4 to display$'
msg7 db 0ah,0dh,' enter 5 to exit$'
msg10 db 0ah,0dh,' enter 6 to search$'
msg8 db 0ah,0dh,' enter your option : $'
msg9 db 0ah,0dh,0ah,' enter the element to be inserted :
$'
msga db 0ah,0dh,' memory allocation error.(exit from
program)$'
msgb db 0ah,0dh,0ah,' do you wish to continue ( press 1 if
yes ) : $'
msgc db 0ah,0dh,' do you wish to insert another ( press 1
if yes ) : $'
msgd db 0ah,0dh,0ah,' the list is as :-$'
msge db 0ah,0dh,' search is successful$'
msgf db 0ah,0dh,' search is not successful$'
msgg db 0ah,0dh,' enter the item to be searched : $'
srh_el db 16 dup ('$')
lin db
0ah,0dh,0ah,'--------------------------------------------------------------$'
begin dw ?
_data ends
_code segment
assume cs : _code , ds : _data , ss : _stack
start: mov ax, _data
mov ds, ax ; initialise ds register with segment
address of data
mov ax, _stack
mov ss, ax ; initialise ss register with segment
address of stack
lea sp, stack_top ; initialise stack pointer
print msg1
l0: print lin
print msg2
print msg3
print msg4
print msg5
print msg6
print msg7
print msg10
print msg8
read cl
write 0ah
write 0dh
jmp ll1
ll0: jmp l0
ll1: cmp cl, 31h
jne l1
call cre
jmp l2
l1: cmp cl, 34h
jne l2
call disp
l2: cmp cl, 36h
jne l3
call srch
l3: write 0ah
print msgb
read cl
cmp cl, 31h
je ll0
last: mov ax, 4c00h
int 21h
print msg9
xor bx, bx
p1: read cl
cmp cl, 0dh
je p2
mov byte ptr [si+bx], cl
inc bl
jmp p1
perr2: jmp perr1
p2: mov byte ptr [si+bx], 24h
write 0ah
print msgc
read cl
cmp cl, 31h
jne p3
mov ah, 48h
mov bx, 0001h
int 21h
jc perr1
mov si, dx
add si, 000eh
mov byte ptr [si], ah
mov byte ptr [si+0001h], al
jmp p0
p3: mov si, dx
add si, 000eh
mov byte ptr [si], 00h
mov byte ptr [si+0001h], 00h
jmp p4
perr1: print msga
p4: pop si
pop dx
pop cx
pop bx
pop ax
ret
endp
_code ends
end start
;---------------------------------------------------------------------------
; end of program
;---------------------------------------------------------------------------
;---------------------------------------------------------------------------
_data segment
msg1 db 0ah,0dh,' program to demonstrate linked list
operations :-$'
msg2 db 0ah,0dh,' the options are :-$'
msg3 db 0ah,0dh,' enter 1 to create$'
msg4 db 0ah,0dh,' enter 2 to search an item$'
msg5 db 0ah,0dh,' enter 3 to display the list$'
msg6 db 0ah,0dh,' enter 4 to exit$'
msg7 db 0ah,0dh,' enter your option : $'
msg8 db 0ah,0dh,' make your entry : $'
msg9 db 0ah,0dh,' do you want to continue ( press y if yes )
$'
msga db 0ah,0dh,' do you want to insert ( press y if yes )
$'
msgb db 0ah,0dh,' enter the item to be searched : $'
msgc db 0ah,0dh,' search is successful $'
msgd db 0ah,0dh,' search is not successful $'
msge db 0ah,0dh,' the list is as follows :-$'
err1 db 0ah,0dh,' memory allocation error.$'
err2 db 0ah,0dh,' wrong option entered.$'
begin dw 0000h
s_itm db 14d dup (0)
_data ends
; --------- stack segment ------------------------
_code segment
assume cs : _code , ds : _data , ss : _stack
start: mov ax, _data
mov ds, ax ; initialise ds register with segment
address of data
mov ax, _stack
mov ss, ax ; initialise ss register with segment
address of stack
lea sp, stack_top ; initialise stack pointer
print msg1
l1: write 0ah
print msg2
print msg3
print msg4
print msg5
print msg6
print msg7
read dl
cmp dl, 31h
jne l2
call create
jmp l5
l11: jmp l1
l2: cmp dl, 32h
jne l3
print msgb
lea di, s_itm
s1: read dl
cmp dl, 0dh
je s2
mov byte ptr [di], dl
inc di
jmp s1
s2: mov byte ptr [di], '$'
call search
jmp l5
l3: cmp dl, 33h
jne l4
call disp
jmp l5
l4: cmp dl, 34h
je last
print err2
l5: print msg9
read dl
cmp dl, 'y'
je l11
last: mov ax, 4c00h
int 21h
_code ends
end start
;---------------------------------------------------------------------------
; end of program
;---------------------------------------------------------------------------
;---------------------------------------------------------------------------
_data segment
msg1 db 0ah,0dh,' program to demonstrate linked list
operations :-$'
msg2 db 0ah,0dh,' the options are :-$'
msg3 db 0ah,0dh,' enter 1 to create$'
msg4 db 0ah,0dh,' enter 2 to search an item$'
msg41 db 0ah,0dh,' enter 3 to insert an item$'
msg5 db 0ah,0dh,' enter 4 to display the list$'
msg6 db 0ah,0dh,' enter 5 to exit$'
msg7 db 0ah,0dh,' enter your option : $'
msg8 db 0ah,0dh,' make your entry : $'
msg9 db 0ah,0dh,' do you want to continue ( press y if yes )
$'
msga db 0ah,0dh,' do you want to insert ( press y if yes )
$'
msgb db 0ah,0dh,' enter the item to be searched : $'
msgc db 0ah,0dh,' search is successful $'
msgd db 0ah,0dh,' search is not successful $'
msge db 0ah,0dh,' the list is as follows :-$'
err1 db 0ah,0dh,' memory allocation error.$'
err2 db 0ah,0dh,' wrong option entered.$'
begin dw 0000h
s_itm db 14d dup (0)
_data ends
_code segment
assume cs : _code , ds : _data , ss : _stack
start: mov ax, _data
mov ds, ax ; initialise ds register with segment
address of data
mov ax, _stack
mov ss, ax ; initialise ss register with segment
address of stack
lea sp, stack_top ; initialise stack pointer
print msg1
l1: write 0ah
print msg2
print msg3
print msg4
print msg41
print msg5
print msg6
print msg7
read dl
cmp dl, 31h
jne l2
call create
jmp l5
l11: jmp l1
l2: cmp dl, 32h
jne l3
print msgb
lea di, s_itm
s1: read dl
cmp dl, 0dh
je s2
mov byte ptr [di], dl
inc di
jmp s1
s2: mov byte ptr [di], '$'
call search
jmp l6
l3: cmp dl, 33h
jne l6
call insert
jmp l6
l4: cmp dl, 34h
jne l6
call disp
jmp l6
l5: cmp dl, 35h
je last
print err2
l6: print msg9
read dl
cmp dl, 'y'
je l11
_code ends
end start
;---------------------------------------------------------------------------
; end of program
;---------------------------------------------------------------------------
;--------------------------------------------------------------------------
; program for matrix operations
;--------------------------------------------------------------------------
; programmed by indranil gupta ( regn no. 98011015 )
; j:\tasm\bin\matrix.asm ( 8086 program )
; dated : 30-11-2000.
;--------------------------------------------------------------------------
_data segment
fir_mat db 4 dup (0)
sec_mat db 4 dup (0)
msg1 db 0ah,0dh,' enter a element for first matrix :- $'
msg2 db 0ah,0dh,' enter a element for second matrix :- $'
msg3 db 0ah,0dh,' the resulting matrix is :-$'
msg4 db 0ah,0dh,' the various operations for 2 x 2 matrix
are :-$'
msg5 db 0ah,0dh,' enter 1 to add two 2x2 matrices.$'
msg6 db 0ah,0dh,' enter 2 to multiply two 2x2
matrices.$'
msg7 db 0ah,0dh,' enter 3 to transpose a 2x2
matrix.$'
msg8 db 0ah,0dh,' wrong choice entered. retry . . . $'
msg9 db 0ah,0dh,' do you wish to continue ( press 1 if yes
) : $'
msga db 0ah,0dh,' your option is : $'
msg00 db 0ah,0dh,' position (0,0) : $'
msg01 db 0ah,0dh,' position (0,1) : $'
msg10 db 0ah,0dh,' position (1,0) : $'
msg11 db 0ah,0dh,' position (1,1) : $'
_data ends
_code segment
assume cs : _code , ds : _data , ss : _stack
start: mov ax, _data
mov ds, ax ; initialise ds register with segment
address of data
mov ax, _stack
mov ss, ax ; initialise ss register with segment
address of stack
lea sp, stack_top ; initialise stack pointer
_code ends
end start
;-------------------------------------------------------------------------
; end of program
;-------------------------------------------------------------------------
;--------------------------------------------------------------------------
; program to change directory using command line arguments
;--------------------------------------------------------------------------
; programmed by indranil gupta ( regn. no. 98011015 )
; c:\tasm\bin\indranil\my_cd.asm ( 8086 program )
; dated : 22-11-2000.
;--------------------------------------------------------------------------
data segment
msg1 db ' invalid directory. $'
msg2 db ' required parameter missing. $'
dir_nm db 15 dup (0)
data ends
code segment
assume cs:code , ds:data
start: mov ax, data
mov ds, ax ; initialise ds register
code ends
end start
;--------------------------------------------------------------------------
; end of program
;--------------------------------------------------------------------------
;---------------------------------------------------------------------------
; program to delete a file using command line arguments
;---------------------------------------------------------------------------
; programmed by indranil gupta ( regn. no. 98011015 )
; c:\tasm\bin\indranil\my_del.asm ( 8086 program )
; dated : 22-11-2000.
;---------------------------------------------------------------------------
data segment
msg1 db 0ah,0dh,'file not found.$'
msg2 db 0ah,0dh,'required parameter missing - $'
filename db 15 dup (0)
data ends
code segment
assume cs:code , ds:data
start: mov ax, data
mov ds, ax ; initialise ds register
mov ah, 62h
int 21h
mov byte ptr [si], '.' ; insert '.' after the filename
inc si
code ends
end start
;---------------------------------------------------------------------------
; end of program
;---------------------------------------------------------------------------
;---------------------------------------------------------------------------
; program to delete a file using command line arguments
;---------------------------------------------------------------------------
; programmed by indranil gupta ( regn. no. 98011015 )
; c:\tasm\bin\indranil\my_del.asm ( 8086 program )
; dated :
;---------------------------------------------------------------------------
_data segment
msg2 db ' file not found.$'
msg1 db ' required parameter missing$'
buffer db 85 dup (0)
filenm db 15 dup (0)
_data ends
_code segment
assume cs : _code , ds : _data , ss : _stack , es : _data
start: mov ax, _data
mov ds, ax ; initialise ds register with segment
address of data
mov ax, _stack
mov ss, ax ; initialise ss register with segment
address of stack
mov ax, _data
mov es, ax
lea sp, stack_top ; initialise stack pointer
mov ds, bx
mov si, offset ctail
mov di, seg buffer
mov es, di
mov di, offset buffer
mov cl, byte ptr [si]
mov dh, cl
cmp dh, 00h
je errmsg1
inc cl
xor ch, ch
xor si, si
cld
rep movsb
mov cl, dh
xor ch, ch
mov di, offset buffer
add di, offset 006dh
l1: mov bl, byte ptr [di]
cmp bl, 20h
je l2
mov byte ptr [si], bl
inc si
l2: inc di
inc ch
cmp ch, cl
jne l1
mov byte ptr [si], 00h
_code ends
end start
;---------------------------------------------------------------------------
; end of program
;---------------------------------------------------------------------------
data segment
buffer db 50 dup (?)
filename db '*.*',0
msg db 0ah,0dh,'invalid switch$'
data ends
code segment
assume cs: code , ds: data
start : mov ax, data
mov ds , ax
code ends
end start
;--------------------------------------------------------------------------
; program to create new sub-directory using command line arguments
;--------------------------------------------------------------------------
; programmed by indranil gupta ( regn. no. 98011015 )
; c:\tasm\bin\indranil\my_md.asm ( 8086 program )
; dated : 22-11-2000.
;--------------------------------------------------------------------------
data segment
msg1 db ' invalid directory. $'
msg2 db ' required parameter missing. $'
dir_nm db 15 dup (0)
data ends
code segment
assume cs:code , ds:data
start: mov ax, data
mov ds, ax ; initialise ds register
code ends
end start
;--------------------------------------------------------------------------
; end of program
;--------------------------------------------------------------------------
;--------------------------------------------------------------------------
; program to remove directory using command line arguments
;--------------------------------------------------------------------------
; programmed by indranil gupta ( regn. no. 98011015 )
; c:\tasm\bin\indranil\my_rd.asm ( 8086 program )
; dated : 22-11-2000.
;--------------------------------------------------------------------------
data segment
msg1 db ' invalid directory or directory not empty. $'
msg2 db ' required parameter missing. $'
dir_nm db 15 dup (0)
data ends
code segment
assume cs:code , ds:data
start: mov ax, data
mov ds, ax ; initialise ds register
code ends
end start
;--------------------------------------------------------------------------
; end of program
;--------------------------------------------------------------------------
;---------------------------------------------------------------------------
; program to rename a file using command line arguments
;---------------------------------------------------------------------------
; programmed by indranil gupta ( regn. no. 98011015 )
; c:\tasm\bin\indranil\my_ren.asm ( 8086 program )
; dated : 22-11-2000.
;---------------------------------------------------------------------------
data segment
fl_old db 15 dup (0)
fl_new db 15 dup (0)
msg1 db ' required parameter missing. $'
msg2 db ' file not found. $'
data ends
code segment
assume cs:code , ds:data
start: mov ax, data
mov ds, ax ; initialise ds register
code ends
end start
;---------------------------------------------------------------------------
; end of program
;---------------------------------------------------------------------------
;-----------------------------------------------------------------------------
; program to type the contents of a file to the screen
;-----------------------------------------------------------------------------
; programmed by indranil gupta ( regn. no 98011015 )
; j:\tasm12\bin\indranil\my_type.asm ( 8086 program )
; dated : 27-11-2000.
;-----------------------------------------------------------------------------
data segment
msg1 db ' file not found $'
msg2 db ' required parameter missing. $'
fil_nm db 15 dup (0)
buffer db ?
fhan dw ?
data ends
code segment
assume cs:code , ds:data
start: mov ax, data
mov ds, ax ; initialise ds register
mov byte ptr [si], '.' ; insert '.' after the filename
inc si
;-----------------------------------------------------------------------------
; end of program
;-----------------------------------------------------------------------------
_data segment
msg1 db 0ah,0dh,' file not found.$'
buffer db 80 dup (0)
filenm db 15 dup (0)
_data ends
_code segment
assume cs : _code , ds : _data , ss : _stack , es : _data
start: mov ax, _data
mov ds, ax ; initialise ds register with segment
address of data
mov ax, _stack
mov ss, ax ; initialise ss register with segment
address of stack
mov ax, _data
mov es, ax
lea sp, stack_top ; initialise stack pointer
write 0ah
write 0dh
mov ds, bx
mov si, offset ctail
mov di, seg buffer
mov es, di
mov di, offset buffer
mov cl, byte ptr [si]
mov dh, cl
inc cl
xor ch, ch
xor si, si
cld
rep movsb
mov cl, dh
xor ch, ch
mov di, offset buffer
add di, offset 006dh
l1: mov bl, byte ptr [di]
cmp bl, 20h
je l2
mov byte ptr [si], bl
inc si
l2: inc di
inc ch
cmp ch, cl
jne l1
mov byte ptr [si], 00h
_code ends
end start
data segment
buffer db 50 dup (?)
filename db '*.*',0
data ends
code segment
assume cs: code , ds: data
start : mov ax, data
mov ds , ax
mov ah , 1ah
mov dx, offset buffer
int 21h
code ends
end start
maxi equ 07h
print macro x
mov ah, 09h
mov dx, offset x
int 21h
endm
read macro
mov ah, 01h
int 21h
endm
write macro x
mov ah, 02h
mov dl, x
int 21h
endm
data segment
msg1 db ' enter any octal no. (max 7 digits) : $'
msg2 db ' the binary equivalent is $'
msg3 db ' invalid entry$'
octal db maxi dup (0)
data ends
code segment
assume cs:code , ds:data
start: mov ax, data
mov ds, ax
print msg1
xor cl, cl
lea si, octal
loop1: read
cmp al, 0dh
je loop2
cmp al, 20h
je loop1
cmp al, 30h
jl errormsg
cmp al, 37h
jg errormsg
mov [si], al
inc si
inc cl
cmp cl, maxi
jne loop1
;------------------------------------------------------------------------
; program to convert a octal no. to its decimal
;------------------------------------------------------------------------
; programmed by indranil gupta ( regn. no. 98011015 )
; c:\tasm\bin\indranil\oct_dec.asm ( 8086 program )
; dated : 30-10-2000.
;------------------------------------------------------------------------
code segment
assume cs:code , ds:data
start: mov ax, data
mov ds, ax ; initialise ds register
print msg1
xor cl, cl
lea si, octal
loop1: read ; read the inputs
cmp al, 0dh
je l1
cmp al, 20h
je loop1
cmp al, 30h
jl errormsg
cmp al, 37h
jg errormsg
mov byte ptr [si], al ; store the data in array octal
inc si
inc cl
cmp cl, 03h
jne loop1
sub si, 0003h
cmp byte ptr [si], 31h
jg errormsg
jmp l1
write 0ah
write 0dh ; move cursor to next line
print msg2
write ch
write cl
write 64h
;------------------------------------------------------------------------
; end of program
;------------------------------------------------------------------------
code segment
assume cs:code ,ds:data
begin : mov ax,data
mov ds,ax
mov dx,offset msg1
mov ah,09h
int 21h
mov si,offset deci
xor cl,cl
entry : inc cl
mov ah,01h
int 21h
sub al,30h
mov [si],al
inc si
cmp cl,02h
jne entry
mov ah,09h
mov dx,offset msg2
int 21h
xor ax,ax
aam
xor bx,bx
; mov cl,03h
mov bl,al
mov bh,ah
; shr bh,cl
add bh,30h
; and bl,00000111b
add bl,30h
mov ah,02h
mov dl,bh
int 21h
mov dl,bl
int 21h
mov ax,4c00h
int 21h
code ends
end begin
code segment
assume cs:code ,ds:data
begin : mov ax,data
mov ds,ax
mov dx,offset msg1
mov ah,09h
int 21h
mov si,offset deci
xor cl,cl
entry : inc cl
mov ah,01h
int 21h
sub al,30h
mov [si],al
inc si
cmp cl,02h
jne entry
mov ah,09h
mov dx,offset msg2
int 21h
xor ax,ax
aam
xor bx,bx
; mov cl,03h
mov bl,al
mov bh,ah
; shr bh,cl
add bh,30h
; and bl,00000111b
add bl,30h
mov ah,02h
mov dl,bh
int 21h
mov dl,bl
int 21h
mov ax,4c00h
int 21h
code ends
end begin
print1 macro rr
mov ah,02h
mov dl,rr
int 21h
endm
data segment
msg1 db "enter the string = $"
msg2 db "its a palindrome $"
msg3 db "its not a palindrome $"
user_stack db 20 dup(?)
data ends
code segment
assume cs:code,ds:data
input: input_data
mov [si],al
inc si
inc cl
cmp al,0dh
jne input
dec si
compare: inc ch
mov ah,[si]
mov al,[di]
print1 ah
print1 al
cmp ah,al
jne loop2
dec si
inc di
jmp compare
loop2: better_display
print msg3
jmp last
loop3: better_display
print msg2
code ends
end start