MP Manual
MP Manual
MP Manual
Microprocessor Manual
DESGINED BY
J.PRAKASH
M.SHILPA
Lecturer ISE Department
B.E , M.TECH
BIT
ISE Dept
Microprocessor Manual
PROGRAM 1A
Search a key element in a list of N numbers using binary search
.MODEL SMALL ; type of model .STACK 64H .DATA ; Data segment begins ARRAY DW 1000H,2000H,3000H,4000H,5000H,6000H
;a sorted array
.CODE
LEN DW ($-ARRAY)/2 ; to find the length of the array MSG DB 0AH,0DH, ' THE KEY TO BE FOUND : 3000H $' KEY DW 3000H ; key to be searched SUC DB 0AH,0DH, ' SUCCESSFUL SEARCH !! FOUND AT POSITION ' POS DB ' $' FAIL DB 0AH,0DH, 'UNSUCCESSFUL SEARCH !! $' ; code segment begins MOV AX,@DATA ; move the address of the data segment to DS MOV DS,AX ; to o/p the key to be searched
LEA DX,MSG MOV AH,09H INT 21H MOV BX,1 MOV DX,LEN MOV CX,KEY AGAIN : CMP BX,DX JA FAILURE MOV AX,BX ADD AX,DX SHR AX,1 MOV SI,AX DEC SI ADD SI,SI CMP CX,ARRAY[SI] JAE NEXT DEC AX MOV DX,AX JMP AGAIN NEXT : JE SUCCESS INC AX MOV BX,AX JMP AGAIN SUCCESS : ADD AL,'0' MOV POS,AL LEA DX,SUC JMP DISPLAY1 FAILURE : LEA DX,FAIL DISPLAY1 : MOV AH,09H INT 21H MOV AH,4CH INT 21H END
; BX register stores the low value ;DX has the high value ; compare low and high ; if (low >high) then the search has failed ;to find the mid ;mid =(low+high)/2 ; shifting right to divide by 2
; compare key with array[mid] ; if equal search is successful ;else change low and high appropriately ; loop back ; check again if key=array[mid] ; if so find the position where it is found
; END of program
BIT
ISE Dept
Microprocessor Manual
PROGRAM 1B
READ THE STATUS OF A BIT INPUT FROM LOGIC CONTROLLER AND DISPLAY FF IF EVEN PARITY OTHERWISE 00. ALSO DISPLAY THE NUMBER OF ONES.
.MODEL SMALL .STACK 64H .CODE MOV AL,82H MOV DX,0A403H OUT DX,AL MOV DX,0A401H IN AL,DX MOV BL,AL AND AL,0FFH JP EV JMP ODD EV: MOV DX,0A400H MOV AL,0FFH OUT DX,AL CALL DILAY JMP COUNT ODD: MOV DX,0A400H MOV AL,00H OUT DX,AL CALL DILAY JMP COUNT DILAY PROC PUSH BX PUSH CX MOV BX,4FFFH LOOP2: MOV CX,0FFFFH LOOP1: LOOP LOOP1 DEC BX JNZ LOOP2 POP CX POP BX RET DILAY ENDP COUNT: MOV CL,08H MOV BH,00H CLC LP: ROR BL,01 ; 8 bits ; to count the no. of ones
; check parity
BIT
ISE Dept
JNC LP2 INC BH LP2: LOOP LP MOV DX,0A400H MOV AL,BH OUT DX,AL MOV AH,4CH INT 21H END
Microprocessor Manual
BIT
ISE Dept
Microprocessor Manual
PROGRAM 2A
MAIN MODULE: PROGRAM TO CALL TWO FAR PROCEDURES FOR READING AND PRINTING CHARACTERS INPUT FROM A KEYBOARD
.MODEL SMALL .STACK 64H .DATA ARR DB 50 DUP (?) .CODE EXTRN READKEY : FAR EXTRN ECHO : FAR START : MOV AX,@DATA MOV DS,AX MOV SI,OFFSET ARR MOV DI,OFFSET ARR MOV CX,00H NEXT : CALL READKEY INC CX CMP AL,0DH JNZ NEXT MOV DL,10 MOV AH,02H INT 21H MOV DL,13 MOV AH,02H INT 21H NEXT1 : MOV DL,[DI] CALL ECHO INC DI LOOP NEXT1 MOV AH,4CH INT 21H END START END
BIT
ISE Dept
Microprocessor Manual
BIT
ISE Dept
Microprocessor Manual
PROGRAM 2B
Simulating BCD up-down counter and ring counter
.MODEL SMALL .DATA MSG1 DB 10,13,"STIMULATING BCD UP_DOWN COUNTER $" MSG2 DB 10,13,"STIMULATING RING COUNTER $" .CODE MOV AX,@DATA ; initialize the data segment MOV DS,AX MOV ES,AX ; and also the extra segment MOV AH,09H ; print MSG1 LEA DX,MSG1 ; to tell what function its doing INT 21H MOV MOV OUT MOV MOV UP_CNTR: OUT DX,AL CMP AL,09H JGE NEXT1 INC AL CALL DE_LAY JMP UP_CNTR NEXT1: MOV AL,09H DOWN_CNTR: OUT DX,AL CMP AL,00H JE NEXT2 DEC AL CALL DE_LAY JMP DOWN_CNTR NEXT2: MOV AH,01H INT 21H MOV AH,09H LEA DX,MSG2 INT 21H MOV AL,01H MOV CX,10H MOV DX,120H RING_CNTR: OUT DX,AL CALL DE_LAY ROR AL,1 LOOP RING_CNTR MOV AH,4CH INT 21H DE_LAY PROC ; start counter from 9 ; o/p the count ; if count >=9 start down counter ; else increment AL and loop back ; wait after each display AL,82H DX,0A403H DX,AL DX,0A400H AL,00H ; move the control word into CWR
; o/p the count ; if count is <=0 start down ; else dec al and loop back ; wait after each display
counter
; display MSG2 ; pattern for ring counter ; it needs to rotate this many times ; port A address ; o/p the bit pattern ; wait ; rotate the pattern ; return to DOS
BIT
ISE Dept
PUSH CX MOV CX, 3FFFH LP1: MOV BP,FFFFH LP2: DEC BP JNZ LP2 LOOP LP1 POP CX RET DE_LAY ENDP END ; of any register
Microprocessor Manual
; end of program
BIT
ISE Dept
Microprocessor Manual
PROGRAM 3A
PROGRAM TO SORT THE GIVEN SET OF ELEMENTS IN ASCENDING AND DESCENDING ORDER
.MODEL SMALL .STACK 64 .DATA ARR DB 17H,3H,10H,5H,00H,14H,23H COUNT EQU 07H ; 7 Array elements N DB 25 DUP(0) MSG1 DB 10,13,' HOW DO YOU WANT TO SORT THE ARRAY ? $' MSG2 DB 10,13,' 1:> ASCENDING ORDER 2:> DESCENDING ORDER $' MSG3 DB 10,13,' ENTER YOUR CHOICE : $' .CODE MOV AX,@DATA ; Load the address of DATA SEGEMENT into DS MOV DS,AX LEA SI,ARR LEA DX,MSG1 ; ask the user if he wants to in ascending MOV AH,09H ; or descending order INT 21H LEA DX,MSG2 MOV AH,09H INT 21H LEA DX,MSG3 MOV AH,09H INT 21H MOV CX,COUNT-1 MOV DX,CX MOV AH,01H INT 21H ; compare your choice with 1 CMP AL,'1' ; if 1 sort in ascending order JZ ASCEND ; else descending order JMP DESCEND ASCEND : ; bubble-sort for ascending order LP1 : ; outer loop begins MOV CX,DX LEA SI,ARR LP2 : ; inner loop begins MOV AL,[SI] CMP AL,[SI+1] JB NEXT1 XCHG [SI+1],AL ; swapping elements XCHG [SI],AL NEXT1 : ADD SI,01 LOOP LP2 ; inner loop ends DEC DX JNZ LP1 ; outer loop ends JMP STOP DESCEND : ; bubble sort descending order LP3 : ; outer loop starts MOV CX,DX MOV SI,OFFSET ARR LP4 : ;inner loop starts
BIT
ISE Dept
MOV AL,[SI] CMP AL,[SI+1] JGE NEXT2 XCHG [SI+1],AL XCHG [SI],AL NEXT2: ADD SI,01 LOOP LP4 DEC DX JNZ LP3 STOP : MOV AH,4CH INT 21H END ; return to DOS ; inner loop ends ; outer loop ends
Microprocessor Manual
; swapping of elements
BIT
10
ISE Dept
Microprocessor Manual
PROGRAM 3B
READ THE STATUS OF 2 8-BIT INPUTS x AND y USING LOGIC CONTROLLER AND DISPLAY x*y
.model small .stack 64h .data msg1 db 10,13,"entr the first operand $" msg2 db 10,13,"enter the second operand $" opr1 db ? opr2 db ? ; the two numbers .code ; start the code segment mov ax,@data ; load address into data segment mov ds,ax mov al,82h mov dx,0123h out dx,al lea dx,msg1 mov ah,09h int 21h mov ah,01h int 21h mov dx,0121h in al,dx mov opr1,al lea dx,msg2 mov ah,09h int 21h mov ah,01h int 21h mov dx,0121h in al,dx mov opr2,al mov ah,00h mov bl,opr1 mul bl mov bx,ax mov dx,0120h out dx,al controller mov ah,01h int 21h mov al,bh out dx,al mov ah,01h int 21h mov ah,4ch int 21h end
; address of CWR ; load control word into CWR ; ask user to enter the first number
; multiply two operands ; move to register AX ; see the lower byte on the logic
; wait until user wants to see the result ; i.e., the higher byte
; return to DOS
BIT
11
ISE Dept
Microprocessor Manual
PROGRAM 4A
PROGRAM TO PRINT A ALPHANUMERIC CHARACTER AT THE CENTRE OF THE SCREEN
.MODEL SMALL .DATA MSG DB 10,13," ENTER A ALPHANUMERIC CHARACTER : $" CHAR DB 0 .CODE MOV AX,@DATA ; Load the address of DATA SEGEMENT into DS MOV DS,AX LEA DX,MSG ; load the starting address of MSG MOV AH,09H ; display the message INT 21H MOV AH,01H INT 21H MOV CHAR,AL ; store in CHAR AND AL,0F0H ; get the upper nibble MOV CL,04H ROR AL,CL ; rotate AL 4 times i.e divide by 16 MOV AH,02H ; move the cursor to the centre MOV BH,00 ; set the page number to 00 MOV DH,10 ; set the row to 10 MOV DL,40 ; set the column to 40 INT 10H CALL DISP ; display the upper nibble value MOV AL,CHAR AND AL,00FH ; get the lower nibble MOV DL,AL CALL DISP ; display the lower nibble value MOV AH,4CH INT 21H DISP PROC MOV DL,AL ; get the character to display CMP DL,09H ; check if the value is between 0-9 or A-F JLE NEXT ; if 0-9 add 30H to it SUB DL,0AH ; if A-F sub 0AH and add 41H ADD DL,41H JMP PRINT NEXT : ADD DL,30H ; if 0-9 add 30H to it PRINT : MOV AH,02H INT 21H RET ; return to main program DISP ENDP END ; end of the program
BIT
12
ISE Dept
Microprocessor Manual
PROGRAM 4B
TO DISPLAY FIRE AND HELP ON A 7-SEGMENT DISPLAY
.MODEL .STACK .DATA A1 A2 SMALL 64h DB 86h,88h,0f9h,8eh DB 8ch,0c7h,86h,89h
MOV AL,80H MOV DX,0A403H OUT DX,AL MOV BH,0AH AGAIN: LEA SI,A1 CALL DISP CALL DELAY LEA SI,A2 CALL DISP CALL DELAY DEC BH CMP BH,00H JE EXIT JMP AGAIN DISP PROC MOV CX,04H LOOP2: MOV BL,08H MOV AL,[SI] NEXT: ROL AL,01H MOV DX,0A401H OUT DX,AL PUSH AX MOV AL,0FFH MOV DX,0A402H OUT DX,AL MOV AL,00H OUT DX,AL DEC BL POP AX JZ NEXT1 JMP NEXT NEXT1: INC SI LOOP LOOP2
; control word
; load SI which contains the code for FIRE ; display it ; load SI which contains the code for HELP ; display it
BIT
13
ISE Dept
RET DISP ENDP
Microprocessor Manual
DELAY PROC PUSH CX PUSH AX MOV CX,1FFFH N1: MOV AX,0FFFFH N2: DEC AX JNZ N2 LOOP N1 POP AX POP CX RET DELAY ENDP EXIT: MOV AH,4CH INT 21H END
; end of program
BIT
14
ISE Dept
Microprocessor Manual
PROGRAM 5A
PROGRAM TO REVERSE A GIVEN STRING AND CHECK IF IT IS A PALINDROME
.MODEL SMALL .STACK 64 .DATA STR1 DB 40 DUP ('$') REV DB 40 DUP ('$') MSG1 DB 10,13,' ENTER THE STRING : $' MSG2 DB 10,13,' THE REVERSE OF THE STRING IS : $' PAL DB 10,13,' THIS STRING IS A PALINDROME!! $' NPAL DB 10,13,' THIS STRING IS NOT A PALINDROME!! $' .CODE MOV AX,@DATA MOV DS,AX MOV ES,AX LEA DX,MSG1 MOV AH,09H INT 21H XOR CX,CX LEA SI,STR1 LP1 : MOV AH,01H INT 21H CMP AL,0DH JZ NEXT INC CX MOV [SI],AL INC SI JMP LP1 NEXT : LEA DI,REV MOV BP,CX LP2 : DEC SI MOV AL,[SI] MOV [DI],AL INC DI LOOP LP2 LEA DX,MSG2 MOV AH,09H INT 21H LEA DX,REV MOV AH,09H INT 21H LEA DI,REV LEA SI,STR1 MOV CX,BP REPE CMPSB JNZ FAIL LEA DX,PAL JMP MSG FAIL : LEA DX,NPAL MSG : MOV AH,09H INT 21H
BIT
15
ISE Dept
MOV AH,4CH INT 21H END
Microprocessor Manual
BIT
16
ISE Dept
Microprocessor Manual
PROGRAM 5B
DISPLAY 12-CHARACTER MESSAGE ON 7-SEGMENT DISPLAY
.MODEL SMALL .STACK 64H .DATA A1 DB 86H,88H,0F9H,8EH,8CH,0C7H,86H,89H LEN DW ($-A1) .CODE MOV AX,@DATA MOV DS,AX
MOV AL,80H MOV DX,0A403H OUT DX,AL MOV BX, 0AH LOOP1: MOV CX,LEN LEA SI,A1 AGAIN: MOV AL,[SI] CALL DISP CALL DELAY INC SI LOOP AGAIN DEC BX JNZ LOOP1 JMP EXIT DISP PROC PUSH CX MOV CX,08H LOOP2: MOV DX,0A401H ROL AL,01H OUT DX,AL PUSH AX MOV AL,0FFH MOV DX,0A402H OUT DX,AL MOV AL,00H OUT DX,AL POP AX LOOP LOOP2 POP CX RET DISP ENDP
; control word
DELAY PROC
BIT
17
ISE Dept
PUSH CX PUSH AX MOV CX,5FFFH N1: MOV AX,0FFFFH N2: DEC AX JNZ N2 LOOP N1 POP AX POP CX RET DELAY ENDP EXIT: MOV AH,4CH INT 21H END ; main loop for delay
Microprocessor Manual
; end of program
BIT
18
ISE Dept
Microprocessor Manual
PROGRAM 6A
PROGRAM TO READ 2 STRINGS AND CHECK IF THEY ARE EQUAL AND DISPLAY APPROPRIATE MESSAGES
.MODEL SMALL .STACK 64 .DATA MSG1 DB 10,13," ENTER THE FIRST STRING : $" MSG2 DB 10,13," ENTER THE SECOND STRING : $" C1 DW ? C2 DW ? STR1 DB 80 DUP ('$') STR2 DB 80 DUP ('$') MSG3 DB 10,13," THE TWO STRINGS ARE EQUAL!! $" MSG4 DB 10,13," THE TWO STRINGS ARE NOT EQUAL!! $" .CODE MOV AX,@DATA ; Load the address of DATA SEGEMENT into DS MOV DS,AX MOV ES,AX ; and into ES register LEA DX,MSG1 ; ask the user to enter the string STR1 MOV AH,09H INT 21H MOV BX,0000H ; initialize the count to zero LEA SI,STR1 ; initialize DI with starting address of ; STR1 NEXT1 : MOV AH,01H INT 21H MOV [SI],AL ; read character by character INC BX INC SI CMP AL,0DH JNZ NEXT1 DEC BX MOV C1,BX ; store count value into memory location C1 LEA DX,MSG2 ; ask the user to enter the second string STR2 MOV AH,09H INT 21H MOV BX,0000H ; initialize the count to zero LEA SI,STR2 ; initialize DI with starting address of ; STR2 NEXT2 : MOV AH,01H INT 21H MOV [SI],AL ; read character by character INC BX INC SI ; increment count and SI CMP AL,0DH ; check if the character is NEWLINE character JNZ NEXT2 DEC BX MOV C2,BX ; store count value into memory location C2 CMP BX,C1 ; compare the lengths of two strings JE CHECK JMP NOT_EQU
BIT
19
ISE Dept
CHECK : MOV SI,OFFSET STR1 MOV DI,OFFSET STR2 MOV CX,BX CLC CLD REPE CMPSB JNZ NOT_EQU EQUAL : LEA DX,MSG3 JMP STOP NOT_EQU : LEA DX,MSG4 STOP : MOV AH,09H INT 21H MOV AH,4CH INT 21H END
Microprocessor Manual
; load SI and DI with the starting address ; of STR1 and STR2 ; move count to CX register
; if equal display the message ,as strings ; are same ; display that two strings are not equal
BIT
20
ISE Dept
Microprocessor Manual
PROGRAM 6B
CONVERT FROM BINARY TO BCD AND DISPLAY ON SEVEN SEGMENT DISPLAY
.model small .stack 64h .data bin equ 0064h table1 db 0c0h,0f9h,0a4h,0b0h,099h,92h,82h,0f8h,80h,98h table2 db 4 dup(?) table3 db 4 dup(?) result dw ? .code mov ax,@data mov ds,ax mov bx,bin mov ax,0000h mov cx,0000h contin: cmp bx,0000h jz endprog dec bx mov al,cl add al,01h daa mov cl,al mov al,ch adc al,00h daa mov ch,al jmp contin endprog: lea bx,table1 lea si,table2 lea di,table3 mov cx,result and cl,0fh mov al,cl xlat mov [si],al mov[di+3],al inc si
mov dx,result mov cl,04h shr dl,cl mov al,dl xlat mov [si],al mov [di+2],al inc si mov cx,result
BIT
21
ISE Dept
and ch,0fh mov al,ch xlat mov [si],al mov [di+1],al inc si
Microprocessor Manual
mov dx,result mov cl,04h shr dh,cl mov al,dh xlat mov [si],al mov[di],al mov al,80h mov dx,0a403h out dx,al lea si,table2 call disp call delay lea di,table3 call disp call delay mov ah,4ch int 21h disp proc mov bh,04h lp2: mov cl,08h mov bl,[si] lp3: rol bl,01h mov al,bl mov dx,0a401h out dx,al push bx mov al,0ffh mov dx,0a402h out dx,al mov al,00h out dx,al pop bx dec cl jnz lp3 inc si dec bh jnz lp2 ret disp endp delay proc push ax push cx mov ax,4fffh mov cx,0ffffh dec cx
lp5: lp6:
BIT
22
ISE Dept
jnz lp6 dec ax jnz lp5 pop cx pop ax ret delay endp end
Microprocessor Manual
BIT
23
ISE Dept
Microprocessor Manual
PROGRAM 7A
PROGRAM TO FIND THE FACTORIAL OF A GIVEN NUMBER RECURSIVELY
.MODEL SMALL .STACK 64H .DATA NUM DW 04H FACT DW ? N DW 25 DUP(0) .CODE START: MOV AX,@DATA MOV DS,AX MOV AX,NUM MOV BX,01H MOV FACT,00H CALL FACTORIAL MOV FACT,BX MOV AH,4CH INT 21H FACTORIAL PROC CMP AX,01H JE NEXT MOV CX,AX MUL BX MOV BX,AX MOV AX,CX DEC AX CALL FACTORIAL NEXT : RET FACTORIAL ENDP END START END
; get the number ; BX is used while multiplying ; function call ; store the result in memory location ; return to dos
; compare with 1 to end process ; if equal return ; DO [AX]=[AX]*[BX] ; [BX]=[AX] ; get the initial value of AX from CX ; ; ; ; recursive call if AX==1 then return end of factorial end of program
BIT
24
ISE Dept
Microprocessor Manual
PROGRAM 7B
STEPPER MOTOR-CLOCKWISE DIRECTION
.MODEL SMALL .STACK 64 .CODE MOV AL,080H MOV DX,0A403H OUT DX,AL MOV AL,088H MOV CX,100 LP1: MOV DX,0A402H OUT DX,AL ROR AL,1 PUSH CX PUSH AX CALL DELAY POP AX POP CX DEC CX JNZ LP1 MOV AH,4CH INT 21H DELAY PROC MOV CX,0FFFH LOOP1: MOV AX,01FFFH LOOP2: DEC AX JNZ LOOP2 DEC CX JNZ LOOP1 RET DELAY ENDP END
; control word ; address of control word ; bit pattern is to be rotated ; no. of times it needs to rotate ; ; ; ; address of o/p port o/p the bit pattern rotate left push contents on stack
; before calling the subroutine for delay ; pop back the count ; jump if not zero
BIT
25
ISE Dept
Microprocessor Manual
PROGRAM 8A
PROGRAM TO READ THE NAME FROM KEYBOARD, CLEAR THE SCREEN AND DISPLAY THE NAME AT THE CENTRE OF THE SCREEN
.MODEL SMALL .STACK 64 .DATA MSG DB " WHAT IS YOUR NAME ? $" NAM DB 40 DUP ('$') .CODE MOV AX,@DATA MOV DS,AX ; Load the address of DATA SEGEMENT into DS LEA DX,MSG ; ask the user to enter the name MOV AH,09H INT 21H LEA SI,NAM ; get the starting address of NAM MOV CX,00H ; set the count to zero LP1 : MOV AH,01H ; read the name character by character INT 21H CMP AL,0DH ; compare if character is NEWLINE character JZ NEXT MOV [SI],AL ; store in location NAM INC SI ; increment SI and COUNT INC CX JMP LP1 NEXT : MOV AH,0FH ; to clear the screen INT 10H MOV AH,00H INT 10H MOV AH,02H ; to move the cursor position MOV BH,00H ; page number is 00 MOV DX,0A1CH ; ROW NO. in DH and COL NO. in DL INT 10H LEA DX,MSG ; print both MSG and NAM MOV AH,09H INT 21H LEA DX,NAM MOV AH,09H INT 21H ; return to DOS MOV AH,4CH INT 21H END ; end of program
BIT
26
ISE Dept
Microprocessor Manual
PROGRAM 8B
STEPPER MOTOR-ANTICLOCKWISE DIRECTION
.MODEL SMALL .STACK 64 .CODE MOV AL,080H MOV DX,0A403H OUT DX,AL MOV AL,088H MOV CX,100 LP1: MOV DX,0A402H OUT DX,AL ROL AL,1 PUSH CX PUSH AX CALL DELAY POP AX POP CX DEC CX JNZ LP1 MOV AH,4CH INT 21H DELAY PROC MOV CX,0FFFH LOOP1: MOV AX,01FFFH LOOP2: DEC AX JNZ LOOP2 DEC CX JNZ LOOP1 RET DELAY ENDP END
; control word ; address of control word ; bit pattern is to be rotated ; no. of times it needs to rotate ; ; ; ; address of o/p port o/p the bit pattern rotate left push contents on stack
; before calling the subroutine for delay ; pop back the count ; jump if not zero
BIT
27
ISE Dept
Microprocessor Manual
PROGRAM 9A
PROGRAM TO FIND THE VALUE OF NCR RECURSIVELY
.MODEL SMALL .STACK 100H .DATA N DW 7H R DW 5H NCR DW ? M DB 25 DUP(0) MSG1 DB 10,13," INVALID VALUES OF N AND R!! $" .CODE START : MOV AX,@DATA ; initialize the data segment MOV DS,AX MOV AX,N MOV BX,R MOV NCR,00H MOV AX,R ; get the value of R PUSH AX ; push it on stack CMP AX,N ; check if N>R JLE NEXT ; if so continue LEA DX,MSG1 ; else print the values are invalid MOV AH,09H INT 21H JMP STOP ; and return NEXT : MOV AX,N ; get the value of N PUSH AX ; save it on stack CALL BINOMIAL ; call the function to compute nCr MOV NCR,AX ; store it in memory location STOP : MOV AH,4CH ; return to DOS INT 21H BINOMIAL PROC ; start of function definition PUSH BP ; get the frame pointer in BP MOV BP,SP MOV AX,[BP+6] ; get r CMP AX,[BP+4] ; compare with n JE NEXT1 ; if equal then return 1 as answer CMP AX,00H ; do the same if r=0 JG NEXT2 ; else continue c(n-1,r)+c(n-1,r-1) NEXT1 : MOV AX,01H ; returning 1 JMP RETURN NEXT2 : PUSH [BP+6] ; save R on stack MOV CX,[BP+4] ; get n DEC CX PUSH CX CALL BINOMIAL PUSH AX MOV CX,[BP+6] DEC CX PUSH CX MOV CX,[BP+4] DEC CX PUSH CX
; ; ; ; ; ; ; ;
save on stack call the function recursively store the result on stack get r save r-1 on stack get N find N-1 save N-1
BIT
28
ISE Dept
CALL BINOMIAL POP BX ADD AX,BX RETURN : POP BP RET 4 BINOMIAL ENDP END START END ; ; ; ; ; ; ;
Microprocessor Manual
call function recursively get the result into BX ADD C(n-1,r) and C(n-1,r-1) pop all the contents that are pushed before returning end of function definition end of program
BIT
29
ISE Dept
Microprocessor Manual
PROGRAM 9B
ROTATE THE STEPPER MOTOR IN LEFT AND RIGHT DIRECTIONS FOR NSTEPS
.MODEL SMALL .STACK 64 .CODE MOV AL,080H MOV DX,0A403H OUT DX,AL MOV AL,088H MOV CX,100 LP1: MOV DX,0A402H OUT DX,AL ROL AL,1 PUSH CX PUSH AX CALL DELAY POP AX POP CX DEC CX JNZ LP1 MOV AH,4CH INT 21H
; control word ; address of control word ; bit pattern is to be rotated ; no. of times it needs to rotate ; ; ; ; address of o/p port o/p the bit pattern rotate left push contents on stack
; before calling the subroutine for delay ; pop back the count ; jump if not zero
MOV AL,088H MOV CX,100 LP2: MOV DX,0A402H OUT DX,AL ROR AL,1 PUSH CX PUSH AX CALL DELAY POP AX POP CX DEC CX JNZ LP2 MOV AH,4CH INT 21H DELAY PROC MOV CX,0FFFH LOOP1: MOV AX,01FFFH LOOP2: DEC AX JNZ LOOP2 DEC CX JNZ LOOP1
; bit pattern is to be rotated ; no. of times it needs to rotate ; ; ; ; address of o/p port o/p the bit pattern rotate left push contents on stack
; before calling the subroutine for delay ; pop back the count ; jump if not zero
BIT
30
ISE Dept
RET DELAY ENDP END
Microprocessor Manual
BIT
31
ISE Dept
Microprocessor Manual
PROGRAM 10A
PROGRAM TO FIND A GIVEN STRING IN THE TEXT
.MODEL SMALL .STACK 64 .DATA STR1 DB 50 DUP ('$') SUBSTR1 DB 20 DUP ('$') LEN2 DW ? LEN1 DW ? MSG1 DB 10,13," ENTER THE TEXT : $" MSG2 DB 10,13," ENTER THE STRING FOR SEARCH : $" MSG3 DB 10,13," THE STRING SUCCESSFULLY FOUND !! $" MSG4 DB 10,13," STRING NOT FOUND !! $" .CODE MOV AX,@DATA ; initialize the data segment MOV DS,AX ; ask the user to input the text MOV AH,09H LEA DX,MSG1 INT 21H MOV CX,00H ; initialize the count to zero LEA SI,STR1 CALL READ ; read the text and store it in ; memory location STR MOV LEN1,CX ; store the length of STR MOV AH,09H ; ask the user for the substring LEA DX,MSG2 INT 21H MOV CX,00H ; read the SUBSTR and also store its ; length LEA SI,SUBSTR1 CALL READ MOV LEN2,CX CMP CX,LEN1 ; if len of SUBSTR > len STR then NOT ; FOUND JG FAIL ; else check char by char by Brute force ; method LEA SI,STR1 ; set the starting of STR and SUBSTR into LEA DI,SUBSTR1 ; SI and DI respectively MOV CX,LEN2 MOV DX,LEN1 LOOP1 : CMP CX,00H ; while(STR[i}!=\0 || SUBSTR[i]!=\0) JE BREAK ; if do the following else break CMP DX,00H JE BREAK MOV AL,[SI] ; get the contents of SI into DI INC SI DEC DX CMP AL,[DI] JE NEXT ; if(STR[i]!=SUBSTR[i]) LEA MOV JMP INC DI,SUBSTR1 CX,LEN2 LOOP1 DI ; move DI point to start address of SUBSTR ; initialise the count back to LEN2 ; increment the counter DI
NEXT :
BIT
32
ISE Dept
DEC CX JNZ LOOP1 BREAK : CMP CX,00H JE SUCC FAIL : LEA DX,MSG4 JMP STOP SUCC : LEA DX,MSG3 STOP : MOV AH,09H INT 21H MOV AH,4CH INT 21H READ PROC PUSH AX LOOP2 : MOV AH,01H INT 21H CMP AL,0DH JE RETURN MOV [SI],AL INC SI INC CX JMP LOOP2 RETURN : POP AX RET READ ENDP END ; ; ; ; ; ; ; ;
Microprocessor Manual
decrement the count tells how many chars are yet to be matched if all the characters in SUBSTR is matched then CX=0 else CX!=0 print messages appropriately failure message success message function to print message on screen
; return to DOS ; ; ; ; procedure to read the string save AX on stack read char by char until \n char is read
; increment the count ; get back the contents from stack into AX
; end of program
BIT
33
ISE Dept
Microprocessor Manual
PROGRAM 10B
8x3 KEY PAD INTERFACE GET THE CHARACTER AND PRINT ITS ROW AND COLUMN
.MODEL SMALL .STACK 64H .DATA MSG1 DB 10,13,"PRESS ANY KEY FROM KEYPAD $" MSG2 DB 10,13,"THE ENTERED CHARACTER IS: $" KEY DB ? MSG3 DB 10,13,"THE ROW IS : $" MSG4 DB 10,13,"THE COLUMN IS : $" ROW DB 1 COL DB 1 ARR DB '0','1','2','3','4','5','6','7','8','9','+','','x','/','=','%','C','E' .CODE MOV AX,@DATA MOV DS,AX MOV MOV MOV OUT LEA MOV INT LP1: MOV MOV MOV MOV MOV ES,AX AL,90H DX,0A403H DX,AL DX,MSG1 AH,09H 21H BH,03H ROW,01H CL,00H AL,01H BL,AL ; initializes the data and extra segments
; ; ; ;
NO. Of rows in the keypad initially search the first row the key no. is initialized to 00 bit pattern to activate the first row
LOOP1:
MOV DX,0A402H OUT DX,AL MOV DX,0A400H IN AL,DX CMP AL,00H JNZ FOUND ADD CL,08H MOV AL,BL ROL AL,01 MOV BL,AL INC ROW DEC BH JNZ LOOP1 JMP LP1
; ; ; ; ;
activate a row to see if the key from the row is pressed get the contents of the row if AL!=0 then key is pressed
; else try to find in the next row ; so, key no. will be greater than 8 ; bit pattern to activate next row
; no. of still to be searched ; loop untill a key is pressed ; if found search the column
FOUND:
BIT
34
ISE Dept
JMP FOUND DISP: LEA DX,MSG2 MOV AH,09H INT 21H MOV CH,00H MOV SI,CX MOV DL,ARR[SI] MOV KEY,DL MOV AH,02H INT 21H MOV CL,ROW LEA DX,MSG3 MOV AH,09H INT 21H CALL DIS_PLAY LEA DX,MSG4 MOV AH,09H INT 21H MOV CL,COL CALL DIS_PLAY MOV AH,4CH INT 21H ; print the key pressed
Microprocessor Manual
DIS_PLAY PROC MOV DL,CL AND DL,0F0H MOV AL,DL ROR AL,01 ROR AL,01 ROR AL,01 ROR AL,01 ADD AL,30H MOV DL,AL MOV AH,02H INT 21H MOV DL,CL AND DL,0FH ADD DL,30H MOV AH,02H INT 21H RET DIS_PLAY ENDP END
; add 30H to get its ASCII value ; display the upper nibble
BIT
35
ISE Dept
Microprocessor Manual
PROGRAM 11A
PROGRAM TO GENERATE N FIBONACCI NUMBERS GIVEN N
.MODEL SMALL .STACK 64H .DATA NUM DW 10 FIB DB 10 DUP (?) .CODE START : MOV AX,@DATA MOV DS,AX MOV ES,AX LEA SI,FIB MOV AX,00H MOV BX,01H MOV CX,NUM SUB CX,02H CALL FIBO MOV AH,4CH INT 21H FIBO PROC MOV [SI],AX MOV [SI+1],BX ADD SI,02H LOOP1 : MOV DX,BX ADD BX,AX MOV [SI],BX MOV AX,DX INC SI LOOP LOOP1 RET FIBO ENDP END START END ; initialize the data and extra segment ; get the address of FIB ; FIB[0]=0,FIB[1]=1
; ; ; ;
10 fibonacii numbers are to be generated FIB is the location where the numbers are stored
; store the first two NOS. ; AX=FIB[n-2] and BX=FIB[N-1] ; increment SI by 2 ; DX=BX ; BX=BX+AX ;FIB[n]=BX ; AX=DX ; make SI point to next element ; decrement CX until n fibonacci numbers ; are generated ; return to main ; end of program
BIT
36
ISE Dept
Microprocessor Manual
PROGRAM 11B
ADD OR SUBTRACT TWO NUMBERS TAKEN AS INPUT FROM KEYPAD
.MODEL SMALL .STACK 64H .DATA ROW DB 01H COL DB 01 MSG1 DB 10,13,"ENTER THE FIRST NUMBER : $" MSG3 DB 10,13,"ENTER THE SECOND NUMBER : $" MSG2 DB 10,13,"ENTER THE OPERATOR : $" ARR DB '0','1','2','3','4','5','6','7','8','9','+','','*','/','=','%',0,0,0,'=' OPT DB ? RES DB ? MSG4 DB 10,13,"THE RESULT IS : $" OP1 DB ? OP2 DB ? .CODE MOV AX,@DATA MOV DS,AX ; initialize the data and extra ; segment MOV ES,AX MOV OP1,0 MOV OP2,0 MOV OPT,0 MOV MOV OUT LEA MOV INT AL,90H DX,0A403H DX,AL DX,MSG1 AH,09H 21H
CALL READ MOV CH,00 MOV SI,CX MOV DL,ARR[SI] MOV AH,02H INT 21H MOV OP1,CL MOV CX,00H MOV AH,01H INT 21H LEA DX,MSG2 MOV AH,09H INT 21H CALL READ MOV CH,00 MOV SI,CX MOV DL,ARR[SI] MOV SI,CX MOV DL,ARR[SI] MOV OPT,DL MOV AH,02H
; ; ; ;
read the operand CX will have the index for the element in array declared arr[8]=8 & arr[11]=+
; CX will have the index for the ; element in array declared ; arr[8]=8 & arr[11]=+
BIT
37
ISE Dept
INT 21H MOV AH,01 INT 21H MOV CX,00H LEA DX,MSG3 MOV AH,09H INT 21H CALL READ MOV CH,00 MOV SI,CX MOV DL,ARR[SI] MOV MOV MOV MOV INT MOV MOV CMP JNE ADD MOV JMP SUBT: SI,CX DL,ARR[SI] OP2,CL AH,02H 21H AH,OP1 AL,OP2 OPT,'+' SUBT AH,AL RES,AH NEXT
Microprocessor Manual
; ; ; ;
read the operand CX will have the index for the element in array declared arr[8]=8 & arr[11]=+
SUB AH,AL MOV RES,AH MOV CL,AH LEA DX,MSG4 MOV AH,09H INT 21H CALL DISP MOV AH,4CH INT 21H
NEXT:
READ PROC PUSH AX PUSH BX PUSH DX LP1: MOV BH,03H MOV ROW,01 MOV CL,00H MOV AL,01H MOV BL,AL LOOP1: MOV DX,0A402H OUT DX,AL MOV DX,0A400H IN AL,DX CMP AL,00H JNZ FOUND ADD CL,08H MOV AL,BL ROL AL,01 MOV BL,AL INC ROW
BIT
38
ISE Dept
DEC BH JNZ LOOP1 JMP LP1 FOUND: ROR AL,01 JC RETURN INC CL INC COL JMP FOUND RETURN: POP DX POP BX POP AX RET READ ENDP DISP PROC MOV MOV AND ROR ROR ROR ROR CMP JBE ADD NEXT2: ADD INT
Microprocessor Manual
DL,RES AH,02H DL,0F0H DL,01 DL,01 DL,01 DL,01 DL,09 NEXT2 DL,7 DL,30H 21H
NEXT1:
MOV DL,RES AND DL,0FH MOV AH,02H CMP DL,9 JBE NEXT1 ADD DL,7H ADD DL,30H INT 21H RET DISP ENDP
END
BIT
39
ISE Dept
Microprocessor Manual
PROGRAM 12A
PROGRAM TO READ THE CURRENT TIME FROM THE SYSTEM AND DISPLAY IT IN STANDARD FORMAT ON THE SCREEN
.MODEL SMALL .STACK 64H .DATA MSG DB 10,13,' THE CURRENT TIME IS : $' TIME DB '00:00:00$' .CODE MOV AX,@DATA ; initializing the data segment MOV DS,AX LEA BX,TIME LEA DX,MSG MOV AH,09H INT 21H CALL GET_TIME LEA DX,TIME MOV AH,09H INT 21H MOV AH,4CH INT 21H GET_TIME PROC MOV AH,2CH INT 21H MOV AL,CH CALL CONVERT MOV [BX],AX MOV AL,CL CALL CONVERT MOV [BX+3],AX MOV AL,DH CALL CONVERT MOV [BX+6],AL RET GET_TIME ENDP CONVERT PROC MOV AH,0 MOV DL,10 DIV DL OR AX,3030H RET CONVERT ENDP END ; to get the values HRS,MINS,SECS into TIME ; print the message the current time is
; return to DOS
; these registers will have the ASCII value ; ; ; ; move these to TIME array CL :minutes(00-59) convert minutes store this
; DH seconds (00-59) ; convert the seconds ; store seconds ; end of procedure ; ; ; ; ; ; function definition for conversion make higher byte 00H divide AX by 10 after division quotient in AL and remainder in AH OR it with ASCII of 0 i.e. 30H
; end of program
BIT
40
ISE Dept
Microprocessor Manual
PROGRAM 12B
DAC INTERFACE :: SINE WAVE
.MODEL SMALL .STACK 64 .DATA ARRAY DB 80H,96H,0ABH,0C1H,0D2H,0E2H,0EEH,0F8H,0FEH DB 0FFH,0FEH,0F8H,0EEH,0E2H,0D2H,0C1H,0ABH,96H DB 80H,69H,54H,40H,2DH,1DH,11H,07H,01H DB 00H,01H,07H,11H,1DH,2DH,40H,54H,69H COUNT DW 36 .CODE MOV AX,@DATA ; initialize data segment MOV DS,AX MOV DX,0A403H MOV AL,80H OUT DX,AL BACK: MOV CX,COUNT LEA SI,ARRAY LOOP1: MOV DX,0A400H MOV AL,[SI] OUT DX,AL CALL DELAY INC SI DEC CX JZ BACK MOV AH,01H INT 16H JNZ STOP JMP LOOP1 STOP: MOV AH,4CH INT 21H DELAY PROC PUSH AX MOV AX,0FFFFH LP1: DEC AX JNZ LP1 POP AX RET DELAY ENDP END ; move the control word into CWR
; ; ; ; ;
make SI point to next element in the array decrement count CX!=0 continue check for the key board interrupt if no key is pressed looping is continued
; return to DOS
; to bring in delay
BIT
41
ISE Dept
Microprocessor Manual
PROGRAM 13A
PROGRAM TO SIMULATE A DECIMAL UP COUNTER FROM 00 T0 99
.MODEL SMALL .STACK 64H .DATA ROW DB 10 COL DB 20 .CODE MOV AX,@DATA MOV DS,AX MOV SI,2 MOV BP,00 MOV AH,0FH INT 10H MOV AH,00H INT 10H LP1 : MOV AH,02H MOV BH,00H MOV DH,ROW MOV DL,COL INT 10H MOV AX,BP CALL DISP CALL DELAY INC BP CMP BP,100 JL CONT MOV BP,00 DEC SI CONT : JNZ LP1 MOV AH,4CH INT 21H DISP PROC CALL CONVERT MOV DL,AL MOV BL,AL AND DL,0F0H MOV CL,04 ROR DL,CL ADD DL,30H MOV AH,02H INT 21H MOV DL,BL AND DL,0FH ADD DL,30H MOV AH,02 INT 21H RET DISP ENDP
; no. of times to count 00-99 ; counter value ; clear screen ; clear screen ; placing the cursor at the ; coordinates given
; get the counter value into AX ; display the counter value ; increment counter ; if its <=99 continue ; else make it 0 again
; get higher significant digit ; move it to lower significant digit position ; get ASCII equivalent ; print
BIT
42
ISE Dept
CONVERT PROC CMP AL,00 JNE LP2 RET LP2 : MOV CL,AL MOV AL,00 LP3 : INC AL MOV BL,AL AND BL,0FH CMP BL,09 JLE CONTC AND AL,0F0H ADD AL,10H CONTC : DEC CL JNZ LP3 RET CONVERT ENDP DELAY PROC MOV DX,0FFFFH LP4 : MOV BX,0FFCH LP5 : DEC BX JNZ LP5 DEC DX JNZ LP4 RET DELAY ENDP END
Microprocessor Manual
; get no. into CL-counter ; will have the final decimal equivalent ; increment no. ; get lower significant digit of AL ; see if its >9 ; if yes, clear it and ; add 1 to higher significant digit
BIT
43
ISE Dept
Microprocessor Manual
PROGRAM 13B
DAC INTERFACE :: HALF-RECTIFIED SINE WAVE
.MODEL SMALL .STACK 64 .DATA ARRAY DB 80H,96H,0ABH,0C1H,0D2H,0E2H,0EEH,0F8H,0FEH DB 0FFH,0FEH,0F8H,0EEH,0E2H,0D2H,0C1H,0ABH,96H DB 80H,80H,80H,80H,80H,80H,80H,80H,80H DB 80H,80H,80H,80H,80H,80H,80H,80H,80H COUNT DW 36 .CODE MOV AX,@DATA ; initialize data segment MOV DS,AX MOV DX,0A403H MOV AL,80H OUT DX,AL BACK: MOV CX,COUNT LEA SI,ARRAY LOOP1: MOV DX,0A400H MOV AL,[SI] OUT DX,AL CALL DELAY INC SI DEC CX JZ BACK MOV AH,01H INT 16H JNZ STOP JMP LOOP1 STOP: MOV AH,4CH INT 21H DELAY PROC PUSH AX MOV AX,0FFFFH LP1: DEC AX JNZ LP1 POP AX RET DELAY ENDP END ; move the control word into CWR
; ; ; ; ;
make SI point to next element in the array decrement count CX!=0 continue check for the key board interrupt if no key is pressed looping is continued
; return to DOS
; to bring in delay
BIT
44
ISE Dept
Microprocessor Manual
PROGRAM 14A
PROGRAM TO PLACE THE CURSOR IN THE SPECIFIED POSITION
.MODEL SMALL .DATA ROW DB 10,13," ENTER THE ROW : $" COL DB 10,13," ENTER THE COLUMN : $" R DB ? C DB ? CHAR DB "_$" .CODE MOV AX,@DATA ; initialize the data segment MOV DS,AX MOV AH,0FH ; clear the screen before INT 10H ; placing the cursor MOV AH,00H INT 10H MOV AH,09H ; ask user to input the row LEA DX,ROW INT 21H XOR AX,AX CALL READ ; read the row MOV R,AL MOV AH,09H ; read the column LEA DX,COL INT 21H XOR AX,AX CALL READ MOV C,AL MOV AH,02H ; place the cursor at the MOV BH,00H ; coordinates given MOV DH,R MOV DL,C INT 10H LEA DX,CHAR ; to see the cursor position display MOV AH,09H ; a _ at that position INT 21H MOV AH,01H ; wait for the user to INT 21H ; see the cursor position MOV AH,4CH ; return to DOS INT 21H READ PROC MOV INT SUB MOV MUL MOV MOV INT SUB ADD RET
; ; ; ; ; ;
read a 2-digit no. first read a number get its integer value it should be in the 10s place of the digit so multiply by 10
; read the digit in its units place ; get its integer value
BIT
45
ISE Dept
READ ENDP END
Microprocessor Manual
BIT
46
ISE Dept
Microprocessor Manual
PROGRAM 14B
DAC INTERFACE :: FULL-RECTIFIED SINE WAVE
.MODEL SMALL .STACK 64 .DATA ARRAY DB 80H,96H,0ABH,0C1H,0D2H,0E2H,0EEH,0F8H,0FEH DB 0FFH,0FEH,0F8H,0EEH,0E2H,0D2H,0C1H,0ABH,96H COUNT DW 18 .CODE MOV AX,@DATA MOV DS,AX MOV DX,0A403H MOV AL,80H OUT DX,AL BACK: MOV CX,COUNT LEA SI,ARRAY LOOP1: MOV DX,0A400H MOV AL,[SI] OUT DX,AL CALL DELAY INC SI DEC CX JZ BACK MOV AH,01H INT 16H JNZ STOP JMP LOOP1 STOP: MOV AH,4CH INT 21H DELAY PROC PUSH AX MOV AX,0FFFFH LP1: DEC AX JNZ LP1 POP AX RET DELAY ENDP END
; ; ; ; ;
make SI point to next element in the array decrement count CX!=0 continue check for the key board interrupt if no key is pressed looping is continued
; return to DOS
; to bring in delay
BIT
47
ISE Dept
Microprocessor Manual
PROGRAM 15A
PROGRAM TO CREATE AND DELETE A FILE
.MODEL SMALL .DATA F1 DB 40 DUP ('$') F2 DB 40 DUP ('$') FPTR DW ? MSG1 DB 10,13," ENTER THE FILENAME FOR INPUT : $" MSG2 DB 10,13," ENTER THE FILENAME FOR DELETION : $" MSG3 DB 10,13," FILE OPENED SUCCESSFULLY !! $" MSG4 DB 10,13," FILE OPERATION FAILED !! $" MSG5 DB 10,13," FILE DELETED SUCCESSFULLY !! $" MSG6 DB 10,13," FILE DELETION FAILED !! $" .CODE MOV AX,@DATA MOV DS,AX MOV DX,OFFSET MSG1 MOV AH,09H INT 21H MOV SI,OFFSET F1 CALL READ MOV AH,3CH LEA DX,F1 MOV CL,00H INT 21H MOV FPTR,AX ;CMP AX,00H JC FAIL MOV AH,09H MOV DX,OFFSET MSG3 INT 21H MOV AH,3EH MOV BX,FPTR INT 21H JMP NEXT FAIL : MOV AH,09H LEA DX,MSG4 INT 21H NEXT : MOV AH,09H LEA DX,MSG2 INT 21H LEA SI,F2 CALL READ MOV AL,00H MOV AH,41H LEA DX,F2 INT 21H JNC SUCC MOV AH,09H LEA DX,MSG6 INT 21H JMP STOP SUCC : LEA DX,MSG5 MOV AH,09H
BIT
48
ISE Dept
INT 21H MOV AH,4CH INT 21H
Microprocessor Manual
STOP :
READ PROC PUSH AX LOOP2 : MOV AH,01H INT 21H CMP AL,0DH JZ RETURN MOV [SI],AL INC SI JMP LOOP2 RETURN : POP AX RET READ ENDP END
BIT
49
ISE Dept
Microprocessor Manual
PROGRAM 15B
ELEVATOR PROGRAM
.MODEL SMALL .STACK 64 .DATA .CODE MOV AX,@DATA MOV DS,AX MOV DX,A403H MOV AL,82H OUT DX,AL MOV DX,A400H MOV AL,0F0H OUT DX,AL XOR CX,CX LOOP1: MOV DX,A401H IN AL,DX AND AL,0FH CMP AL,0FH JZ LOOP1 NEXT: SHR AL,01 JNC GFLR SHR AL,01 JNC FFLR SHR AL,01 JNC SFLR SHR AL,01 JNC TFLR GFLR: MOV CL,01H JMP MOVE FFLR: MOV CL,4 JMP MOVE SFLR: TFLR: MOV CL,7 JMP MOVE MOV CL,10 JMP MOVE MOV AL,00 MOV BL,CL MOV DX,A400H OUT DX,AL CALL DELAY INC AL DEC CL JNZ LP1 MOV CL,BL DEC AL MOV DX,A400H OUT DX,AL CALL DELAY DEC AL DEC CL JNZ LP2
; clear CX ; read the port B contents ; if a key is not pressed loop back ; else GOTO next ; find which floor key is pressed
; if the first floor 4 LEDs SHD ; light ; if second floor 7 LEDs ; if the third floor 10 LEDS SHD ; light
MOVE: LP1:
LP2:
; moving down
BIT
50
ISE Dept
MOV AH,4CH INT 21H DELAY PROC PUSH AX PUSH CX MOV AX,0CFFH LP3: MOV CX,0FFFH LP4: DEC CX JNZ LP4 DEC AX JNZ LP3 POP CX POP AX RET DELAY ENDP END ; return to DOS
Microprocessor Manual
; end of program
BIT
51