;buble sort maxi equ 10d ; macro to read a character in bl

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 make_entry macro push ax push dx read mov dh, bl read mov dl, bl and dx, 0f0fh mov ax, dx aad pop dx mov x, al pop ax endm 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 x

; macro to write a chararacter x

; macro to display a string

; x cannot be any of ah or al

endm

;

-------------

data

segment

-----------------------$' $'

_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 ; --------stack segment ------------------------

_stack segment stack dw 80 dup (0) stack_top label word _stack ends ; ----------code segment -------------------------

start: address of data address of stack

_code segment assume cs : _code , ds : _data , ss : _stack mov ax, _data mov ds, ax ; initialise ds register with segment mov ax, _stack mov ss, ax lea sp, stack_top print msg1 xor cx, cx make_entry cl ; initialise ss register with segment ; initialise stack pointer ; display msg1 ; cl contains the no. of terms

loop1:

mov ch, 00h lea si, vars write 0ah write 0dh print msg2 make_entry bh mov byte ptr [si], bh inc ch inc si cmp ch, cl jne loop1 cmp cl, maxi jg errormsg lea mov xor jmp si, vars var1, cl dl, dl loop2

; entries been made

errormsg:

print msg4 jmp last mov bh, var1 mov var2, bh xor bx, bx dec var2 mov ah, byte mov al, byte cmp ah, al jl loop4 mov byte ptr mov byte ptr inc bl cmp bl, var2 jne loop3 inc dl cmp dl, var1 jne loop2 write 0ah write 0dh print msg3 lea si , vars xor ch, ch mov bl, byte ptr [si] show bl write 20h inc si inc ch cmp ch, cl jne loop5

loop2:

loop3:

ptr [si+bx] ptr [si+bx+0001h] [si+bx], al [si+bx+0001h], ah

loop4:

loop5:

last:

mov ax, 4c00h int 21h _code ends end start

; program to design a two digit calculator(+,-,*,/)for single digit number. print macro msg mov ah,09h mov dx,offset msg int 21h endm data segment msg1 db "enter the expression = $"

msg2 db "the result = ends data code segment assume cs:code,ds:data start : mov ax,data mov ds,ax print msg1 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 plus : mov ah,01h int 21h sub al,30h add bh,al or bh,30h mov ah, 02h mov dl, 0ah int 21h mov dl, 0dh int 21h print msg2 mov mov int jmp ah,02h dl,bh 21h last

$"

minus: mov ah,01h int 21h sub al,30h sub bh,al or bh,30h mov ah, 02h mov dl, 0ah int 21h mov dl, 0dh int 21h print msg2 mov mov int jmp ah,02h dl,bh 21h 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 mov ah, 0fh int 10h mov bl, bh mov mov mov mov mov mov mov int dl, ah, al, bh, ch, cl, dh, 10h ah 06h 00h attri 00h 00h 19h

start:

; get current video mode ; active display page ; ; ; ; ; ; ; ; ; no. of character cols. on screen interrupt function no. zero as whole screen is to be blanked attribute in the specified region top left y co-ordinate top left x co-ordinate bottom right y co-ordinate interrupt to scroll window up ( using int 10h ( function 06h) )

mov mov mov mov int

ah, bh, dh, dl, 10h

02h bl 18h 00h

; ; ; ; ;

function no. to set cursor active display page top left y co-ordinate top left x co-ordinate interrupt to set cursor ( int 10h(02h) )

mov ah, 01h int 21h mov ax, 4c00h int 21h code ends

; to prompt the user to press any key ; terminate process

end start

;---------------------------------------------------------------------; 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 mov ah, 0fh int 10h mov bl, bh mov mov mov mov mov mov mov int mov mov mov mov int dl, ah, al, bh, ch, cl, dh, 10h ah, bh, dh, dl, 10h ah 06h 00h attri 00h 00h 19h

start:

; get current video mode ; active display page ; ; ; ; ; ; ; ; ; ; ; ; ; ; no. of character cols. on screen interrupt function no. zero as whole screen is to be blanked attribute in the specified region top left y co-ordinate top left x co-ordinate bottom right y co-ordinate interrupt to scroll window up ( using int 10h ( function 06h) ) function no. to set cursor active display page top left y co-ordinate top left x co-ordinate interrupt to set cursor ( int 10h(02h) )

02h bl 18h 00h

mov ah, 01h int 21h mov ax, 4c00h int 21h code ends end start

; to prompt the user to press any key ; terminate process

;---------------------------------------------------------------------; end of program ;----------------------------------------------------------------------

;-----------------------------------------------------------------------; program to clear a specified portion of the screen ;-----------------------------------------------------------------------attri equ 02h ; attribute of specified portion ; macro to display a string

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 take_val macro its binary in al read mov dh, al read mov dl, al mov ax, dx and ax, 0f0fh aad endm data segment msg1 db msg2 msg3 msg4 db db db

; macro to read a character

; macro to write a character

; macro to input a two digit no. and place

$' $' digits) : $' digits) : $'

' ' ' ' '

