Mup Lab Manual

March 24, 2018 | Author: solo | Category: Ascii, Computer Architecture, Computer Engineering, Computer Hardware, Technology


Comments



Description

PART A; to generate FIBONACCI series(11A) .model small .stack 200 .data n dw 6 fib db 30 dup(?) .code mov ax,@data mov ds,ax lea si,fib mov [si],0 mov [si+1],1 mov cx,n sub cx,2 back: mov al,[si] add al,[si+1] mov [si+2],al inc si loop back int 3 ; initialization of data segment ; inside the code segment ;initializing first number ;initializing second number ; adding first & second number ; storing at as third number ; break point interrupt end BNMIT/CSE/Mp Lab Manual 1 ; sort the no using bubble sort(3A) .model small .stack 200 .data a db 23h,43h,12h,55h,11h len dw ($-a) .code mov ax,@data ; initialization of data segment mov ds,ax ; inside code segment mov bx,len dec bx outl: mov cx,bx mov si,0 inl: mov al,a[si] inc si cmp al,a[si] jb next xchg al,a[si] mov a[si-1],al next: loop inl ; outer loop from 0 to n-1 ; inner loop from 0 to outer loop ; comparison of 2 elements ; if greater exchange dec bx jnz outl mov ah,4ch int 21h ; interrupt to end the code segment end BNMIT/CSE/Mp Lab Manual 2 ;Binary Search-1A .model small .stack 200 .data a dw 1111h,3333h,5555h,7777h,9999h len dw ($-a)/2 key dw 2333h msg1 db 10,13,'successful search','$' msg2 db 10,13,'Unsuccessful search','$' .code mov ax,@data mov ds,ax mov ax,key mov si,0 mov di,len dec di again: cmp si,di ja notfound mov bx,si add bx,di shr bx,01 mov bp,bx shl bx,01 cmp ax,a[bx] je found jc midbig inc bp mov si,bp jmp again midbig: dec bp mov di,bp jmp again ; Initialization of Data Segment ; Inside Code Segment ; ax = Search key ; si = low ; di = high ; low > high ; bx = low + high ; bx = mid ; pointer adjustment ; Searching for key element ; mid = key ; si(low) = mid + 1 ; di (high) = mid - 1 found: lea dx,msg1 jmp exit BNMIT/CSE/Mp Lab Manual 3 notfound: lea dx,msg2 exit: mov ah,09h int 21h mov ah,4ch int 21h ; interrupt to display the ; message ; interrupt to end the ; program end BNMIT/CSE/Mp Lab Manual 4 ; linking of 2 macros which are (2A) included as library files with include c:\masm\jalaja\2a1.mac include c:\masm\jalaja\2a2.mac .model small .stack 200 .data msg db 10,13,"enter the data end with enter key",'$' a db 10 dup(?) .code mov ax,@data mov ds,ax lea dx,msg mov ah,09h int 21h ; initialization of data segment ; inside code segment ; interrupt to print ; the message mov si,0 again: read cmp al,13 je disp ; macro to accept i/p ; till ENTER key is pressed mov a[si],al inc si jmp again disp: mov dl,0ah mov ah,02 int 21h ; interrupt to move the ; cursor to next line mov cx,si mov si,0 begin: mov dl,a[si] writ inc si loop begin mov ah,4ch int 21h end ; macro to print a character BNMIT/CSE/Mp Lab Manual 5 02 int 21h .------2a1.01 int 21h ..-----2a2.mac-----read macro mov ah. interrupt to accept i/p endm . interrupt to print a character endm BNMIT/CSE/Mp Lab Manual 6 .mac-----writ macro mov ah. ax . procedure finding the factorial .stack 200 .code mov ax.1 ret fact endp end BNMIT/CSE/Mp Lab Manual 7 .@data mov ds. Factorial of a number using(8a) . inside code segment mov ax. procedure called recursively pop ax mul res mov res.---factorial procedure--fact proc cmp ax.data n dw 4 res dw ? .n call fact int 3 . recursive approach .model small . break point interrupt . initialization of data segment .ax ret exit: mov res.00 je exit push ax dec ax call fact .. . n+1 .data n dw 4 r dw 2 n dw ? .@data mov ds.1 ret ncrrec endp . ncr <.stack 200 .bx mul ncr div bx mov ncr.ax <.code mov ax. n+1-r .n mov bx.ax * ncr . ax <.4ch int 21h ncrrec proc cmp bx.ax/bx exit: mov ncr. nCr = (nC(r-1) * (n+1-r))/r .model small .0 je exit push ax push bx dec bx call ncrrec RA2: pop bx pop ax inc ax sub ax.r call ncrrec RA1: mov ah.1 end BNMIT/CSE/Mp Lab Manual 8 .ax ret . 9A Write an ALP to compute NCR using recursive procedure .ax mov ax. 13.cx lea dx. into code segment mov ah.'FILE NOT FOUND'.'1' je create cmp op.'FILE NOT CREATED'.13. program to create and to delete a file (15A) print macro msg lea dx.'$' m7 db 10.'$' m6 db 10. initialization of data segment mov ds.code mov ax. interrupt to accept the choice cmp op.data fname db 'c:\masm\jalaja\name.13.'$' m3 db 10..00 mov al.3ch xor cx.model small . interrupt to clear the screen print m2 mov ah.stack 200 .'$' m4 db 10.'$' m5 db 10.01 int 21h mov op.ax .'FILE DELETED'.02 int 10h .txt'. initialization into specified seg BNMIT/CSE/Mp Lab Manual 9 .'FILE CREATED'.'INVALID CHOICE'. fname int 21h jc cerror .13.@data .'enter 1) to create 2) to delete'. interrupt to create the file .13.'$' op db ? fhandle dw ? .al .09h int 21h endm . macro to print the message .0 m2 db 10.13.msg mov ah.'2' je delete jmp invalid create: mov ah. 4ch int 21h end BNMIT/CSE/Mp Lab Manual 10 .41h lea dx.print m3 jmp ter cerror: print m4 jmp ter delete: mov ah. interrupt to delete the file print m5 jmp ter derror: print m6 jmp ter invalid: print m7 ter: mov ah.fname int 21h jc derror . ax mov es. to reverse and check for PALINDROME(5A) print macro msg lea dx.13.str1 lea di. DF=0 .str2 mov cx.code mov ax.'$' msg2 db 10.stack 200 .09h int 21h endm .'string is NOT PALINDROME'. reversing the string .str2 mov cx.[si] mov [di]..'string is PALINDROME'.model small .13.msg mov ah.str1 lea di. interrupt to print the message .data msg1 db 10.len dec si back: mov al.len add si.msg2 jmp exit BNMIT/CSE/Mp Lab Manual 11 . inside code segment lea si.al inc di dec si loop back cld lea si.@data mov ds. initializing data & extra segment .ax .'$' str1 db 'diddd$' len dw ($-str1-1) str2 db 20 dup(?) . compare string byte by byte if equal lea dx.len repe cmpsb jz pali . 09h int 21h .4ch int 21h . interrupt to end the program end BNMIT/CSE/Mp Lab Manual 12 .pali: lea dx.msg1 exit: mov ah. interrupt to print the message mov ah. initialization of data & extra segment mov ds.msg3 exit: mov ah.model small .'$' .stack 200 .m1 lea di.len2 repe cmpsb pop di pop si jz found .data msg1 db 'this is a day' len1 dw ($-msg1) msg2 db 'ias' len2 dw ($-msg2) msg3 db 10.'SUBSTRING IS NOT PRESENT'. comparing string byte by byte inc si dec bx jnz again lea dx. .len1 sub bx.13..'$' msg4 db 10. initialization again: push si push di mov cx.4ch int 21h end BNMIT/CSE/Mp Lab Manual 13 .code mov ax.09h int 21h . interrupt to print the message mov ah. searching for sub-string in main string(10A) .msg4 jmp exit found: lea dx.ax mov bx. .13.ax .@data .m2 cld .len2 lea si.'SUBSTRING IS PRESENT'. . inside code segment mov es. 13. ‘strings are not equal $’ .13.---macro to print the message----print macro msg lea dx.13.code mov ax.?.13.0 str1 db 50 dup(?) m2 db 10.0 str2 db 50 dup(?) m3 db 10.stack 200 .ax mov es.@data mov ds. .str1buf mov ah.al print m3 BNMIT/CSE/Mp Lab Manual .?. .13.0ah int 21h mov al. .data m1 db 10.3030h mov len1.’the length of 1st string :’ len2 db ?. .’ enter 1st string :$’ str1buf db 50.’ enter 1st string :$’ str2buf db 50.’$’ m5 db 10.09h int 21h endm .’strings are equal $’ m6 db 10.msg mov ah.’the length of 1st string :’ len1 db ?. unpacking the data or ax.’$’ m4 db 10.ax print m1 lea dx.00 aam . getting ASCII equivalent of unpacked data 14 .13. str1buf+1 mov ah.ah mov len1+1. .model small .accepting 1st string ..string comparison and print its length(6a) . 00 aam . str2buf+1 mov ah. unpacking the data or ax.str1buf+1 cmp al.str1 lea di.str2 mov ch. . mov al.print m2 lea dx.strbuf+1 repe cmpsb je equal notequal: print m6 jmp exit equal: print m5 exit: mov ah.3030h mov len2.str2buf mov ah.ah mov len2+1.al print m4 .str2buf+1 jne notequal cld lea si.accepting 2nd string . getting ASCII equivalent of unpacked data mov al.0ah int 21h . .4ch int 21h end BNMIT/CSE/Mp Lab Manual 15 .00 mov cl. . . @data ..prompt mov ah.ax . to accept the name and display at(7a) . entire screen with blank space .0 int 10h . interrupt to print the message . specified position on the screen .09 int 21h loop ag .0.09h int 21h lea dx.02 mov bh.myname mov ah. bh=page 0 .data blank10 db ' $' prompt db 'what is your name? :$' rowpos db 10 colpos db 27 myname db 50. interrupt filling .rowpos mov dl. placing cursor at bottom of the screen mov dh.code mov ax. inside code segment mov cx. dl=column address lea dx.200 ag: lea dx.model small .50 dup(?) .4ch int 21h end BNMIT/CSE/Mp Lab Manual 16 . initialization of data segment mov ds. dh=row address .colpos mov ah. interrupt to accept the message mov ah. interrupt to place the cursor .0ah int 21h .blank10 mov ah.stack 200 . cl jmp l1 exit: mov ah.stack 200 . converting to ascii . accept system time mov al.data msg db ' hrs : min'.'$' .ch mov si.ah mov ah.msg mov ah.00 aam or ax. interrupt to print the message mov al. interrupt to . interrupt to end code segment end BNMIT/CSE/Mp Lab Manual 17 .ax mov ah.2ch int 21h .09h int 21h .02 int 21h dec si jz exit lea dx.@data mov ds. printing on to screen pop ax mov dl.02h int 21h ..model small .al mov ah.3030h push ax mov dl.02 l1: mov ah.4ch int 21h .code mov ax. to display SYSTEM TIME(12A) . macro to read 2-digit number print m2 readnum col .al mov ah.@data .. interrupt to read first number int 21h sub al. macro to print the message .'0' mov cl.stack 200 . placing it to tens place from unit place .----macro to print msg ----print macro msg lea dx. convertion to decimal from ascii .13. to position the cursor (14A) . interrupt to clear the screen 18 .'enter the row:'.'$' m2 db 10.macro to read 2-digit number mov ah.09h int 21h endm . adding to previous data placed at tens place .'$' m3 db ‘cursor is here $’ . into code segment print m1 readnum row .13. accepting the second digit .cl mov num. at specified row and column .'0' add num.00 mov al.02 BNMIT/CSE/Mp Lab Manual . initialization of data segment mov ds.msg mov ah.'enter the col:'.01h .4 ror al.----macro to read row and col---readnum macro num mov ah.01 int 21h sub al. macro to print the message .data row db ? col db ? m1 db 10.code mov ax. convertion to decimal from ascii .al endm .model small .ax . 00 int 10h .01 int 21h mov ah.int 10h mov ah. interrupt to position the cursor at specified .col mov bh.4ch int 21h end BNMIT/CSE/Mp Lab Manual 19 .02 mov dh.row mov dl. row & column print m3 mov ah. . retaining lower 4-bits .cl cmp al.stack 200 .28h .4 shr al.09h int 21h . interrupt to accept an i/p and al.msg mov ah. positioning row .al mov al. mask off LSB 4-bits & retain higher 4-bits .bl and al.code mov ax.model small . initialization of data segment mov ds. interrupt to print the message mov ah.0f0h mov cl. and display its ASCII EQUIVALENT . conversion to its ascii value .30h mov ascii+1. to clear the screen lea dx.ax .@data .01h int 21h mov bl.09h jle sum30 add al.00 mov al.al . to accept alphanumeric character(4A) . and column to centre BNMIT/CSE/Mp Lab Manual 20 .0fh cmp al.0ch mov dl.02 int 10h . conversion to its ascii value add al.'$' .30h mov ascii.07 ad30: add al. inside code segment mov ah.07 sum30: add al.al mov dh.09 jle ad30 .data ascii db 2 dup(?) msg db "enter the alph or numeric data". 02 int 21h .00 mov ah.02h int 10h .2 mov si. interrupt to print a character inc si dec bl jnz ag mov ah.4ch int 21h . interrupt to end the program end BNMIT/CSE/Mp Lab Manual 21 .0 ag: mov dl.ascii[si] mov ah.mov bh.of the screen in page 0 mov bl. .al mov ah.02 int 10h mov ch.------display procedure-----display proc mov dh.30 mov bh.ch and al. initial value .0fh add al.02 int 21h mov al.stack 200 .0f0h mov cl.al and al.02h .al mov ah. procedure to display the number mov ah. getting first 4-bits . converting to ascii .code mov al.4 shr al.1 daa push ax push cx call display call delay pop cx pop ax loop rpt . converting to its ascii value .100 rpt: add al.30h mov dl. extracting 1st MSB digit . conversion to BCD .30h mov dl.4ch int 21h .15 mov dl. getting it to units place . to display the data BNMIT/CSE/Mp Lab Manual 22 .model small . count =100 . to generate DECIMAL UP counter 00 – 99(13A) .99h mov cx.00 mov ah.cl add al. 2000h loc1: mov cx.0fffh loc2: loop loc2 dec bx jnz loc1 pop cx pop bx ret delay endp end BNMIT/CSE/Mp Lab Manual 23 .int 21h ret display endp delay proc push bx push cx mov bx. stack 200 .bl mov dx.@data mov ds.8ah mov dx.pb in al.ctrl out dx.PART B .msg mov ah. o/p through port c mov dx. to check for odd or even(1B) .al .0 ag: rol al. pb=i/p mov dx.code mov ax.dx . interrupt to display the message mov al.ax lea dx.1 jnc noinbl inc bl noinbl: loop ag mov al. accept the i/p bg: mov cx.pa ror bl.model small . port address assigned in order pb=0d881h pc=0d882h ctrl=0d883h msg db 'press any key to come to dos prompt'.'$' .pc out dx. control word decision . pa=o/p .1 jc disp00 BNMIT/CSE/Mp Lab Manual 24 .al .8 mov bl.data pa=0d880h .09h int 21h . o/p through port a mov dl.4ch int 21h end BNMIT/CSE/Mp Lab Manual 25 .0ffh mov ah.00 nxt: out dx. or i/p is accepted mov ah. interrupt that waits until any key .06h int 21h jz bg .al .mov al.0ffh jmp nxt disp00: mov al. model small .al call delay mov dl. interrupt to display the message .data pa=0d880h .0ffh mov ah. BCD RING COUNTER(2B1) .ctrl out dx. control word decision mov al.01 mov dx.msg mov ah.al . port address assigned in order pb=0d881h pc=0d882h ctrl=0d883h msg db 'press any key to come to dos prompt$' .pa back: push ax push dx out dx.ax lea dx.@data .09h int 21h mov al. initialization of data segment in CS mov ds..06h int 21h jnz exit pop dx pop ax rol al. interrupt that waits until any key is pessed exit: mov ah.4ch int 21h BNMIT/CSE/Mp Lab Manual 26 .8ah mov dx.code mov ax.stack 200 .1 jmp back . procedure with suitable delay end BNMIT/CSE/Mp Lab Manual 27 .2000h tere:mov cx.0ffffh here:loop here dec di jnz tere ret delay endp ..-----delay procedure-----delay proc mov di. 0 back: push ax mov dx.@data . initialization of data segment in CS mov ds. BCD UP(1)-DOWN(1) COUNTER(2B2) .al .stack 200 . control word decision mov al.code mov ax. port address assigned in order pb=0d881h pc=0d882h ctrl=0d883h msg db 'press any key to come to dos prompt$' .0ffh mov ah.1 pop ax jc up down: sub al.1 das jmp back up: add al.ctrl out dx.pb in al.06h int 21h jnz exit mov dx.data pa=0d880h . interrupt that waits until any key is pessed .09h int 21h .1 daa .pa out dx. interrupt to display the message mov al. accepting the i/p from port B BNMIT/CSE/Mp Lab Manual 28 ..8ah mov dx.dx ror al.ax lea dx.msg mov ah.al call delay mov dl.model small . 0ffffh here:loop here dec di jnz tere ret delay endp .2000h tere:mov cx. procedure with suitable delay end BNMIT/CSE/Mp Lab Manual 29 .4ch int 21h .jmp back exit: mov ah.---delay procedure----delay proc mov di. ctrl out dx.ah out dx.@data .data pa=0d880h .13.pb in al.13. port address assigned in order pb=0d881h pc=0d882h ctrl=0d883h m1 db 10.09h int 21h mov dx.pa mov al.ax mov al.09h int 21h . interrupt to display the message bg: mov dx. initialization of data segment in CS mov ds.model small .al .8ah mov dx. accepting the 2’nd i/p from port B mul bl push ax mov dx.’ enter 2nd data from port B$’ msg db 'press any key to come to dos prompt$' .code mov ax.’ enter 1st data from port B$’ m2 db 10.al BNMIT/CSE/Mp Lab Manual 30 .dx .dx mov bl. interrupt to display the message .m1 mov ah..pb in al. MULTIPLICATION OF 8 bit * 8 bit(3B) .al .m2 mov ah. control word decision lea dx. accepting the 1’st i/p from port B call delay lea dx.stack 200 . 4ch int 21h delay proc mov di.al mov ah. procedure with suitable delay end BNMIT/CSE/Mp Lab Manual 31 .0ffffh here:loop here dec di jnz tere ret delay endp .call delay pop ax mov dx.pa out dx.2000h tere:mov cx. interrupt that waits until any key is pessed mov ah.0ffh.stack 200 .86h.09h int 21h .4ch int 21h .-----display procedure---disp proc BNMIT/CSE/Mp Lab Manual 32 . port address assigned in order pc=0d882h ctrl=0d883h msg db 'press any to come to dos prompt$' fire db 86h.blnk call disp call delay lea si.ctrl mov al. initialization of data segment in CS mov ds. interrupt to display the message mov dx.0ceh.01 int 16h jz start .help call disp call delay mov ah.data pa=0d880h pb=0d881h .al start: lea si.TO DISPLAY FIRE AND HELP ALTERNATIVELY(4B) .0ffh.fire call disp call delay .80h out dx.msg mov ah.0ffh help db 8ch.model small . control word decision lea si.0c7h.0cfh..code mov ax.ax lea dx.@data .89h .8eh blnk db 0ffh. al pop ax dec bl jnz nxtbit inc si loop nxtchr ret disp endp .00 out dx.11h out dx.4 nxtchr: mov bl.1 mov dx.0ffffh tere:mov cx.-----delay procedure-----delay proc mov di.al push ax mov dx. procedure with suitable delay end BNMIT/CSE/Mp Lab Manual 33 .pb out dx.8 mov al.mov cx. giving the clock pulse mov al.2000h here:loop here dec di jnz tere ret delay endp .[si] nxtbit: rol al.al .pc mov al. ax .ctrl mov al.code mov ax.4ch int 21h BNMIT/CSE/Mp Lab Manual 34 .0b0h. port address assigned in order pc=0d882h ctrl=0d883h msg db 'press any to come to dos prompt$' table db 0c0h.TO DISPLAY 12 char in rolling fashion(5B) .table mov cx.10 nxtchr: mov al.01 int 21h jz start .stack 200 .99h db 92h. control word decision . initialization of data segment in CS lea dx.msg mov ah.82h.0a4h.@data mov ds.[si] call disp call delay inc si loop nxtchr mov ah.09h int 21h .data pa=0d880h pb=0d881h .al start: lea si.model small .80h out dx. interrupt that waits until any key is pessed mov ah.98h . interrupt to display the message mov dx.80h.0f9h..0f8h. 00 out dx.-----delay procedure-----delay proc mov di.8 nxtbit: rol al.11h out dx..1 mov dx. procedure with suitable delay end BNMIT/CSE/Mp Lab Manual 35 .pc mov al.al pop ax dec bl jnz nxtbit ret disp endp . giving the clock pulse mov al.0ffffh tere:mov bx.al push ax mov dx.al .-----display procedure---disp proc mov bl.2000h here:dec bx jnz here dec di jnz tere ret delay endp .pb out dx. 0f9h.09 int 21h mov cx.98h msg db 0ffh.0f8h.m1 mov ah.al lea dx.0b0h.0 mov bl.0ffh num dw 0ffffh bcd db 5 dup(?) .0ffh.0ffh.code mov ax.00 jnc noinc BNMIT/CSE/Mp Lab Manual 36 .99h db 92h.80h mov dx.model small .data pa=0d880h pb=0d881h .al mov al.0ffh..ah daa mov ah.stack 200 .@data mov ds.ctrl out dx.82h.80h.0ffh.01 mov al.?. port address assigned in order pc=0d882h ctrl=0d883h msg db 'press any to come to dos prompt$' table db 0c0h.?.?. .ax mov al.?. ?.0ffh.0a4h.Convert a 16 bit binary or hexa value to BCD and display it from left to right and right to left for specified number of times on a 7 seg display unit.0ffh.0 jcxz exit ag: add al.01 daa jnc noinc add ah.num mov ax. 10h mov ah.0 mov al.msg back : mov si.bcd lea di.ah mov bcd+4.0 mov al.al mov ah.al dec di inc si loop next start: mov bh.ax mov bl.di push bx call disp call delay call kbhit pop bx inc di dec bh jnz back BNMIT/CSE/Mp Lab Manual 37 .bl mov dx.5 next: mov al.dh div bl mov bcd+1.table mov cx.inc bl noinc: loop ag exit: mov bcd.ah mov bcd+2.10h lea di.msg+8 lea bx.[si] xlat mov [di].al mov si.dl div bl mov bcd+3. [si] nxtbit: rol al.msg+9 back1: mov si.10 lea di.1 mov dx.di push bx call disp call delay pop bx dec di dec bh jnz back1 jmp start .8 mov al.0ffh out dx.al pop ax dec bl jnz nxtbit inc si loop nxtchr ret disp endp BNMIT/CSE/Mp Lab Manual 38 .al push ax mov dx.pb out dx.00 out dx.pc mov al.4 nxtchr: mov bl. giving the clock pulse mov al.mov bh.al .-----display procedure---disp proc mov cx. -----delay procedure-----delay proc push di push bx mov di.4ch int 21h kbhit endp .for repetation and ending purpose------kbhit proc mov ah.-----./.2000h here:dec bx jnz here dec di jnz tere . procedure with suitable delay pop bx pop di ret delay endp end BNMIT/CSE/Mp Lab Manual 39 .0ffffh tere:mov bx.01 int 16h jnz exit ret exit: mov ah. 4ch int 21h . initialization of data segment in CS mov ds.09h int 21h .data pa=0d880h .88h ag: out dx.2000h tere:mov cx..stack 200 .ax lea dx.80h mov dx. port address assigned in order pb=0d881h pc=0d882h ctrl=0d883h n dw 10 msg db 'rotation in clock wise'. STEPPER MOTOR IN CLOCK WISE(7B) .n mov dx.model small . control word decision mov cx.code mov ax. procedure with suitable delay 40 . interrupt to display the message mov al.---delay procedure--delay proc mov di.ctrl out dx.al push cx call delay pop cx ror al.'$' .1 loop ag .@data . output the data through port mov ah.msg mov ah.0ffffh here:loop here dec di jnz tere ret delay endp end BNMIT/CSE/Mp Lab Manual .pc mov al.al . ax lea dx. STEPPER MOTOR IN ANTI-CLOCK WISE(8B) . procedure with suitable delay 41 .pc mov al.@data .n mov dx.---delay procedure--delay proc mov di.data pa=0d880h .1 loop ag .0ffffh here:loop here dec di jnz tere ret delay endp end BNMIT/CSE/Mp Lab Manual .model small . initialization of data segment mov ds.09h int 21h mov al.code mov ax.al .msg mov ah. port address assigned in order pb=0d881h pc=0d882h ctrl=0d883h n dw 10 msg db 'rotation in anti-clock wise'.'$' .ctrl out dx.88h ag: out dx.stack 200 . output the data through port mov ah. control word decision mov cx.2000h tere:mov cx.80h mov dx.4ch int 21h ..al push cx call delay pop cx rol al. port address assigned in order pb=0d881h pc=0d882h ctrl=0d883h n dw 10 msg db 'rotation in clock & anti clock wise'.@data .n mov dx.code mov ax. interrupt to display the message mov al.ax lea dx.09h int 21h .80h mov dx. output the data through port mov cx.al push cx call delay pop cx rol al.pc mov al.al push cx call delay pop cx ror al.n mov dx. control word decision mov cx.'$' . initialization of data segment mov ds.88h bg: out dx.1 loop bg BNMIT/CSE/Mp Lab Manual 42 .1 loop ag .pc mov al.data pa=0d880h .88h ag: out dx. & ANTI-CLOCK WISE(n-steps) .al .stack 200 .msg mov ah. STEPPER MOTOR IN CLOCK WISE(n steps)(9B) ..model small .ctrl out dx. mov ah.0ffffh here:loop here dec di jnz tere ret delay endp end BNMIT/CSE/Mp Lab Manual . procedure with suitable delay 43 .---delay procedure--delay proc mov di.2000h tere:mov cx.4ch int 21h . [si] mov dx.210. interrupt to display the message .@data .192.al inc si loop back mov ah.226.150.. port address assigned in order pb=0d881h pc=0d882h ctrl=0d883h table db 128.ax lea dx.pa out dx.254.17.192.09h int 21h mov dx.248 db 238.0. initialization of data segment mov ds.45.17.36 lea si.29.105 msg db 'press any key to come to dos prompt'.29.84.238.64.105.al start: mov cx.150.'$' .80h out dx.45.model small .code mov ax.128.1.4ch int 21h end BNMIT/CSE/Mp Lab Manual 44 . output the data through port mov dx.01 int 16h jz start mov ah. GENERATION OF SINE WAVE(12B) value = 128 + 128 sine @ .stack 200 .7.171.table back: mov al.248.84.64.msg mov ah.al .data pa=0d880h .210. control word decision .pb out dx.254.ctrl mov al.7. db 0.226.171.1. pa out dx.msg mov ah. interrupt to display the message .128 msg db 'press any key to come to dos prompt'.150.18 mov al..226.210. control word decision mov cx.code mov ax.254.254.18 lea si.192.171.09h int 21h mov dx. initialization of data segment .@data mov ds.238.al inc si loop back mov cx.248 db 238.171.80h out dx.pa out dx.226.[si] mov dx. output the data through port 45 .ax lea dx. port address assigned in order pb=0d881h pc=0d882h ctrl=0d883h table db 128.stack 200 .al .192.al BNMIT/CSE/Mp Lab Manual . GENERATION OF HALF-RECTIFIED WAVE(13B) .table back: mov al.pb out dx.'$' .248. output the data through port mov dx.128 back2: mov dx.data pa=0d880h .150.model small .210.al start: .ctrl mov al. mov dx.4ch int 21h end BNMIT/CSE/Mp Lab Manual 46 .01 int 16h jz start mov ah.al loop back2 mov ah.pb out dx. output the data through port mov dx. GENERATION OF FULL-RECTIFIED WAVE(14B) .4ch int 21h end mov ah.ctrl mov al.210.150.150.238.09h int 21h mov dx.01 int 16h BNMIT/CSE/Mp Lab Manual 47 .248. initialization of data segment mov ds.226.ax lea dx.210.al .226.128 msg db 'press any key to come to dos prompt'.al inc si loop back mov ah..data pa=0d880h .[si] mov dx.171.model small .table back: mov al.pb out dx. control word decision .msg mov ah.'$' .01 int 16h jz start mov ah.254.171.254.al start: mov cx.pa out dx.248 db 238.192.192.stack 200 .code mov ax.18 lea si. port address assigned in order pb=0d881h pc=0d882h ctrl=0d883h table db 128. interrupt to display the message .@data .80h out dx. jz start mov ah.4ch int 21h end BNMIT/CSE/Mp Lab Manual 48 .4ch int 21h end mov ah.01 int 16h jz start mov ah. 1’st led is ON mov dx. accept the i/p . control word decision mov dx.dx and al.0fh jz scan mov ch.ctrl mov al.1 add ch.code mov ax.pb scan: in al.al .al .model small .ch .0f0h again: inc al BNMIT/CSE/Mp Lab Manual 49 .0fh cmp al..pa mov al. initializing all led’s to 0 or OFF mov al.ax . initialization of data segment mov ds.bh add ch. servicing floor rol ch.1 jnc firid inc ch jmp findagn firid: mov bh.stack 200 .data pa=0d880h .al .0 out dx. port address assigned in order pb=0d881h pc=0d882h ctrl=0d883h .0f0h out dx. inside the code segment mov dx.82h out dx. ELEVATOR INTERFACE(15B) .@data .0f0h mov al.0 findagn: shr al. 0fh out dx.0f0h dngain: out dx.al jne again down: mov si.5 back: push cx call delay pop cx dec si jnz back . procedure with suitable delay 50 .pa out dx.4ch int 21h delay proc mov di.al push cx call delay pop cx cmp ch. procedure with suitable delay and al.2400h here: loop here dec di jnz there ret delay endp end BNMIT/CSE/Mp Lab Manual .0ffffh there: mov cx.al or al. traversing down ward .mov dx.0efh jne dngain mov ah.al push cx call delay pop cx dec al cmp al. @data .stack 200 .90h mov dx.cl add bh.'$' msg db 'the row & col address :' aski db ?.?. initialization of data segment mov ds.%ce' .'$' table db '0123456789+-*/.06 mov dl.ah mov al.0ffh int 21h jnz quit .13.3 rol bh.13.model small . OF THE KEY PRESSED . control word decision mov ah.. interrupt that waits until any key is pessed call scan cmp si.al .0 je ag push ax push bx mov cl.10.'$' m1 db 'the key pressed is :' scancode db ?.prompt int 21h . ROW & COLUMN INFORMATION(10B) .ax mov al.10.bh BNMIT/CSE/Mp Lab Manual 51 .09h lea dx.ctrl out dx. interrupt to display the message ag: mov ah.10.data pa=0d880h .code mov ax.' '. port address assigned in order pb=0d881h pc=0d882h ctrl=0d883h prompt db 'press any key to come to dos prompt'.13. 09h int 21h pop bx pop ax add bh.30h mov aski+2.80h nxtrow: rol al.al lea dx. procedure with suitable delay quit: mov ah.ah lea dx.2fffh mov cx.*****SCAN PROCEDURE****** scan proc mov si.m1 mov ah.al BNMIT/CSE/Mp Lab Manual .0ffffh here:loop here dec di jnz here jmp ag .09h int 21h mov di.al mov dx.bh add ah.30h mov aski.0 mov al.3 mov bh. row selection 52 .msg mov ah.0 mov cx.pc out dx.lea dx. interrupt to display the message .1 mov bl.table xlat mov scancode.4ch int 21h . 0 ag2: ror al.dx .1 mov cx.mov dx. accepting the i/p from port A cmp al.bl inc bh loop nxtrow ret keyid: mov si.0 jnz keyid mov al.08 mov ah.1 jc skip inc ah loop ag2 skip: ret scan endp end BNMIT/CSE/Mp Lab Manual 53 .pa in al. msg mov ah. DOING ADD & SUB print macro msg lea dx.10.stack 200 . initialization of data segment mov ds.0 je ag1 mov cl.0 ag2: push cx ag1: call scan cmp si.model small .ctrl out dx.bh mov bp.20000 tere:mov cx..code mov ax.09h int 21h endm .cl add bh.13.ax mov al. procedure with suitable delay 54 .NUM2'.ah mov inputs[di].'$' .al .3 rol bh.data pa=0d880h . SIMPLE CALCULATOR(11B).@data .90h mov dx. port address assigned in order pb=0d881h pc=0d882h ctrl=0d883h result db ? inputs db 3 dup(?) msg db 'enter the input as NUM1 +/. control word decision print m1 mov cx.0ffffh here:loop here dec bp BNMIT/CSE/Mp Lab Manual .3 mov di. Row selection mov dx.al quit: mov dl.3 mov bh.al .0 mov cx.30h mov ah.inputs+2 mov result.bl inc bh loop nxtrow ret BNMIT/CSE/Mp Lab Manual 55 .pa in al.1 mov bl.80h nxtrow: rol al.4ch int 21h .al jmp quit minus: sub al.0 jnz keyid mov al. accepting the i/p from port A cmp al.dx .0ah jne minus add al.inputs cmp inputs+1.result add dl.02 int 21h mov ah.inputs+2 mov result.jnz tere inc di pop cx loop ag2 mov al.*****SCAN PROCEDURE****** scan proc mov si.0 mov al.al mov dx.pc out dx. 1 jc skip inc ah loop agg skip: ret scan endp end BNMIT/CSE/Mp Lab Manual 56 .keyid: mov si.08 mov ah.0 agg: ror al.1 mov cx.
Copyright © 2024 DOKUMEN.SITE Inc.