enter the top left x co-ordinate ( 2 digits) : enter the top left y co-ordinate ( 2 digits) : enter the bottom right x co-ordinate ( 2 enter the bottom right y co-ordinate ( 2 invalid entry made$'

msg5 db data ends

start:

code segment assume cs : code , ds : data mov ax, data mov ds, ax ; initialise ds register

print msg1 take_val cmp al, 50h jg errormsg mov cl, al write 0ah write 0dh print msg2 take_val cmp al, 19h jg errormsg mov ch, al jmp loop0 errormsg: loop0: print msg5 jmp last write 0ah write 0dh print msg3 take_val cmp al, 50h jg errormsg mov bh, al write 0ah write 0dh print msg4 take_val cmp al, 19h jg errormsg mov dh, al mov dl, bh mov mov sub mov int last: end start ah, al, al, bh, 10h 06h dh ch attri

; display msg1 ; input the top left x co-ordinate ; al should be less than 80d (i.e. 50h) ; top left x co-ordinate ; ; ; ; move cursor to next line display msg2 input the top left y co-ordinate al should be less than 25d (i.e. 19h)

; top left y co-ordinate

; ; ; ;

move cursor to next line display msg3 input the bottom right x co-ordinate al should be less than 80d (i.e. 50h)

; ; ; ;

move cursor to next line display msg4 input the bottom right y co-ordinate al should be less than 25d (i.e. 19h)

; bottom right y co-ordinate ; bottom right x co-ordinate ; interrupt function no. ; no. of lines to scroll ( al = dh-ch ) ; attribute used in specified area ; interrupt call ; terminate with return code

mov ax, 4c00h int 21h code ends

;----------------------------------------------------------------------------; program to delete file (using 21h, function 41h) ;----------------------------------------------------------------------------; programmed by indranil gupta (regn. no. 98011015) ; j;\tasm12\del_file.asm ;----------------------------------------------------------------------------_data segment ; data segment begins here

file_name msg1 msg2 _data ends

db db db

'new.txt',0 'successful$' 'not successful$'

; name of file to be deleted ; messages ; end of data segment ; code segment begins here

_code segment assume cs:_code, ds:_data start: mov ax,_data mov ds, ax mov dx, offset file_name mov ah, 41h int 21h jc errmsg mov dx, offset msg1 jmp last errmsg: mov dx, offset msg2 last: mov ah, 09h message int 21h mov ax,4c00h program int 21h

; ;

call of interrupt to delete file int 21h, function 41h

; ;

call of interrupt to display int 21h, function 09h

; call of interrupt to terminate

_code ends end start

;

code segment ends here

;----------------------------------------------------------------------------; 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 ;------------------------------------------------------------------------; programmed by indranil gupta (regn no. 98011015) ; j:\tasm12\bin\dis_asc.asm ( 8086 program) ; dated : 23-10-2000. ;------------------------------------------------------------------------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 mov ax, data mov ds, ax mov ah, 09h mov dx, offset msg1 int 21h mov ah, 01h int 21h mov bl, al mov mov int mov int ah, 02h dl, 0ah 21h dl, 0dh 21h

start:

; initialise ds register

; display message to enter character ; read character from console

; to insert a new line character

mov ah, 09h mov dx, offset msg2 int 21h mov al, bl and bl, 0fh cmp bl, 0ah jge pos1 or bl, 30h jmp pos2 pos1: pos2: sub bl, 09h or bl, 40h and al, 0f0h ror al, 04h or al, 30h mov ah, 02h mov dl,al int 21h mov dl,bl

; to display message 2 ; masking lower nibble of bl

; masking higher nibble of al

code

; displaying first hex character of hex

int 21h code mov ax, 4c00h int 21h code ends end start

; displaying next hex character of hex ; terminate program

;------------------------------------------------------------------------; end of program ;-------------------------------------------------------------------------

;--------------------------------------------------------------------------; program to display the ascii graphic character of hex no. ;--------------------------------------------------------------------------; programmed by indranil gupta ;--------------------------------------------------------------------------data segment msg1 db msg2 db msg3 db data ends

:

$'

0ah,0dh,' 0ah,0dh,' 0ah,0dh,'

enter the two digit hex code (0-9,a-f) the equivalent character is error in input$' : $'

start:

code segment assume cs:code , ds:data mov ax, data mov ds, ax mov ah, 09h mov dx, offset msg1 int 21h mov int mov int mov ah, 01h 21h bh, al 21h bl, al 30h 39h 0fh 61h 66h

l1:

cmp bh, jl err1 cmp bh, jg l1 and bh, jmp l2 cmp bh, jl err1 cmp bh, jg err1

sub bh, 57h l2: cmp bl, jl err1 cmp bl, jg l3 and bl, jmp l4 cmp bl, jl err1 cmp bl, jg err1 sub bl, 30h 39h 0fh 61h 66h 57h

l3:

l4:

shl bh, 04h or bh, bl mov mov int mov mov int jmp ah, 09h dx, offset msg2 21h ah, 02h dl, bh 21h last

err1:

mov ah, 09h mov dx, offset msg3 int 21h mov ax, 4c00h int 21h code ends end start

last:

;--------------------------------------------------------------------------; 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. ;--------------------------------------------------------------------print macro x mov ah, 09h mov dx, offset x int 21h endm ; macro to display a string

read endm

macro mov ah, 01h int 21h

; macro to read a character

write macro x mov ah, 02h mov dl, x int 21h endm data segment msg1 db msg2 db msg3 db msg4 db data ends ' ' ' '

; macro to write a character

enter any two digit decimal no. the no. is even.$' the no. is odd.$' invalid input$'

:

$'

start:

code segment assume cs:code , 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

ds:data

and bx, 0f0fh mov ax, bx aad mov bl, 02h div bl cmp ah, 00h je loop1 print msg3 jmp loop2 loop1: print msg2 jmp loop2 errormsg: print msg4 loop2: mov ax, 4c00h int 21h code ends end start

;--------------------------------------------------------------------; end of program ;---------------------------------------------------------------------

; name : dipendra shrestha ; roll : 10 ; program to check whether an input no is even or odd print macro msg mov ah,09h mov dx,offset msg int 21h endm better_display macro mov ah,02h mov dl,0ah int 21h mov dl,0dh int 21h endm ;macro for displaying message

;code for better display

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 start : mov ax,data mov ds,ax print msg1 mov int mov int mov ah,01h 21h bh,al 21h bl,al

and bx,0f0fh better_display mov ax,bx mov bl,02h div bl cmp ah,0h je iseven print msg3 jmp last iseven : print msg2 jmp last

last

: mov ax,4c00h int 21h

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. ;-------------------------------------------------------------------print macro x mov ah, 09h mov dx, offset x int 21h endm read endm macro mov ah, 01h int 21h ; macro to print a message x

; macro to read a character

write macro x mov ah, 02h mov dl, x int 21h endm data segment msg1 db ' msg2 db ' msg3 db ' var1 db data ends code segment assume cs:code , mov ax, data mov ds, ax print msg1 read cmp al, 30h jl errormsg cmp al, 38h jg errormsg mov var1, al

; macro to write a character

enter any single digit decimal no. < 9 the factorial in hex is $' invalid input or out of range$' ?

:

$'

ds:data ; initialise ds

start:

; read a character

and var1, 0fh write 0ah write 0dh print msg2 xor mov mov dec ax, ax al, var1 cx, ax cx

; move cursor to new line

; cx <- ax

cmp var1, 01h jg loop1 write 31h jmp loop6 loop1: mul dec cmp jne xor mov xor xor shl rcl inc cmp jne cx cx cx, 0000h loop1 cx, cx bx, ax cl, cl dh, dh bx, 01h dh, 01h cl cl, 04h loop3

; if entered value is 0 or 1 display 1

; ax

<-

ax * cx

; bx contains the factorial ; shift msb of bx to carry bit ; rotate dh left through carry bit

loop2: loop3:

loop4: loop5:

cmp dh, 0ah jg loop4 add dh, 30h jmp loop5 add dh, 37h write dh inc ch cmp ch, 04h jne loop2 write 68h jmp loop6

; displayed value lies between 0 to 9 ; displayed value lies between a to f

; append the result with character h

errormsg: print msg3 loop6: mov ax, 4c00h int 21h code ends end start

; terminate process

;-------------------------------------------------------------------; 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 msg2 db msg3 db _data ends

' enter the number ( < 9 ) : $' ' the factorial in hex is : $' ' invalid input or out of range$'

_stack segment stack dw 30 dup (0) stack_top label word _stack ends _code segment assume cs : _code mov ax, _data mov ds, ax mov ax, _stack , ds : _data , ss : _stack

start:

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 errormsg : l0: print msg3 jmp last write 0ah write 0dh print msg2 xor ax, ax mov ax, 0001h call fact mov bl, ah call show mov bl, al call show write 'h' jmp last fact proc near cmp cx, 0000h je l1 mul cx dec cx call fact l1: ret endp proc near mov bh, bl and bh, 0f0h shr bh, 04h cmp bh, 0ah jl l2 add bh, 37h jmp l3 add bh, 30h write bh mov bh, bl and bh, 0fh

show

l2: l3:

cmp bh, 0ah jl l4 add bh, 37h jmp l5 l4: add bh, 30h l5: write bh ret endp

last:

mov ax, 4c00h int 21h _code ends end start

;------------------------------------------------------------------------; end of program ;-------------------------------------------------------------------------

; name : dipendra shrestha ; roll : 10 ; program to generate the fibonacci series print macro msg mov ah,09h mov dx,offset msg int 21h endm ;macro definition for diaplaying message

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 start : mov ax,data mov ds,ax print msg1 mov int and mov mov mov int mov ah,01h 21h al,0fh n,al ah,02h dl,0ah 21h dl,0dh ;code for better display

int 21h print msg2 mov mov mov mov mov mov int mov int cl,00h bl,00h bh,01h ch,01h ah,02h dl,30h 21h dl,31h 21h

loop1: mov ah,02h or ch,30h mov dl,ch int 21h mov var,ch mov ch,00h mov bl,bh mov bh,var mov ch,bh and bl,0fh add ch,bl inc cl cmp cl,n jne loop1 last : mov ax,4c00h int 21h code ends end start ;terminating the program

print

macro x mov ah, 09h mov dx, offset x int 21h macro mov ah, 01h int 21h

endm read 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 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 and bx, 0f0fh mov ax, bx aad cmp al, 01h jl loop2 cmp al, 0bh jg errormsg mov bl, al jmp loop0 errormsg: print msg3 jmp loop2 loop0: write 0ah write 0dh print msg2 xor cl, cl mov bh, 00h mov dh, 01h write 30h write 31h write 20h dec bl cmp bl, 01h jl loop2 mov ch, bh add ch, dh mov al, ch aam or ax, 3030h mov var1, ah

start:

loop1:

mov var2, al write var1 write var2 write 20h mov bh, dh mov dh, ch inc cl cmp cl, bl jne loop1 loop2: mov ax, 4c00h int 21h 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 dstfile fhan1 fhan2 buffer msg1 msg2 data ends

db db dw dw db db db

'abc.txt',0 'xyz.txt',0 ? ? 100 dup (0) 'successful$' 'not successful$'

; source file ; destination file ; file handlers

start:

code segment assume cs:code , mov ax, data mov ds, ax

ds:data ; initialize ds register

mov ah, 3dh mov al, 80h mov dx, offset srcfile int 21h jc errormsg mov fhan1, ax mov ah, 3dh mov al, 81h mov dx, offset dstfile

; open srcfile in reading mode

int 21h jc errormsg mov fhan2, ax mov ah, 3fh mov bx, fhan1 mov cx, 100 mov dx, offset buffer int 21h jc errormsg mov cx, ax mov ah, 40h mov bx, fhan2 mov dx, offset buffer int 21h jc errormsg mov ah, 3eh mov bx, fhan1 int 21h jc errormsg mov ah, 3eh mov bx, fhan2 int 21h jc errormsg mov jmp mov mov int dx, offset msg1 last dx, offset msg2 ah, 09h 21h

; open dstfile in writing mode

; read the contents of first file

; write the contents of second file

; close srcfile

; close dstfile

errormsg: last:

; display message ; terminate process

mov ax, 4c00h int 21h code ends end start

;---------------------------------------------------------------------; 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 ) ;--------------------------------------------------------------------------read macro mov ah, 01h int 21h endm ; macro to read a character in al

write macro x mov dl, x mov ah, 02h int 21h endm print mov mov int endm macro x dx, offset x ah, 09h 21h

; macro to write a chararacter x

; macro to display a string

:

$'

data segment filename msg1 db msg2 db msg3 msg4 db db db db db db db db db db db

db 15 dup (0) 0ah,0dh,' enter 1 to set file attributes $' 0ah,0dh,' or any other key to set file attributes 0ah,0dh,' 0ah,0dh,' 0ah,0dh,' 0ah,0dh,' 0ah,0dh,' enter the file name : $' enter the no. of attributes you want to the file attributes are : enter $' enter the attribute to be set $' : $'

have : $'

msg5 msg6 msg7 msgr msgh msgs msgv msga err1 data ends

' read only $' ' hidden $' ' system $' ' volume label $' ' normal ( archive ) $' 0ah,0dh,' invalid file name$'

start:

code segment assume cs:code , ds:data mov ax, data mov ds, ax print msg1 print msg2 read mov cl, al print msg3 lea si, filename read cmp al, 0dh je l2 mov byte ptr [si], al inc si jmp l1 mov byte ptr [si], 00h cmp cl, 31h je l7 mov ah, 43h mov al, 00h mov dx, offset filename

l1:

l2:

l3:

l4:

l5:

l6:

errmsg: last: l7:

int 21h jc errmsg mov bl, cl print msg5 and cl, 01h cmp cl, 00h je l3 print msgr mov cl, bl and cl, 02h cmp cl, 00h je l4 print msgh mov cl, bl and cl, 04h cmp cl, 00h je l5 print msgs mov cl, bl and cl, 08h cmp cl, 00h je l6 print msgv mov cl, bl and cl, 20h cmp cl, 00h je last print msga jmp last print err1 mov ax, 4c00h int 21h print print write print print write print print write print print write print print write print msg5 msg6 'r' msgr msg6 'h' msgh msg6 's' msgs msg6 'v' msgv msg6 'n' msga

print msg4 read mov cl, al and cl, 0fh print msg7 xor ch, ch xor bl, bl

l8:

l9:

la:

lb:

lc: ld:

read cmp al, 'r' jne l9 or bl, 01h jmp ld cmp al, 'h' jne la or bl, 02h jmp ld cmp al, 's' jne lb or bl, 04h jmp ld cmp al, 'v' jne lc or bl, 08h jmp ld or bl, 20h inc ch cmp ch, cl jne l8 mov ah, 43h mov al, 01h xor cx, cx mov cl, bl mov dx, offset filename int 21h jnc lf print err1 mov ax, 4c00h int 21h code ends end start

lf:

;--------------------------------------------------------------------------; end of program ;---------------------------------------------------------------------------

;name : dipendra shrestha ;roll no : 10 ;program to transfer the contents of the source file to destination file print macro message mov ah,09h mov dx,offset message int 21h endm data segment source db 80 dup(0) dest db 80 dup(0) recsize equ 512 rdcount dw ? ;macro for displaying message

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 main : mov ax,data mov ds,ax print msg1; accept source file name mov si,offset source loop1 : mov ah,01h int 21h cmp al,0dh je done1 mov [si],al inc si jmp loop1 done1 :print msg2 ;accept dest file name mov si,offset dest loop2 : mov ah,01h int 21h cmp al,0dh je done2 mov [si],al inc si jmp loop2 done2 : ;open source in read mode mov ah,3dh mov al,00 mov dx,offset source int 21h jc file_error mov handle1,ax ;further used to access file ;create dest file mov ah,3ch mov cx,00 ;normal mov dx,offset dest int 21h jc file_error mov handle2,ax read_file: ;read source file mov ah,3fh mov bx,handle1 mov cx,recsize ;(whole sector) n. of byte to be read mov dx,offset buff int 21h jc file_error mov rdcount,ax ;no of character read ax=0 eof mov ah,40h mov bx,handle2

mov cx,rdcount mov dx,offset buff int 21h jc file_error mov ah,09h mov dx,offset success_msg int 21h cmp cx,recsize je read_file file_end : mov mov int mov mov int jmp ah,3eh bx,handle1 21h ah,3eh dx,handle2 21h quit

file_error: ;display error message mov dx,offset error_msg mov ah,09h int 21h quit : mov ax,4c00h int 21h text ends end main ; name : dipendra shrestha ; roll : 10 ; program to convert a hexadecimal no. into a decimal no. print macro msg mov ah,09h mov dx,offset msg int 21h endm ; macro for displaying message

data segment msg1 db "enter the hexadecimal no = $" msg2 db "its decimal equivalent = $" data ends code segment assume cs:code,ds:data start : mov ax,data mov ds,ax print msg1 mov int mov int mov ah,01h 21h bh,al 21h bl,al ;inputting the headecimal no.

mov mov int mov int

ah,02h dl,0ah 21h dl,0dh 21h

;code for better display

print msg2 cmp bh,3ah jg l1 sub bh,30h jmp l2 l1 : l2 : sub bh,37h cmp bl,3ah jg l3 sub bl,30h jmp l4 sub bl,37h shl bh,04h or bh,bl xor ax,ax mov al,bh aam mov bx,ax or bx,3030h mov mov int mov int mov ax,4c00h int 21h code ends end start data segment msg1 db ' msg2 db ' msg3 db ' data ends enter any two digit hexadecimal no. (<64h) : $' the equivalent bcd no. is : $' invalid entry or out of range$' ah,02h dl,bh 21h dl,bl 21h

l3 : l4 :

start:

code segment assume cs: code, ds: data mov ax, data mov ds, ax mov ah, 09h mov dx, offset msg1 int 21h

mov int mov int mov mov mov int mov int

ah, 01h 21h bh, al 21h bl, al ah, 02h dl, 0ah 21h dl, 0dh 21h

cmp bh, 36h jg errormsg loop1: and bh, 0fh cmp bl, 3ah jl loop2 sub bl, 37h and bl, 0fh shl bh, 04h or bh, bl mov al, bh cmp al, 63h jg errormsg aam mov bx, ax cmp bh, 00h jl errormsg cmp bh, 09h jg errormsg cmp bl, 00h jl errormsg cmp bl, 09h jg errormsg shl bh, 04h or bh, bl mov ah, 09h mov dx, offset msg2 int 21h loop3: xor bl, bl shl bh, 01h jc loop4 mov dl, 30h jmp loop5 mov dl, 31h mov ah, 02h int 21h inc bl cmp bl, 08h je loop6 cmp bl, 04h jne loop3

loop2:

loop4: loop5:

mov dl, 20h int 21h jmp loop3

errormsg: mov ah, 09h mov dx, offset msg3 int 21h loop6: mov ax, 4c00h int 21h 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. ;--------------------------------------------------------------------------

dis_char mov add mov int endm

macro x dl, 30h dl, x ah, 02h 21h

;

macro to display character x

data segment msg1 msg2 msg3 hex_val data ends

db ' enter any hexadecimal no. : $' db ' the equivalent binary is : $' db 'invalid entry made$' db 5 dup (0)

start:

code segment assume cs:code , ds:data mov ax, data mov ds, ax ; initialize ds register mov ah, 09h mov dx, offset msg1 int 21h xor cx, cx lea bx, hex_val

; display initial message ; clear cx ; initialise bx with offset of an array

loop1:

mov ah, 01h int 21h mov byte ptr [bx], al inc bx inc cx cmp al, 0dh je loop2 cmp al, 2fh jl errormsg cmp al, 66h jg errormsg cmp al, 3ah jl loop1

; reading the hexadecimal input

; terminate input of pressing enter key ; to check that input character lies beyond 2fh ; to chech that input character lies before 66h

; character lies between 0 to 9 ; to chech that input character lies after 3ah &

before 40h

cmp al, 40h jl errormsg cmp al, 47h jl loop1 cmp al, 60h jl errormsg jmp loop1

; character lies between a to f ; to chech that input character lies after 47h & ; character lies between a to f

before 60h

loop2:

sub bx, cx mov mov int mov int ah, 02h dl, 0ah 21h dl, 0dh 21h

; move cursor to next line

mov ah, 09h mov dx, offset msg2 int 21h loop3:

; display message

cmp byte ptr [bx], 3ah ; jg loop4 and byte ptr [bx], 0fh jmp loop5 and byte ptr [bx], 0fh add byte ptr [bx], 09h rol byte ptr [bx], 04h xor cx, cx shl byte ptr [bx], 01h jc loop7 dis_char 00h

loop4: loop5: loop6:

loop7: loop8:

jmp loop8 dis_char 01h inc cx cmp cx, 04h jne loop6 mov ah, 02h mov dl, 20h int 21h inc bx cmp byte ptr [bx], 0dh ; continue until enter key is obtained jne loop3 jmp loop9

errormsg: mov ah, 09h mov dx, offset msg3 int 21h loop9: mov ax, 4c00h int 21h code ends end start ;-------------------------------------------------------------------------; 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 , mov ax, data mov ds, ax ds:data

$'

start:

mov ah, 09h mov dx, offset msg1 int 21h mov ah, 01h

int 21h mov bh, al mov ah, 01h int 21h mov bl, al cmp bl, 3ah jl lab1 add bl, 09h and bl, 0fh cmp bh, 3ah jl lab2 add bh, 09h and bh, 0fh rol bh, 04h or bh, bl xor ax, ax mov al, bh aam mov bx, ax mov mov int mov int ah, 02h dl, 0ah 21h dl, 0dh 21h

lab1:

lab2:

mov ah, 09h mov dx, offset msg2 int 21h mov mov or int mov mov or int ah, 02h dl, bh dl, 30h 21h ah, 02h dl, bl dl, 30h 21h

mov ax, 4c00h int 21h code ends end start ;----------------------------------------------------------------------; end of program ;-----------------------------------------------------------------------

val

equ

0abh ; macro to read a character in bl

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 take_in macro x push ax push dx read mov dh, bl read mov dl, bl mov ah, dh mov al, dl and ax, 0f0fh aad pop dx mov x, al pop ax endm con macro x and display push ax xor ax, ax mov al, x aam or ax, 3030h write ah write al pop ax endm

; macro to write a chararacter x

; macro to display a string

; macro to input a two digit no in x

; macro to convert binary x to decimal

;

-------------

data

segment

-----------------------: $'

_data segment msg1 db ' _data ends ; ---------

the equivalent decimal is

stack

segment

------------------------

_stack segment stack dw 80 dup (0) stack_top label word _stack ends ; ----------code segment -------------------------

start: address of data address of stack

_code segment assume cs : _code , ds : _data , ss : _stack mov ax, _data mov ds, ax ; initialise ds register with segment mov ax, _stack mov ss, ax lea sp, stack_top ; initialise ss register with segment ; initialise stack pointer

write 0ah write 0dh print msg1 mov bx, 000ah xor ax, ax mov al, val div bx or dl, 30h write dl cmp ax, 0000h jg l1 _code ends end start

l1:

;--------------------------------------------------------------------------; 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 ) ;--------------------------------------------------------------------------val equ 0078h ; input hexadecimal no. ( <= 0ffffh)

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 array db _data ends ; --------stack data ' 5

; macro to read a character in bl

; macro to write a chararacter x

; macro to display a string

segment

-----------------------: $'

the equivalent decimal no. is dup (0)

segment

------------------------

_stack segment stack dw 80 dup (0) stack_top label word _stack ends ; ----------code segment -------------------------

start: address of data address of stack

_code segment assume cs : _code , ds : _data , ss : _stack mov ax, _data mov ds, ax ; initialise ds register with segment mov ax, _stack mov ss, ax lea sp, stack_top mov ax, val ; initialise ss register with segment ; initialise stack pointer

l1:

mov lea xor xor div mov inc inc cmp jne

bx, 000ah si, array cl, cl dx, dx bx byte ptr [si], dl si cl ax, 0000h l1

l2:

dec si mov ch, byte ptr [si] or ch, 30h write ch dec cl cmp cl, 00h jne l2 mov ax, 4c00h int 21h end _code ends 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 ) ;----------------------------------------------------------------------------maxi equ 10d ; maximum defined array ; macro to read a character in x ; x cann`t be either of ah or al

read macro x push ax mov ah, 01h int 21h mov x, al pop ax endm write macro x push ax push dx mov dl, x mov ah, 02h int 21h pop dx pop ax

; macro to write a chararacter x

endm print macro x push ax push dx mov dx, offset x mov ah, 09h int 21h pop dx pop ax endm take_in macro x push ax push dx push cx read cl mov dh, cl read cl mov dl, cl mov ah, dh mov al, dl and ax, 0f0fh aad pop cx pop dx mov x, al pop ax endm con macro x and display push ax xor ax, ax mov al, x aam or ax, 3030h write ah write al pop ax endm data segment -----------------------; macro to display a string

; macro to input a two digit no in x ; x cann`t be either of ah or al

; macro to convert binary x to decimal

;

------------_data segment arry db msg1 db

maxi dup 0ah,0dh,' 0ah,0dh,' 0ah,0dh,' 0ah,0dh,' stack

(0) enter the 2 digit no. of terms (max make your entry (2 digits) : $' the sorted list in ascending order is : overflow error$' ------------------------

10d) $'

:

$'

msg2 msg3

db db

msg4 db _data ends ; ---------

segment

_stack segment stack dw 80 dup (0)

stack_top _stack ends ; -----------

label

word -------------------------

code

segment

start: address of data address of stack

_code segment assume cs : _code , ds : _data , ss : _stack mov ax, _data mov ds, ax ; initialise ds register with segment mov ax, _stack mov ss, ax lea sp, stack_top print msg1 take_in cl cmp cl, maxi jle l0 print msg4 jmp last ; initialise ss register with segment ; initialise stack pointer ; cl contains the no. of terms

l0: l1:

xor ch, ch lea si, arry print msg2 take_in dl mov byte ptr [si], dl inc ch inc si cmp ch, cl jne l1 lea si, arry mov ah, cl dec ah xor bh, bh mov bl, bh inc bl mov di, si inc di mov dl, byte cmp dl, byte jl l4 mov dh, byte mov byte ptr mov byte ptr mov dl, dh inc di inc bl cmp bl, cl jl l3 inc bh inc si cmp bh, ah jl l2 lea si, arry xor ch, ch

; make entries in the array

; perform the sorting

l2:

l3:

ptr [si] ptr [di] ptr [di] [di], dl [si], dh

l4:

l5:

print msg3 mov bh, byte ptr [si] con bh write 20h inc ch inc si cmp ch, cl jl l5 mov ax, 4c00h int 21h _code ends end start

; display the sorted array

last:

; terminate process

;----------------------------------------------------------------------------; end of program ;-----------------------------------------------------------------------------

;----------------------------------------------------------------------; program to find the largest of n-2-digit nmbers print macro x mov ah, 09h mov dx, offset x int 21h endm read endm write macro x mov ah, 02h mov dl, x int 21h endm data segment msg1 db msg2 db msg3 db msg4 db terms db i db data ends ' ' ' ' ; macro to write the character x macro mov ah, 01h int 21h ; macro to print a string

; macro to read a character

enter any two digit no. of terms (in decimal): make a two digit unsigned entry : $' the largest is $' invalid input$' ? ?

$'

start:

code segment assume cs:code , mov ax, data mov ds, ax print msg1 read cmp al, 30h jl errormsg

ds:data ; initialise ds register ; display msg1 ; make entry of the no. of terms

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 mov ax, bx aad mov terms, al jmp loop0 errormsg: print msg4 jmp last loop0: write 0ah write 0dh print msg2 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 dec terms mov i, 00h write 0ah write 0dh print msg2 read cmp al, 30h jl errormsg cmp al, 39h jg errormsg mov ch, al read cmp al, 30h jl errormsg cmp al, 39h jg errormsg mov cl, al cmp bx, cx jg loop2 mov bx, cx inc i mov dl, terms

; masking higher nibble ; convert unpacked bcd to binary in al ; 'terms' contains the no. of terms ; display error msg

; move cursor to next line ; display msg2 ; make the first entry

; first entry is in bx ; decrement the no. of terms ; initialise counter i to zero ; move cursor to next line ; display msg2 ; make subsequent entry in cx

loop1:

; cx contains the next entry ; compare cx with bx ; if cx > bx then bx <- cx ; inc counter i

loop2:

cmp i, dl jne loop1 write write print write write last: end start 0ah 0dh msg3 bh bl ; move cursor to next line ; display msg3 ; display bx, the largest no.

mov ax, 4c00h int 21h code ends

; terminate program

;----------------------------------------------------------------------; end of program ;-----------------------------------------------------------------------

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 make_entry push ax push dx read mov dh, read mov dl, and dx, mov ax, macro x

; macro to read a character in bl

; macro to write a chararacter x

; macro to display a string

; x cannot be any of ah or al

bl bl 0f0fh dx

aad pop dx mov x, al pop ax endm 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 msg2 db msg3 db msg4 db var1 db var2 db _data ends ---------

data ' ' ' '

segment

-----------------------: : $' $'

; ; ;

? ?

enter the first two digit no. enter the second two digit no. the hcf is : $' the lcm is : $'

stack

segment

------------------------

_stack segment stack dw 80 dup (0) stack_top label word _stack ends ; ----------code segment -------------------------

start: address of data address of stack

_code segment assume cs : _code , ds : _data , ss : _stack mov ax, _data mov ds, ax ; initialise ds register with segment mov ax, _stack mov ss, ax lea sp, stack_top print msg1 make_entry bh mov var1, bh write 0ah write 0dh ; initialise ss register with segment ; initialise stack pointer ; display msg1

;

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 loop1: xor mov div mov mov cmp jne ax, ax al, bh bl bh, bl bl, ah bl, 00h loop1

; bh > bl

write 0ah write 0dh print msg3 show bh write 0ah write 0dh print msg4 xor mov mul div ax, ax al, dh dl bh

show al mov ax, 4c00h int 21h _code ends end start

maxi

equ

10d ; macro to read a character in bl

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 make_entry macro push ax push dx read mov dh, bl read mov dl, bl and dx, 0f0fh mov ax, dx aad pop dx mov x, al pop ax endm x ; macro to write a chararacter x

; macro to display a string

; x cannot be any of ah or al

;

------------_data segment msg1 db msg2 db msg3 db msg4 db msg5 db msg6 db vars db _data ends

data

segment

-----------------------$'

' enter the no. of terms present (max 10) : ' make your entry : $' ' match found.$' ' match not found.$' ' enter the item to be searched : $' ' no. of items exceeds the limit$' maxi dup (0)

;

---------

stack

segment

------------------------

_stack segment stack dw 80 dup (0) stack_top label word _stack ends ; ----------code segment -------------------------

start: address of data address of stack

_code segment assume cs : _code , ds : _data , ss : _stack mov ax, _data mov ds, ax ; initialise ds register with segment mov ax, _stack mov ss, ax lea sp, stack_top print msg1 xor cx, cx make_entry cl cmp cl, maxi jg errormsg mov ch, 00h lea si, vars write 0ah write 0dh print msg2 make_entry bh mov byte ptr [si], bh inc ch inc si cmp ch, cl jne loop1 write 0ah write 0dh write 0ah jmp l1 ; initialise ss register with segment ; initialise stack pointer ; display msg1 ; cl contains the no. of terms

loop1:

errormsg: l1:

print msg6 jmp last print msg5 make_entry bh

loop2:

lea si, vars xor ch, ch cmp bh, byte ptr [si] je fnd inc si inc ch cmp ch, cl jne loop2

write 0ah write 0dh print msg4 jmp last fnd: write 0dh write 0ah print msg3 mov ax, 4c00h int 21h _code ends end start

last:

;--------------------------------------------------------------------------; program to implement linked list operations ;--------------------------------------------------------------------------; programmed by indranil gupta ;--------------------------------------------------------------------------;========================== ; program is not complete ;=========================== read macro x push ax mov ah, 01h int 21h mov x, 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 ; macro to read a character in bl

; macro to write a chararacter x

; macro to display a string

;

-------------

data

segment

------------------------

_data segment msg1 db 0ah,0dh,' operations :-$' msg2 msg3 msg4 msg5 msg6 msg7 msg10 msg8 msg9 msga msgb msgc db db db db db db db db db db db db

program to demonstrate linked list

0ah,0dh,' the options are as :-$' 0ah,0dh,' enter 1 to create$' 0ah,0dh,' enter 2 to insert$' 0ah,0dh,' enter 3 to delete$' 0ah,0dh,' enter 4 to display$' 0ah,0dh,' enter 5 to exit$' 0ah,0dh,' enter 6 to search$' 0ah,0dh,' enter your option : $' 0ah,0dh,0ah,' enter the element to be inserted : 0ah,0dh,' memory allocation error.(exit from 0ah,0dh,0ah,' 0ah,0dh,' do you wish to continue ( press 1 if

$' program)$' yes ) : $' if yes ) : $'

do you wish to insert another ( press 1

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 ; --------stack segment ------------------------

_stack segment stack dw 180 dup (0) stack_top label word _stack ends ; ----------code segment -------------------------

start: address of data address of stack

_code segment assume cs : _code , ds : _data , ss : _stack mov ax, _data mov ds, ax ; initialise ds register with segment mov ax, _stack mov ss, ax lea sp, stack_top ; initialise ss register with segment ; initialise stack pointer

l0:

print print print print print print print

msg1 lin msg2 msg3 msg4 msg5 msg6

ll0: ll1:

l1: l2: l3:

last: ;---------cre

print msg7 print msg10 print msg8 read cl write 0ah write 0dh jmp ll1 jmp l0 cmp cl, 31h jne l1 call cre jmp l2 cmp cl, 34h jne l2 call disp cmp cl, 36h jne l3 call srch write 0ah print msgb read cl cmp cl, 31h je ll0 mov ax, 4c00h int 21h procedure to create a list proc near push ax push bx push cx push dx push si mov ah, 48h mov bx, 0001h int 21h jc perr2 mov begin, ax mov si, ax mov dx, ax print msg9 xor bx, bx read cl cmp cl, 0dh je p2 mov byte ptr [si+bx], cl inc bl jmp p1 jmp perr1 mov byte ptr [si+bx], 24h write 0ah print msgc read cl cmp cl, 31h jne p3 ---------------------------

p0:

p1:

perr2: p2:

p3:

perr1: p4:

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 mov si, dx add si, 000eh mov byte ptr [si], 00h mov byte ptr [si+0001h], 00h jmp p4 print msga pop si pop dx pop cx pop bx pop ax ret endp procdure to display the list ---------------------

; ------------

ep1:

ep2:

disp proc near push si push ax push dx mov si, begin write 0ah write 0dh write 0ah print msgd write 0ah write 0dh write 09h mov ah, 09h mov dx, si int 21h write 0ah write 0dh add si, 000eh mov ah, byte ptr [si] mov al, byte ptr [si+0001h] cmp ax, 0000h je ep2 mov si, ax jmp ep1 pop dx pop ax pop si ret endp procedure to search a name in the list proc near --------------

;------------srch

push push push push push

si bx dx cx di

q:

r:

lea di, srh_el write 0ah print msgg read cl cmp cl, 0dh je r mov byte ptr [di], cl inc di jmp q mov byte ptr [di], '$' lea di, srh_el mov si, begin xor bx, bx mov dl, byte ptr [si+bx] cmp dl, byte ptr [di] jne sp2 inc di inc bx cmp dl, '$' jne sp5 print msge jmp sp3 print msgf pop di pop cx pop dx pop bx pop si ret endp

sp4: sp5:

sp2: sp3:

_code ends end start ;--------------------------------------------------------------------------; end of program ;---------------------------------------------------------------------------

;--------------------------------------------------------------------------; program to create and display linear linked list ;---------------------------------------------------------------------------

; programmed by indranil gupta ;--------------------------------------------------------------------------read macro x push ax mov ah, 01h int 21h mov x, 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 ; macro to read a character in x ; x cann`t be either of ah or al

; macro to write a chararacter x

; macro to display a string

segment

------------------------

_data segment msg1 db 0ah,0dh,' operations :-$' msg2 msg3 msg4 msg5 msg6 msg7 msg8 msg9 msga db db db db db db db db db 0ah,0dh,' 0ah,0dh,' 0ah,0dh,' 0ah,0dh,' 0ah,0dh,' 0ah,0dh,' 0ah,0dh,' 0ah,0dh,' 0ah,0dh,'

program to demonstrate linked list the options are :-$' enter 1 to create$' enter 2 to search an item$' enter 3 to display the list$' enter 4 to exit$' enter your option : $' make your entry : $' do you want to continue ( press y if yes ) do you want to insert ( press y if yes )

$' $'

msgb db msgc db msgd db msge db err1 db err2 db begin dw s_itm db _data ends

0ah,0dh,' enter the item to be searched : $' 0ah,0dh,' search is successful $' 0ah,0dh,' search is not successful $' 0ah,0dh,' the list is as follows :-$' 0ah,0dh,' memory allocation error.$' 0ah,0dh,' wrong option entered.$' 0000h 14d dup (0)

;

---------

stack

segment

------------------------

_stack segment stack dw 180 dup (0) stack_top label word _stack ends ; ----------code segment -------------------------

start: address of data address of stack

_code segment assume cs : _code , ds : _data , ss : _stack mov ax, _data mov ds, ax ; initialise ds register with segment mov ax, _stack mov ss, ax lea sp, stack_top print msg1 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 jmp l1 cmp dl, 32h jne l3 print msgb lea di, s_itm read dl cmp dl, 0dh je s2 mov byte ptr [di], dl inc di jmp s1 mov byte ptr [di], '$' call search jmp l5 cmp dl, 33h jne l4 call disp jmp l5 cmp dl, 34h je last print err2 print msg9 read dl cmp dl, 'y' je l11 ; initialise ss register with segment ; initialise stack pointer

l1:

l11: l2:

s1:

s2: l3:

l4: l5:

last:

mov ax, 4c00h int 21h procedure to create linked list -------------------

;-------------

crep1: crep2:

crep3:

crep4:

cre_err2: cre_err1: crelst:

create proc near push si push ax push bx push dx mov ah, 48h mov bx, 0001h int 21h jc cre_err1 mov begin, ax mov si, ax print msg8 xor bx, bx read dl cmp dl, 0dh je crep3 mov byte ptr [si+bx], dl inc bx jmp crep2 mov byte ptr [si+bx], '$' print msga read dl cmp dl, 'y' jne crep4 mov ah, 48h mov bx, 0001h int 21h jc cre_err2 add si, 000eh mov byte ptr [si], ah mov byte ptr [si+0001h], al jmp crep1 add si, 000eh mov byte ptr [si], 00h mov byte ptr [si+0001h], 00h jmp crelst mov byte ptr [si], 00h mov byte ptr [si+0001h], 00h print err1 pop dx pop bx pop ax pop si ret endp procudure to display linked list ------------------

;---------------

disp proc near push si push ax print msge

dis1:

dis2:

write 0ah write 0dh mov si, begin cmp si, 0000h je dis2 write 09h mov ah, 09h mov dx, si int 21h write 0ah write 0dh add si, 000eh mov ah, byte ptr [si] mov al, byte ptr [si+0001h] mov si, ax jmp dis1 pop ax pop si ret endp procedure to search for an item in the list --------

;-------------

sr1: sr2:

sr3:

nf: fnd: sr4:

search proc near push si push di push bx push dx mov si, begin lea di, s_itm cmp si,0000h je nf xor bx, bx mov dh, byte ptr mov dl, byte ptr inc bx cmp dh, dl jne sr3 cmp dh, '$' je fnd jmp sr2 add si, 000eh mov dh, byte ptr mov dl, byte ptr mov si, dx jmp sr1 print msgd jmp sr4 print msgc pop dx pop bx pop di pop si ret endp _code ends

[si+bx] [di+bx]

[si] [si+0001h]

end start ;--------------------------------------------------------------------------; end of program ;---------------------------------------------------------------------------

;--------------------------------------------------------------------------; program to create and display linear linked list ;--------------------------------------------------------------------------; programmed by indranil gupta ;--------------------------------------------------------------------------read macro x push ax mov ah, 01h int 21h mov x, 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 ; macro to read a character in x ; x cann`t be either of ah or al

; macro to write a chararacter x

; macro to display a string

segment

------------------------

operations :-$'

_data segment msg1 db 0ah,0dh,' msg2 msg3 msg4 msg41 msg5 db db db db db 0ah,0dh,' 0ah,0dh,' 0ah,0dh,' 0ah,0dh,' 0ah,0dh,'

program to demonstrate linked list the options are :-$' enter 1 to create$' enter 2 to search an item$' enter 3 to insert an item$' enter 4 to display the list$'

$' $'

msg6 msg7 msg8 msg9 msga

db db db db db

0ah,0dh,' 0ah,0dh,' 0ah,0dh,' 0ah,0dh,' 0ah,0dh,'

enter 5 to exit$' enter your option : $' make your entry : $' do you want to continue ( press y if yes ) do you want to insert ( press y if yes )

msgb db msgc db msgd db msge db err1 db err2 db begin dw s_itm db _data ends ; ---------

0ah,0dh,' enter the item to be searched : $' 0ah,0dh,' search is successful $' 0ah,0dh,' search is not successful $' 0ah,0dh,' the list is as follows :-$' 0ah,0dh,' memory allocation error.$' 0ah,0dh,' wrong option entered.$' 0000h 14d dup (0) stack segment ------------------------

_stack segment stack dw 180 dup (0) stack_top label word _stack ends ; ----------code segment -------------------------

start: address of data address of stack

_code segment assume cs : _code , ds : _data , ss : _stack mov ax, _data mov ds, ax ; initialise ds register with segment mov ax, _stack mov ss, ax lea sp, stack_top print msg1 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 jmp l1 cmp dl, 32h jne l3 print msgb lea di, s_itm read dl cmp dl, 0dh je s2 ; initialise ss register with segment ; initialise stack pointer

l1:

l11: l2:

s1:

s2: l3:

l4:

l5: l6:

mov byte ptr [di], dl inc di jmp s1 mov byte ptr [di], '$' call search jmp l6 cmp dl, 33h jne l6 call insert jmp l6 cmp dl, 34h jne l6 call disp jmp l6 cmp dl, 35h je last print err2 print msg9 read dl cmp dl, 'y' je l11 mov ax, 4c00h int 21h procedure to create linked list -------------------

last:

;-------------

crep1: crep2:

crep3:

create proc near push si push ax push bx push dx mov ah, 48h mov bx, 0001h int 21h jc cre_err1 mov begin, ax mov si, ax print msg8 xor bx, bx read dl cmp dl, 0dh je crep3 mov byte ptr [si+bx], dl inc bx jmp crep2 mov byte ptr [si+bx], '$' print msga read dl cmp dl, 'y' jne crep4 mov ah, 48h mov bx, 0001h int 21h jc cre_err2 add si, 000eh mov byte ptr [si], ah mov byte ptr [si+0001h], al

crep4:

cre_err2: cre_err1: crelst:

jmp crep1 add si, 000eh mov byte ptr [si], 00h mov byte ptr [si+0001h], 00h jmp crelst mov byte ptr [si], 00h mov byte ptr [si+0001h], 00h print err1 pop dx pop bx pop ax pop si ret endp procudure to display linked list ------------------

;---------------

dis1:

dis2:

disp proc near push si push ax print msge write 0ah write 0dh mov si, begin cmp si, 0000h je dis2 write 09h mov ah, 09h mov dx, si int 21h write 0ah write 0dh add si, 000eh mov ah, byte ptr [si] mov al, byte ptr [si+0001h] mov si, ax jmp dis1 pop ax pop si ret endp procedure to search for an item in the list --------

;-------------

sr1: sr2:

search proc near push si push di push bx push dx mov si, begin lea di, s_itm cmp si,0000h je nf xor bx, bx mov dh, byte ptr [si+bx] mov dl, byte ptr [di+bx] inc bx cmp dh, dl

sr3:

nf: fnd: sr4:

jne sr3 cmp dh, '$' je fnd jmp sr2 add si, 000eh mov dh, byte ptr [si] mov dl, byte ptr [si+0001h] mov si, dx jmp sr1 print msgd jmp sr4 print msgc pop dx pop bx pop di pop si ret endp _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. ;-------------------------------------------------------------------------read macro than ax x ; macro to read a character in x other

push ax mov ah, 01h int 21h mov x, al pop ax endm write macro x push ax push dx mov dl, x mov ah, 02h int 21h pop dx pop ax endm ; macro to write a chararacter x

print macro x push ax push dx mov dx, offset x mov ah, 09h int 21h pop dx pop ax endm take_in macro x push ax push dx push bx read bl mov dh, bl read bl mov dl, bl mov ah, dh mov al, dl and ax, 0f0fh aad pop bx pop dx mov x, al pop ax endm and display con macro x push ax mov al, x xor ah, ah aam or ax, 3030h write ah write al pop ax endm

; macro to display a string

; macro to input a two digit no in x

; macro to convert binary x to decimal

;

-------------

data

segment

------------------------

are :-$' matrices.$' matrix.$'

_data segment fir_mat db 4 dup sec_mat db 4 dup msg1 db 0ah,0dh,' msg2 db 0ah,0dh,' msg3 db 0ah,0dh,' msg4 db 0ah,0dh,' msg5 msg6 msg7 db db db 0ah,0dh,' 0ah,0dh,' 0ah,0dh,'

(0) (0) enter a element for first matrix :- $' enter a element for second matrix :- $' the resulting matrix is :-$' the various operations for 2 x 2 matrix enter 1 to add two 2x2 matrices.$' enter 2 to multiply two 2x2 enter 3 to transpose a 2x2

) : $'

msg8 msg9

db db

0ah,0dh,' 0ah,0dh,' 0ah,0dh,' 0ah,0dh,' 0ah,0dh,' 0ah,0dh,' 0ah,0dh,' stack

wrong choice entered. retry . . . $' do you wish to continue ( press 1 if yes your option is : $' position (0,0) : $' position (0,1) : $' position (1,0) : $' position (1,1) : $' ------------------------

msga db msg00 db msg01 db msg10 db msg11 db _data ends ; ---------

segment

_stack segment stack dw 80 dup (0) stack_top label word _stack ends ; ----------code segment -------------------------

start: address of data address of stack l1:

_code segment assume cs : _code , ds : _data , ss : _stack mov ax, _data mov ds, ax ; initialise ds register with segment mov ax, _stack mov ss, ax lea sp, stack_top print msg4 print msg5 print msg6 print msg7 print msga read cl cmp cl, 31h jne l2 call mat_add jmp l5 jmp l1 cmp cl, 32h jne l3 call mat_mul jmp l5 cmp cl, 33h jne l4 call mat_trp jmp l5 print msg8 print msg9 read cl cmp cl, 31h je l11 mov ax, 4c00h int 21h mat_add proc near ; procedure to perform matrix addition ; initialise ss register with segment ; initialise stack pointer

l11: l2:

l3:

l4: l5: l6:

last:

al1:

al11: al12:

push si push di push cx lea si, fir_mat print msg1 call inp lea si, sec_mat print msg2 call inp lea si, fir_mat lea di, sec_mat xor cl, cl write 0ah write 0dh write 09h write 0b3h write 20h jmp al12 jmp al1 mov ch, byte ptr add ch, byte ptr con ch write 20h inc si inc di mov ch, byte ptr add ch, byte ptr con ch write 20h write 0b3h inc cl inc si inc di cmp cl, 02h jne al11 pop cx pop di pop si ret endp inp proc near

[si] [di]

[si] [di]

pointed by si

; procedure to input values to matrix

push si push cx print msg00 take_in ch mov byte ptr [si], ch inc si print msg01 take_in ch mov byte ptr [si], ch inc si print msg10 take_in ch mov byte ptr [si], ch inc si print msg11

take_in ch mov byte ptr [si], ch pop cx pop si ret endp mat_mul proc near ; procedure for matrix multiplication push si push di push ax push cx lea si, fir_mat print msg1 call inp lea si, sec_mat print msg2 call inp lea si, fir_mat lea di, sec_mat write 0ah write 0dh write 09h write 0b3h write 20h xor ax, ax mov al, byte ptr [si] mul byte ptr [di] mov ch, al inc si add di, 0002h xor ax, ax mov al, byte ptr [si] mul byte ptr [di] add ch, al con ch write 20h dec di dec si xor ax, ax mov al, byte ptr [si] mul byte ptr [di] mov ch, al inc si add di, 0002h mov al, byte ptr [si] mul byte ptr [di] add ch, al con ch write 20h write 0b3h write 0ah write 0dh write 09h write 0b3h write 20h inc si sub di, 0003h

mov al, byte ptr [si] mul byte ptr [di] mov ch, al inc si add di, 0002h mov al, byte ptr [si] mul byte ptr [di] add ch, al con ch write 20h dec si dec di mov al, byte ptr [si] mul byte ptr [di] mov ch, al inc si add di, 0002h mov al, byte ptr [si] mul byte ptr [di] add ch, al con ch write 20h write 0b3h pop cx pop ax pop di pop si ret endp mat_trp proc near push si push cx lea si, fir_mat print msg1 call inp lea si, fir_mat write 0ah write 0dh write 09h write 0b3h write 20h mov cl, byte ptr [si] con cl write 20h add si, 0002h mov cl, byte ptr [si] con cl write 20h write 0b3h write 0ah write 0dh write 09h write 0b3h write 20h dec si mov cl, byte ptr [si] ; procedure for transpose of matrix

endp

con cl write 20h add si, 0002h mov cl, byte ptr [si] con cl write 20h write 0b3h pop cx pop si ret _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 mov ax, data mov ds, ax 62h bx 0080h byte ptr es:[di] 00h

start:

; initialise ds register

mov ah, int 21h mov es, mov di, mov cl, characters in argument cmp cl, je err1

; cl contains the no. of

lea si, dir_nm xor ch, ch mov di, 005dh

l0:

mov dl, byte ptr es:[di] cmp dl, 21h jl err1 mov byte ptr [si], dl inc si inc di inc ch mov dl, byte ptr es:[di] cmp dl, 21h jl l1 cmp ch, cl jne l0 mov mov mov int jnc mov mov int jmp byte ptr [si], 00h ah, 3bh dx, offset dir_nm 21h last ah, 09h dx, offset msg1 21h last

; read the content of argument

l1:

; set the current directory

err1:

mov ah, 09h mov dx, offset msg2 int 21h mov ax, 4c00h int 21h code ends end start ; terminate program

last:

;-------------------------------------------------------------------------; 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 msg2 db filename data ends 0ah,0dh,'file not found.$' 0ah,0dh,'required parameter missing - $' db 15 dup (0)

start:

code segment assume cs:code , ds:data mov ax, data mov ds, ax

; initialise ds register

mov ah, 62h int 21h mov es, bx base addr of psp mov di, 0080h mov cl, byte ptr es:[di] characters in the argument cmp cl, 00h je err1 lea si, filename mov di, 005dh argument l0: xor ch, mov dl, inc ch cmp ch, je err1 inc di cmp dl, jl l0 dec di ch byte ptr es:[di] cl 21h ; neglecting space characters ; command characters stored in ; offset of filename in si ; starting address of command ; initialise es register with ; cl contains the no. of

l1: filename

mov byte ptr [si], dl inc si inc di inc ch cmp ch, cl jg err2 mov dl, byte ptr es:[di] cmp dl, 20h jg l1 mov byte ptr [si], '.' inc si

; read next command character

; insert '.' after the filename ; filename extension lies from

l2: 65h l3:

mov di, 0065h mov dl, byte ptr es:[di] cmp dl, 21h jl l4 mov byte ptr [si], dl inc si inc di inc ch cmp ch, cl jg err2 jmp l3 mov byte ptr [si], 00h mov ah, 41h mov dx, offset filename int 21h

; copy extension

l4:

; insert null at last

; dos interrupt to delete file

jnc last err2: mov mov int jmp ah, 09h dx, offset msg1 21h last

err1:

mov ah, 09h mov dx, offset msg2 int 21h mov ax, 4c00h int 21h code ends end start ; terminate process

last:

;--------------------------------------------------------------------------; 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 : ;--------------------------------------------------------------------------ctail equ 080h ; psp offset, command tail ; macro to read a character in bl

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

; macro to write a chararacter x

; macro to display a string

pop dx pop ax endm ; ------------_data segment msg2 db msg1 db buffer db filenm db _data ends ; --------data segment ------------------------

' file not found.$' ' required parameter missing$' 85 dup (0) 15 dup (0) stack segment ------------------------

_stack segment stack dw 80 dup (0) stack_top label word _stack ends ; ----------code segment -------------------------

start: address of data address of stack

_code segment assume cs : _code , ds : _data , ss : _stack , es : _data mov ax, _data mov ds, ax ; initialise ds register with segment mov ax, _stack mov ss, ax mov ax, _data mov es, ax lea sp, stack_top mov ah, 62h int 21h 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 lea si, filenm mov xor mov add cl, ch, di, di, dh ch offset buffer offset 006dh ; initialise ss register with segment

; initialise stack pointer

l1:

l2:

mov bl, byte ptr [di] cmp bl, 20h je l2 mov byte ptr [si], bl inc si inc di inc ch cmp ch, cl jne l1 mov byte ptr [si], 00h mov ax, _data mov ds, ax ; ;

mov ah, 41h mov dx, offset filenm int 21h jc errmsg2 jmp last errmsg1: errmsg2: last: print msg1 jmp last print msg2 mov ax, 4c00h int 21h _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 mov ax, data mov ds , ax mov ah, int 21h mov es, xor bx, mov di, mov bl, cmp bl, je l1 62h bx bx 80h byte ptr es:[di] 00h , ds: data

start :

l0:

mov xor mov inc inc cmp

di, cx, ch, cl di ch,

005dh cx byte ptr es:[di] cl

l1:

mov ah , 1ah mov dx, offset buffer int 21h mov ah, 4eh mov cx, 0000h mov dx, offset filename int 21h jc last lea si, buffer add si, 001eh xor cl,cl mov dl, byte ptr [si] cmp dl, 21h jl loop2 mov ah, 02h int 21h inc si inc cl cmp cl, 0ch jne loop1 mov ah, 4fh int 21h jc last lea si, buffer xor cl,cl add si, 001eh mov dl, byte ptr [si] cmp dl, 21h jl loop4 mov ah, 02h int 21h inc si inc cl cmp cl, 0ch jne loop3 mov ah, 02h mov dl, 0ah int 21h mov dl, 0dh int 21h inc ch cmp ch, 16h jl loop2

loop1:

loop2:

;;;;

loop3:

loop4:

mov int xor jmp last :

ah, 01h 21h ch, ch loop2

mov ax, 4c00h int 21h 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 mov ax, data mov ds, ax 62h bx 0080h byte ptr es:[di] 00h

start:

; initialise ds register

mov ah, int 21h mov es, mov di, mov cl, characters in argument cmp cl, je err1

; cl contains the no. of

l0:

lea si, dir_nm xor ch, ch mov di, 005dh mov dl, byte ptr es:[di] cmp dl, 21h jl err1 mov byte ptr [si], dl inc si inc di inc ch mov dl, byte ptr es:[di] cmp dl, 21h jl l1 cmp ch, cl

; read the content of argument

jne l0 l1: mov mov mov int jnc mov mov int jmp err1: byte ptr [si], 00h ah, 39h dx, offset dir_nm 21h last ah, 09h dx, offset msg1 21h last

; set the current directory

mov ah, 09h mov dx, offset msg2 int 21h mov ax, 4c00h int 21h code ends end start ; terminate program

last:

;-------------------------------------------------------------------------; 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 mov ax, data mov ds, ax 62h bx 0080h byte ptr es:[di] 00h

start:

; initialise ds register

mov ah, int 21h mov es, mov di, mov cl, characters in argument cmp cl, je err1

; cl contains the no. of

l0:

lea si, dir_nm xor ch, ch mov di, 005dh mov dl, byte ptr es:[di] cmp dl, 21h jl err1 mov byte ptr [si], dl inc si inc di inc ch mov dl, byte ptr es:[di] cmp dl, 21h jl l1 cmp ch, cl jne l0 mov mov mov int jnc mov mov int jmp byte ptr [si], 00h ah, 3ah dx, offset dir_nm 21h last ah, 09h dx, offset msg1 21h last

; read the content of argument

l1:

; set the current directory

err1:

mov ah, 09h mov dx, offset msg2 int 21h mov ax, 4c00h int 21h code ends end start ; terminate program

last:

;-------------------------------------------------------------------------; 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 fl_new msg1 msg2

db db db db

15 dup (0) 15 dup (0) ' required parameter missing. $' ' file not found. $'

data ends code segment assume cs:code , ds:data mov ax, data mov ds, ax mov ah, 62h int 21h mov es, bx lea si, fl_old mov di, 005dh xor ch, ch mov dl, byte ptr es:[di] cmp dl, 21h jl err1 mov byte ptr [si], dl inc si inc di mov dl, byte ptr es:[di] cmp dl, 21h jl l1 cmp ch, 08h jne l0 mov byte ptr [si], '.' inc si mov di, 0065h xor ch, ch mov dl, byte ptr es:[di] cmp dl, 21h jl l4 mov byte ptr [si], dl inc si inc di cmp ch, 03h jl l2 mov mov int jmp ah, 09h dx, offset msg1 21h last

start:

; initialise ds register

; es contains psp address

l0:

; read the first filename

l1:

l2:

; read the extension of first filename

err1:

; display error msg

l4:

l5:

mov byte ptr [si], 00h lea si, fl_new mov di, 006dh xor ch, ch mov dl, byte ptr es:[di] cmp dl, 21h jl err1 mov byte ptr [si], dl inc si inc di mov dl, byte ptr es:[di] cmp dl, 21h jl l6 cmp ch, 08h

; read next filename

jne l5 l6: mov byte ptr [si], '.' inc si mov di, 0075h xor ch, ch mov dl, byte ptr es:[di] cmp dl, 21h jl l8 mov byte ptr [si], dl inc si inc di cmp ch, 03h jl l7 mov mov mov mov mov mov int jnc byte ptr [si], 00h ax, data es, ax ah, 56h dx, offset fl_old di, offset fl_new 21h last

l7:

; read extension of next file

l8:

; interrupt to rename file

mov ah, 09h mov dx, offset msg2 int 21h last: mov ax, 4c00h int 21h code ends end start ;--------------------------------------------------------------------------; end of program ;--------------------------------------------------------------------------; terminate process with return code

;----------------------------------------------------------------------------; 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

start:

code segment assume cs:code , ds:data mov ax, data mov ds, ax mov ah, 62h int 21h

; initialise ds register

mov es, bx base addr of psp mov di, 0080h mov cl, byte ptr es:[di] characters in the argument cmp cl, 00h je err2 lea si, fil_nm mov di, 005dh argument l0: xor ch, mov dl, inc ch cmp ch, je err1 inc di cmp dl, jl l0 dec di ch byte ptr es:[di] cl 21h

; initialise es register with ; cl contains the no. of

; offset of filename in si ; starting address of command

; neglecting space characters ; command characters stored in

l1: filename

mov byte ptr [si], dl inc si inc di inc ch cmp ch, cl jg l4 mov dl, byte ptr es:[di] cmp dl, 20h jg l1 mov byte ptr [si], '.' inc si

; read next command character

; insert '.' after the filename ; filename extension lies from

l2: 65h l3:

mov di, 0065h mov dl, byte ptr es:[di] cmp dl, 21h jl l4 mov byte ptr [si], dl inc si inc di inc ch cmp ch, cl jg l4 jmp l3 jmp err1

; copy extension

err2:

l4:

mov byte ptr [si], 00h mov ah, 3dh mov al, 80h mov dx, offset int 21h jnc l41 mov ah, 09h mov dx, offset int 21h jmp last mov fhan, ax mov ah, 3fh mov bx, fhan mov cx, 0001h mov dx, offset int 21h cmp ax, 0000h je l6 mov ah, 02h mov dl, buffer int 21h jmp l5 mov ah, 3eh mov bx, fhan int 21h jmp last mov ah, 09h mov dx, offset int 21h jmp last mov ax, 4c00h int 21h code ends end start

; insert null at last

fil_nm ; open file in reading mode msg1

l41: l5:

buffer

; read file content

; display file content

l6:

; close file msg1

err1:

last:

; terminate process

;----------------------------------------------------------------------------; end of program ;-----------------------------------------------------------------------------

ctail

equ

080h

; psp offset, command tail ; macro to read a character in bl

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

; macro to write a chararacter x

mov int pop pop endm

ah, 02h 21h dx ax ; macro to display a string

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 buffer db filenm db _data ends ; --------data

segment

------------------------

0ah,0dh,' file not found.$' 80 dup (0) 15 dup (0) stack segment ------------------------

_stack segment stack dw 80 dup (0) stack_top label word _stack ends ; ----------code segment -------------------------

start: address of data address of stack

_code segment assume cs : _code , ds : _data , ss : _stack , es : _data mov ax, _data mov ds, ax ; initialise ds register with segment mov ax, _stack mov ss, ax mov ax, _data mov es, ax lea sp, stack_top write 0ah write 0dh mov ah, 62h int 21h mov mov mov mov mov mov mov ds, si, di, es, di, cl, dh, bx offset ctail seg buffer di offset buffer byte ptr [si] cl ; initialise ss register with segment

; initialise stack pointer

inc xor xor cld rep

cl ch, ch si, si movsb

lea si, filenm mov cl, dh xor ch, ch mov di, offset buffer add di, offset 006dh mov bl, byte ptr [di] cmp bl, 20h je l2 mov byte ptr [si], bl inc si inc di inc ch cmp ch, cl jne l1 mov byte ptr [si], 00h mov ah, 41h mov dx, offset filenm int 21h

l1:

l2:

last:

mov ax, 4c00h int 21h _code ends

end start

data segment buffer db 50 dup (?) filename db '*.*',0 data ends code segment assume cs: code mov ax, data mov ds , ax mov mov int mov int ah, 02h dl, 0ah 21h dl, 0dh 21h , ds: data

start :

mov ah , 1ah

mov dx, offset buffer int 21h mov ah, 4eh mov cx, 0 mov dx, offset filename int 21h jc last lea add xor mov cmp jmp mov int inc inc cmp jne si, buffer si, 001eh cl,cl dl, byte ptr [si] dl, 21h loop2 ah, 02h 21h si cl cl, 0ch loop1

loop1:

loop2:

mov ah, 4fh int 21h jc last lea si, buffer xor cl,cl add si, 001eh mov dl, byte ptr [si] cmp dl, 21h jl loop4 mov ah, 02h int 21h inc si inc cl cmp cl, 0ch jne loop3 mov ah, 02h mov dl, 0ah int 21h mov dl, 0dh int 21h inc ch cmp ch, 16h jl loop2 mov ah, 01h int 21h xor ch, ch jmp loop2 mov ax, 4c00h int 21h code ends

;;;;

loop3:

loop4:

last :

end start

maxi

equ 07h

print macro x mov ah, 09h mov dx, offset x int 21h endm read endm macro mov ah, 01h int 21h

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 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 cmp cl, 00h je loop6 write 0ah

$'

start:

loop2:

loop3:

loop10:

loop4: loop5:

write 0dh print msg2 lea si, octal xor ch, ch and byte ptr [si], 0fh xor bl, bl shl byte ptr [si], 05h write 20h shl byte ptr [si], 01h jc loop4 write 30h jmp loop5 write 31h inc bl cmp bl, 03h jne loop10 inc ch inc si cmp ch, cl jne loop3 write 62h jmp loop6 print msg3 mov ax, 4c00h int 21h code ends

errormsg: loop6: end start

;-----------------------------------------------------------------------; 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. ;-----------------------------------------------------------------------print macro x mov ah, 09h mov dx, offset x int 21h endm read endm write macro x mov ah, 02h mov dl, x int 21h endm ; macro to write a character macro mov ah, 01h int 21h ; macro to display a string

; macro to read a character

data segment msg1 db ' enter any octal no. (<143o) : msg2 db ' the decimal equivalent is $' msg3 db ' invalid entry$' octal db 3 dup (0) data ends code segment assume cs:code , ds:data mov ax, data mov ds, ax print msg1 xor cl, cl lea si, octal read 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 inc si inc cl cmp cl, 03h jne loop1 sub si, 0003h cmp byte ptr [si], 31h jg errormsg jmp l1 print msg3 jmp loop4 xor bl, bl xor ch, ch lea si, octal and byte ptr [si], 0fh shl byte ptr [si], 05h xor bh, bh shl byte ptr [si], 01h rcl bl, 01h inc bh cmp bh, 03h jne loop3 inc si inc ch cmp ch, cl jne loop2 mov al, bl cmp al, 63h jg errormsg

$'

start:

; initialise ds register

loop1:

; read the inputs

; store the data in array octal

errormsg: l1: loop2: loop3:

; mask higher nibble ; shift 5 bits left of content of si

; rotate 3 bits and store in bl

aam mov cx, ax or cx, 3030h write write print write write write loop4: end start 0ah 0dh msg2 ch cl 64h

; convert binary to unpacked bcd

; move cursor to next line

mov ax, 4c00h int 21h code ends

; terminate process

;-----------------------------------------------------------------------; end of program ;-----------------------------------------------------------------------;program to convert octal to decimal ; by sanjib das regn no 98011031 data segment msg1 db 'enter the octal number$' msg2 db 'the equivalent decimal no is :$' deci db 3 dup(?) data ends 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 mov int sub mov inc cmp jne cl ah,01h 21h al,30h [si],al si cl,02h entry

mov ah,09h mov dx,offset msg2 int 21h xor ax,ax mov mov mov shl si,offset deci ah,[si] al,[si+1] ah,03h

add al,ah 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 ;program to convert octal to decimal ; by sanjib das regn no 98011031 data segment msg1 db 'enter the octal number$' msg2 db 'the equivalent decimal no is :$' deci db 3 dup(?) data ends 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 mov int sub mov inc cmp jne cl ah,01h 21h al,30h [si],al si cl,02h entry

mov ah,09h mov dx,offset msg2 int 21h xor ax,ax mov si,offset deci mov ah,[si] mov al,[si+1]

shl ah,03h add al,ah 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

; program to find whether a string is a palindrome or not print macro msg mov ah,09h mov dx,offset msg int 21h endm better_display macro mov ah,02h mov dl,0ah int 21h mov dl,0dh int 21h endm print1 macro rr mov ah,02h mov dl,rr int 21h endm input_data macro mov ah,01h int 21h endm ;macro for inputting characters ;macro for displaying message

;macro for better display

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 start : mov ax,data mov ds,ax mov si,offset user_stack mov di,si better_display print msg1 mov ch,0h mov cl,0h ;counter for the string length 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 loop1 : cmp ch,cl je loop3 loop2: better_display print msg3 jmp last

loop3: better_display print msg2 last : mov ax,4c00h int 21h code ends end start

Sign up to vote on this title
UsefulNot useful