%@ Page Language="C#" ContentType="text/html" ResponseEncoding="iso-8859-1" %>
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; ; COE-25 PROJECT DESIGN ; ; MPU-BASED ENCROACHMENT SECURITY ACCESS SYSTEM ; ; ; ; EDISIM SEGUNDINO ; ; RODORA KHO ; ; JOSE DOLIENTE ; ; ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; start: xor ax,ax ; clear all register (AX BC CX DX DS) xor bx,bx xor cx,cx xor dx,dx call detect_mem_store ; detect if memory has stored data call initPPI1 ; call init_LCD ; call initPPI2 ; INITIALIZE ALL PPI AND LCD call initPPI3 ; call initPPI4 ; call intro ; print message to printer restart: call delay call menu kpad: in al,21h ; in switch status test al,01h ; detect backdoor switch status (bit 0) cmp al,01h jne proceed in al,21h ; in switch status (repeat input for right data) test al,01h ; detect backdoor switch status (bit 0) cmp al,01h jne proceed call waitMSG ; message call decs ; decrement 7 segment display call open_motor ; door opening proceed: xor ax,ax in al,12h ;detect key press and debounce test al,01h je kpad call delay in al,12h test al,01h je kpad cmp al,01h ; do a job upon key press jne bbb mov [424h],al ; store press data for printing cardCode/increment 7 seg. call num1 ; key#1 jmp restart ; restart if end process bbb: cmp al,11h jne kpad call num2 ; key#2 jmp restart ; restart if end process menu: call clr_dis call delay mov dl,084h ;line1 Log Options call line mov al,'L' call dis_char mov al,'O' call dis_char mov al,'G' call dis_char mov al,' ' call dis_char mov al,'O' call dis_char mov al,'P' call dis_char mov al,'T' call dis_char mov al,'I' call dis_char mov al,'O' call dis_char mov al,'N' call dis_char mov al,'S' call dis_char mov dl,0c0h ;line2 Room Entry call line mov al,'[' call dis_char mov al,'1' call dis_char mov al,']' call dis_char mov al,' ' call dis_char mov al,'R' call dis_char mov al,'o' call dis_char mov al,'o' call dis_char mov al,'m' call dis_char mov al,' ' call dis_char mov al,'E' call dis_char mov al,'n' call dis_char mov al,'t' call dis_char mov al,'r' call dis_char mov al,'y' call dis_char mov dl,94h ;line3 Change Password call line mov al,'[' call dis_char mov al,'2' call dis_char mov al,']' call dis_char mov al,' ' call dis_char mov al,'C' call dis_char mov al,'h' call dis_char mov al,'a' call dis_char mov al,'n' call dis_char mov al,'g' call dis_char mov al,'e' call dis_char mov al,' ' call dis_char mov al,'P' call dis_char mov al,'I' call dis_char mov al,'N' call dis_char mov al,' ' call dis_char mov al,'C' call dis_char mov al,'o' call dis_char mov al,'d' call dis_char mov al,'e' call dis_char mov dl,0d7h ;line4 Choose Number call line mov al,'C' call dis_char mov al,'h' call dis_char mov al,'o' call dis_char mov al,'o' call dis_char mov al,'s' call dis_char mov al,'e' call dis_char mov al,' ' call dis_char mov al,'N' call dis_char mov al,'u' call dis_char mov al,'m' call dis_char mov al,'b' call dis_char mov al,'e' call dis_char mov al,'r' call dis_char mov al,':' call dis_char mov al,0ch ; Cursor Off call command ret accept_code: ; this procedure will be called if card is accepted call clr_dis call delay mov dl,0c2h call line mov al,'C' call dis_char mov al,'a' call dis_char mov al,'r' call dis_char mov al,'d' call dis_char mov al,' ' call dis_char mov al,'A' call dis_char mov al,'c' call dis_char mov al,'c' call dis_char mov al,'e' call dis_char mov al,'p' call dis_char mov al,'t' call dis_char mov al,'e' call dis_char mov al,'d' call dis_char mov al,'.' call dis_char call longdelay call longdelay call longdelay call longdelay mov al,'.' call dis_char call longdelay call longdelay call longdelay call longdelay mov al,'.' call dis_char call longdelay2 ret ask_pin: ; ask PIN Code call clr_dis call delay mov dl,080h call line mov al,'E' call dis_char mov al,'n' call dis_char mov al,'t' call dis_char mov al,'e' call dis_char mov al,'r' call dis_char mov al,' ' call dis_char mov al,'P' call dis_char mov al,'I' call dis_char mov al,'N' call dis_char mov al,' ' call dis_char mov al,'C' call dis_char mov al,'o' call dis_char mov al,'d' call dis_char mov al,'e' call dis_char mov al,':' call dis_char mov dl,0d4h call line mov al,'P' call dis_char mov al,'r' call dis_char mov al,'e' call dis_char mov al,'s' call dis_char mov al,'s' call dis_char mov al,' ' call dis_char mov al,'#' call dis_char mov al,' ' call dis_char mov al,'t' call dis_char mov al,'o' call dis_char mov al,' ' call dis_char mov al,'V' call dis_char mov al,'a' call dis_char mov al,'l' call dis_char mov al,'i' call dis_char mov al,'d' call dis_char mov al,'a' call dis_char mov al,'t' call dis_char mov al,'e' call dis_char mov al,0eh ; cursor ON call command mov dl,0c0h ; PIN Line call line call PIN_ASK mov al,[300h] ; retrieve card code cmp al,02h jne x1 call code2 jmp x4 x1: cmp al,04h jne x2 call code4 jmp x4 x2: cmp al,06h jne x3 call code6 jmp x4 x3: call code8 x4: nop ret ch_pin: ; procedure called when key2 is press call clr_dis call delay mov dl,080h call line mov al,'E' call dis_char mov al,'n' call dis_char mov al,'t' call dis_char mov al,'e' call dis_char mov al,'r' call dis_char mov al,' ' call dis_char mov al,'C' call dis_char mov al,'u' call dis_char mov al,'r' call dis_char mov al,'r' call dis_char mov al,'e' call dis_char mov al,'n' call dis_char mov al,'t' call dis_char mov al,' ' call dis_char mov al,'P' call dis_char mov al,'I' call dis_char mov al,'N' call dis_char mov al,':' call dis_char mov dl,0d4h call line mov al,'P' call dis_char mov al,'r' call dis_char mov al,'e' call dis_char mov al,'s' call dis_char mov al,'s' call dis_char mov al,' ' call dis_char mov al,'#' call dis_char mov al,' ' call dis_char mov al,'t' call dis_char mov al,'o' call dis_char mov al,' ' call dis_char mov al,'V' call dis_char mov al,'a' call dis_char mov al,'l' call dis_char mov al,'i' call dis_char mov al,'d' call dis_char mov al,'a' call dis_char mov al,'t' call dis_char mov al,'e' call dis_char mov al,0eh ;cursor ON call command mov dl,0c0h ; PIN Line call line call PIN_ASK mov al,[300h] ;retrieve card code cmp al,02h jne xx1 call code2 jmp xx4 xx1: cmp al,04h jne xx2 call code4 jmp xx4 xx2: cmp al,06h jne xx3 call code6 jmp xx4 xx3: call code8 xx4: call longdelay2 call new_PIN ret new_PIN: ; Procedure for asking new PIN Code call clr_dis call delay mov dl,080h call line mov al,'E' call dis_char mov al,'n' call dis_char mov al,'t' call dis_char mov al,'e' call dis_char mov al,'r' call dis_char mov al,' ' call dis_char mov al,'N' call dis_char mov al,'e' call dis_char mov al,'w' call dis_char mov al,' ' call dis_char mov al,'P' call dis_char mov al,'I' call dis_char mov al,'N' call dis_char mov al,' ' call dis_char mov al,'C' call dis_char mov al,'o' call dis_char mov al,'d' call dis_char mov al,'e' call dis_char mov al,':' call dis_char mov dl,0d4h call line mov al,'P' call dis_char mov al,'r' call dis_char mov al,'e' call dis_char mov al,'s' call dis_char mov al,'s' call dis_char mov al,' ' call dis_char mov al,'#' call dis_char mov al,' ' call dis_char mov al,'t' call dis_char mov al,'o' call dis_char mov al,' ' call dis_char mov al,'V' call dis_char mov al,'a' call dis_char mov al,'l' call dis_char mov al,'i' call dis_char mov al,'d' call dis_char mov al,'a' call dis_char mov al,'t' call dis_char mov al,'e' call dis_char mov dl,094h call line mov al,'P' call dis_char mov al,'r' call dis_char mov al,'e' call dis_char mov al,'s' call dis_char mov al,'s' call dis_char mov al,' ' call dis_char mov al,'*' call dis_char mov al,' ' call dis_char mov al,'t' call dis_char mov al,'o' call dis_char mov al,' ' call dis_char mov al,'E' call dis_char mov al,'s' call dis_char mov al,'c' call dis_char mov al,'a' call dis_char mov al,'p' call dis_char mov al,'e' call dis_char mov al,0eh ;cursor ON call command mov dl,0c0h ; PIN Line call line call PIN_ASK1 mov al,[300h] ;retrieve card code cmp al,02h jne g1 call code_2 jmp g4 g1: cmp al,04h jne g2 call code_4 jmp g4 g2: cmp al,06h jne g3 call code_6 jmp g4 g3: call code_8 g4: call pin_save nop ret pin_save: call clr_dis call delay mov dl,0c2h call line mov al,0ch ; Cursor Off call command mov al,'S' call dis_char mov al,'a' call dis_char mov al,'v' call dis_char mov al,'i' call dis_char mov al,'n' call dis_char mov al,'g' call dis_char mov al,'.' call dis_char call longdelay call longdelay call longdelay call longdelay call longdelay call longdelay call longdelay mov al,'.' call dis_char call longdelay call longdelay call longdelay call longdelay call longdelay call longdelay call longdelay mov al,'.' call dis_char call longdelay call longdelay call longdelay call longdelay call longdelay call longdelay call longdelay mov al,'.' call dis_char call longdelay call longdelay call longdelay call longdelay call longdelay call longdelay call longdelay mov al,'.' call dis_char call longdelay call longdelay call longdelay call longdelay call longdelay call longdelay call longdelay mov al,'.' call dis_char call longdelay call longdelay call longdelay call longdelay call longdelay call longdelay call longdelay mov al,'.' call dis_char call longdelay call longdelay call longdelay call longdelay call longdelay call longdelay call longdelay mov al,'.' call dis_char ret ;;;;;;;;;;;;;;;;; PROCEDURES FOR SAVING NEW PIN CODE ;;;;;;;;;;;;;;;;;;;;; code_2: ; CODE2 new PIN mov si,405h mov bl,[301h] mov [si],bl inc si mov bl,[302h] mov [si],bl inc si mov bl,[303h] mov [si],bl inc si mov bl,[304h] mov [si],bl inc si mov bl,[305h] mov [si],bl ret code_4: ; CODE4 new PIN mov si,40ah mov bl,[301h] mov [si],bl inc si mov bl,[302h] mov [si],bl inc si mov bl,[303h] mov [si],bl inc si mov bl,[304h] mov [si],bl inc si mov bl,[305h] mov [si],bl ret code_6: ; CODE6 new PIN mov si,40fh mov bl,[301h] mov [si],bl inc si mov bl,[302h] mov [si],bl inc si mov bl,[303h] mov [si],bl inc si mov bl,[304h] mov [si],bl inc si mov bl,[305h] mov [si],bl ret code_8: ; CODE8 new PIN mov si,414h mov bl,[301h] mov [si],bl inc si mov bl,[302h] mov [si],bl inc si mov bl,[303h] mov [si],bl inc si mov bl,[304h] mov [si],bl inc si mov bl,[305h] mov [si],bl ret ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; PIN_ASK: ; Procedure used in "Room Entry" Option mov si,301h call key_PIN ; inc si call key_PIN ; inc si call key_PIN ; key-in 5 digit PIN Code inc si call key_PIN ; inc si call key_PIN ; call delay number_sign: in al,12h ; detect key press and debounce test al,01h je number_sign call delay in al,12h test al,01h je number_sign cmp al,0e1h jne number_sign still3: xor ax,ax in al,12h test al,01h jne still3 ret PIN_ASK1: ; Procedure used in "Change PIN" Option mov si,301h ; call key_PIN ; inc si ; call key_PIN ; inc si ; key-in 5 digit PIN Code call key_PIN ; inc si ; call key_PIN ; inc si ; call key_PIN ; call delay ; sign: in al,12h ;detect key press and debounce test al,01h je sign call delay in al,12h test al,01h je sign cmp al,0c1h ; * to escape jne sign_1 jmp restart sign_1: cmp al,0e1h ;# to validate jne sign still4: xor ax,ax in al,12h test al,01h jne still4 ret key_PIN: in al,12h ;detect key press and debounce test al,01h ; je key_PIN ; call delay ; in al,12h ; Loop key_PIN until key is press test al,01h ; je key_PIN ; mov [si],al ; load press data to a mem location call embed still2: xor ax,ax in al,12h test al,01h jne still2 ret code2: ; code2 procedure for PIN validation (compare keyed pin) mov si,405h mov al,[si] mov bl,[301h] cmp al,bl je y1 jmp deny y1: inc si mov al,[si] mov bl,[302h] cmp al,bl je y2 jmp deny y2: inc si mov al,[si] mov bl,[303h] cmp al,bl je y3 jmp deny y3: inc si mov al,[si] mov bl,[304h] cmp al,bl je y4 jmp deny y4: inc si mov al,[si] mov bl,[305h] cmp al,bl jne deny call granted jmp ennd deny: call denied ennd: ret code4: ; code4 procedure for pin validation (compare keyed pin) mov si,40ah mov al,[si] mov bl,[301h] cmp al,bl je yy1 jmp deny1 yy1: inc si mov al,[si] mov bl,[302h] cmp al,bl je yy2 jmp deny1 yy2: inc si mov al,[si] mov bl,[303h] cmp al,bl je yy3 jmp deny1 yy3: inc si mov al,[si] mov bl,[304h] cmp al,bl je yy4 jmp deny1 yy4: inc si mov al,[si] mov bl,[305h] cmp al,bl jne deny1 call granted jmp end1 deny1: call denied end1: ret code6: ; code6 procedure for pin validation (compare keyed pin) mov si,40fh mov al,[si] mov bl,[301h] cmp al,bl je yyy1 jmp deny2 yyy1: inc si mov al,[si] mov bl,[302h] cmp al,bl je yyy2 jmp deny2 yyy2: inc si mov al,[si] mov bl,[303h] cmp al,bl je yyy3 jmp deny2 yyy3: inc si mov al,[si] mov bl,[304h] cmp al,bl je yyy4 jmp deny2 yyy4: inc si mov al,[si] mov bl,[305h] cmp al,bl jne deny2 call granted jmp end2 deny2: call denied end2: ret code8: ; code8 procedure for pin validation (compare keyed pin) mov si,414h mov al,[si] mov bl,[301h] cmp al,bl je yyyy1 jmp deny3 yyyy1: inc si mov al,[si] mov bl,[302h] cmp al,bl je yyyy2 jmp deny3 yyyy2: inc si mov al,[si] mov bl,[303h] cmp al,bl je yyyy3 jmp deny3 yyyy3: inc si mov al,[si] mov bl,[304h] cmp al,bl je yyyy4 jmp deny3 yyyy4: inc si mov al,[si] mov bl,[305h] cmp al,bl jne deny3 call granted jmp end3 deny3: call denied end3: ret denied: call clr_dis call delay mov dl,0c3h call line mov al,'A' call dis_char mov al,'C' call dis_char mov al,'C' call dis_char mov al,'E' call dis_char mov al,'S' call dis_char mov al,'S' call dis_char mov al,' ' call dis_char mov al,'D' call dis_char mov al,'E' call dis_char mov al,'N' call dis_char mov al,'I' call dis_char mov al,'E' call dis_char mov al,'D' call dis_char mov al,0ch ; Cursor Off call command call longdelay2 call longdelay2 jmp restart ret granted: mov al,[424h] ; retrieve keypress cmp al,01h jne grant call incs mov al,00h mov [424h],al ; clear mem[424h] ;;;;;; print user card code ;;;;;;;;;;; mov al,[300h] cmp al,02h ; card code2 jne prn1 call code2_IN_print jmp grant prn1: cmp al,04h ; card code4 jne prn2 call code4_IN_print jmp grant prn2: cmp al,06h ; card code6 jne prn3 call code6_IN_print jmp grant prn3: call code8_IN_print ; card code8 grant: call clr_dis call delay mov dl,0c3h call line mov al,'A' call dis_char mov al,'C' call dis_char mov al,'C' call dis_char mov al,'E' call dis_char mov al,'S' call dis_char mov al,'S' call dis_char mov al,' ' call dis_char mov al,'G' call dis_char mov al,'R' call dis_char mov al,'A' call dis_char mov al,'N' call dis_char mov al,'T' call dis_char mov al,'E' call dis_char mov al,'D' call dis_char mov al,0ch ; Cursor Off call command mov bl,0cdh ; force data = 0cdh mov [421h],bl ; store data to [421h] (for motor rotation) ret embed: mov al,'*' call dis_char ret notify: call clr_dis call delay mov dl,080h call line mov al,'N' call dis_char mov al,'o' call dis_char mov al,' ' call dis_char mov al,'C' call dis_char mov al,'a' call dis_char mov al,'r' call dis_char mov al,'d' call dis_char mov al,' ' call dis_char mov al,'I' call dis_char mov al,'n' call dis_char mov al,'s' call dis_char mov al,'e' call dis_char mov al,'r' call dis_char mov al,'t' call dis_char mov al,'e' call dis_char mov al,'d' call dis_char mov dl,0c0h call line mov al,'P' call dis_char mov al,'l' call dis_char mov al,'e' call dis_char mov al,'a' call dis_char mov al,'s' call dis_char mov al,'e' call dis_char mov al,' ' call dis_char mov al,'I' call dis_char mov al,'n' call dis_char mov al,'s' call dis_char mov al,'e' call dis_char mov al,'r' call dis_char mov al,'t' call dis_char mov al,' ' call dis_char mov al,'V' call dis_char mov al,'a' call dis_char mov al,'l' call dis_char mov al,'i' call dis_char mov al,'d' call dis_char mov dl,94h call line mov al,'C' call dis_char mov al,'a' call dis_char mov al,'r' call dis_char mov al,'d' call dis_char mov al,' ' call dis_char mov al,'F' call dis_char mov al,'i' call dis_char mov al,'r' call dis_char mov al,'s' call dis_char mov al,'t' call dis_char mov al,'.' call dis_char call longdelay call longdelay call longdelay call longdelay call longdelay call longdelay call longdelay mov al,'.' call dis_char call longdelay call longdelay call longdelay call longdelay call longdelay call longdelay call longdelay mov al,'.' call dis_char call longdelay call longdelay call longdelay call longdelay call longdelay call longdelay call longdelay mov al,0ch ; Cursor Off call command ret invalid_card: call clr_dis call delay mov dl,0c4h call line mov al,'I' call dis_char mov al,'n' call dis_char mov al,'v' call dis_char mov al,'a' call dis_char mov al,'l' call dis_char mov al,'i' call dis_char mov al,'d' call dis_char mov al,' ' call dis_char mov al,'C' call dis_char mov al,'a' call dis_char mov al,'r' call dis_char mov al,'d' call dis_char mov al,0ch ; Cursor Off call command call longdelay2 ret waitMSG: call clr_dis call delay mov dl,0c4h call line mov al,'P' call dis_char mov al,'r' call dis_char mov al,'o' call dis_char mov al,'c' call dis_char mov al,'e' call dis_char mov al,'s' call dis_char mov al,'s' call dis_char mov al,' ' call dis_char mov al,'S' call dis_char mov al,'t' call dis_char mov al,'o' call dis_char mov al,'p' call dis_char mov dl,96h call line mov al,'P' call dis_char mov al,'l' call dis_char mov al,'e' call dis_char mov al,'a' call dis_char mov al,'s' call dis_char mov al,'e' call dis_char mov al,' ' call dis_char mov al,'W' call dis_char mov al,'a' call dis_char mov al,'i' call dis_char mov al,'t' call dis_char mov al,'.' call dis_char mov al,'.' call dis_char mov al,'.' call dis_char mov al,0ch ; Cursor Off call command ret num1: call clr_dis call delay mov dl,0c3h ; LCD initial line >> key_1 call line mov al,'R' call dis_char mov al,'e' call dis_char mov al,'a' call dis_char mov al,'d' call dis_char mov al,'i' call dis_char mov al,'n' call dis_char mov al,'g' call dis_char mov al,' ' call dis_char mov al,'C' call dis_char mov al,'a' call dis_char mov al,'r' call dis_char mov al,'d' call dis_char mov al,'.' call dis_char call longdelay call longdelay call longdelay call longdelay call longdelay mov al,'.' call dis_char call longdelay call longdelay call longdelay call longdelay call longdelay mov al,'.' call dis_char call longdelay2 mov al,0ch ;cursor off / bink off call command xor ax,ax in al,22h ;Port C PPI2 Card Slot (input) mov [300h],al ;save DATA for CARD & PIN Validation cmp al,00h jne ccc call notify call longdelay2 jmp iii ccc: cmp al,02h jne ddd jmp ggg ddd: cmp al,04h jne eee jmp ggg eee: cmp al,06h jne fff jmp ggg fff: cmp al,08h je ggg call invalid_card jmp iii ggg: call accept_code ; procedure called if card is valid call ask_pin hhh: mov al,[421h] ; retrieve data from mem.[421h] cmp al,0cdh ; if access granted then data should be <0cdh> if e call open_motor ; door open iii: nop ret num2: call clr_dis call delay mov dl,0c3h ; LCD initial line >> key_1 call line mov al,'R' call dis_char mov al,'e' call dis_char mov al,'a' call dis_char mov al,'d' call dis_char mov al,'i' call dis_char mov al,'n' call dis_char mov al,'g' call dis_char mov al,' ' call dis_char mov al,'C' call dis_char mov al,'a' call dis_char mov al,'r' call dis_char mov al,'d' call dis_char mov al,'.' call dis_char call longdelay call longdelay call longdelay mov al,'.' call dis_char call longdelay call longdelay call longdelay mov al,'.' call dis_char call longdelay2 mov al,0ch ;cursor off / bink off call command xor ax,ax in al,22h ;Port C PPI2 Card Slot (input) mov [300h],al ;save DATA for CARD & PIN Validation cmp al,00h jne a1 call notify call longdelay2 jmp a6 a1: cmp al,02h jne a2 jmp a5 a2: cmp al,04h jne a3 jmp a5 a3: cmp al,06h jne a4 jmp a5 a4: cmp al,08h je a5 call invalid_card jmp a6 a5: call accept_code ; procedure called if card is accepted call ch_pin ; procedure called for changing PIN a6: nop ret clr_dis: mov al,01h ; clear current display call command ret initPPI1: mov al,89h ;(PortA-OUT PortB-OUT PortC-IN) out 13h,al ret initPPI2: mov al,9bh ;(PortA-IN PortB-IN PortC-IN) out 23h,al ret initPPI3: mov al,80h ;(PortA-OUT PortB-OUT PortC-OUT) out 33h,al ret initPPI4: mov al,82h ;(PortA-OUT PortB-IN PortC-OUT) out 43h,al ret init_PIN: ;default PIN >> 67890 initialize all PIN Code xor ax,ax mov [422h],ax ; used for 7 segment display mov [423h],ax ; used for 7 segment display mov si,420h mov al,0abh ; data to compare if mem is already in use mov [si],al mov si,405h ; start Address for CODE2 mov al,61h mov [si],al inc si mov al,81h mov [si],al inc si mov al,91h mov [si],al inc si mov al,0a1h mov [si],al inc si mov al,0d1h mov [si],al mov si,40ah ; start Address for CODE4 mov al,61h mov [si],al inc si mov al,81h mov [si],al inc si mov al,91h mov [si],al inc si mov al,0a1h mov [si],al inc si mov al,0d1h mov [si],al mov si,40fh ; start Address for CODE6 mov al,61h mov [si],al inc si mov al,81h mov [si],al inc si mov al,91h mov [si],al inc si mov al,0a1h mov [si],al inc si mov al,0d1h mov [si],al mov si,414h ; start Address for CODE8 mov al,61h mov [si],al inc si mov al,81h mov [si],al inc si mov al,91h mov [si],al inc si mov al,0a1h mov [si],al inc si mov al,0d1h mov [si],al ret init_LCD: call delay mov al,38h ;1st function set call command call delay mov al,38h ;2nd function set call command mov al,38h ;3rd function set call command call delay mov al,01h call command mov al,0eh ;display on / cursor on / bink off call command ret dis_char: out 10h,al mov al,0a0h out 11h,al call delay mov al,01h out 11h,al ret command: out 10h,al call delay mov al,80h out 11h,al call delay mov al,00h out 11h,al ret delay: mov cx,0ffh xxx: loop xxx ret delay2: mov cx,0fffh yyy: loop yyy ret stepdelay: mov cx,02ffh steps: loop steps ret longdelay: call delay2 call delay2 call delay2 call delay2 call delay2 ret longdelay2: call longdelay call longdelay call longdelay call longdelay call longdelay call longdelay call longdelay call longdelay call longdelay call longdelay call longdelay call longdelay call longdelay call longdelay call longdelay call longdelay call longdelay call longdelay call longdelay call longdelay call longdelay call longdelay call longdelay call longdelay call longdelay call longdelay ret line: xor ax,ax mov al,dl call command ret detect_mem_store: mov ds,ax mov si,420h mov al,[si] cmp al,0abh jne not_stored jmp stored not_stored: call init_PIN stored: ret open_motor: call longdelay2 call clr_dis call menu xor ax,ax mov al,11h push ax motor1: pop ax call stepdelay out 32h,al rol al,01h push ax in al,21h ; in switch status and al,04h ; get switch status (bit 2) cmp al,04h jne motor1 call rotate_stop_and_close ret close_motor: mov al,11h push ax motor2: pop ax call stepdelay out 32h,al ror al,01h push ax in al,21h ; in switch status and al,02h ; get switch status (bit 1) cmp al,02h jne motor2 call delay2 mov al,00h ; set back to default value of port out 32h,al ; to protect the step driver from high TEMPERATURE ret rotate_stop_and_close: mov al,00h ; set back to default value of port out 32h,al ; to protect the step driver from high TEMPERATURE call longdelay2 call longdelay2 call close_motor jmp restart ret incs: mov cx,[423h] ; pop counter mov bx,[422h] ; pop number of entries inc bl inc cl cmp cl,0ah jne incs_a call add1 incs_a: mov al,bl out 30h,al mov [422h],bl ; store current number of entries mov [423h],cl ; store current counter full: ret add1: cmp bl,9ah jne add1_a call add2 jmp add1_b add1_a: add bl,06h add1_b: xor cx,cx ret add2: add bx,66h mov al,bh out 31h,al ret decs: mov cx,[423h] ; pop counter mov bx,[422h] ; pop number of entries cmp cl,00h jne decs_a call sub1 jmp decs_b decs_a: dec bl dec cl decs_b: mov al,bl out 30h,al mov [422h],bl ; store current number of entries mov [423h],cl ; store current counter ret sub1: cmp bl,00h jne sub1_a call sub2 jmp sub1_b sub1_a: sub bl,07h sub1_b: mov cl,09h ret sub2: sub bx,67h mov al,bh out 31h,al ret code2_IN_print: call print_next_line mov al,'C' call printer mov al,'O' call printer mov al,'D' call printer mov al,'E' call printer mov al,' ' call printer mov al,'2' call printer ret code4_IN_print: call print_next_line mov al,'C' call printer mov al,'O' call printer mov al,'D' call printer mov al,'E' call printer mov al,' ' call printer mov al,'4' call printer ret code6_IN_print: call print_next_line mov al,'C' call printer mov al,'O' call printer mov al,'D' call printer mov al,'E' call printer mov al,' ' call printer mov al,'6' call printer ret code8_IN_print: call print_next_line mov al,'C' call printer mov al,'O' call printer mov al,'D' call printer mov al,'E' call printer mov al,' ' call printer mov al,'8' call printer ret intro: ; routine for introduction message mov al,'W' call printer mov al,'E' call printer mov al,'L' call printer mov al,'C' call printer mov al,'O' call printer mov al,'M' call printer mov al,'E' call printer mov al,'!' call printer mov al,'!' call printer mov al,' ' call printer mov al,'T' call printer mov al,'E' call printer mov al,'A' call printer mov al,'M' call printer mov al,' ' call printer mov al,'O' call printer mov al,'F' call printer mov al,' ' call printer mov al,'I' call printer mov al,'N' call printer mov al,'S' call printer mov al,'T' call printer mov al,'R' call printer mov al,'U' call printer mov al,'C' call printer mov al,'T' call printer mov al,'O' call printer mov al,'R' call printer mov al,'S' call printer call print_next_line mov al,'C' call printer mov al,'O' call printer mov al,'L' call printer mov al,'L' call printer mov al,'E' call printer mov al,'G' call printer mov al,'E' call printer mov al,' ' call printer mov al,'O' call printer mov al,'F' call printer mov al,' ' call printer mov al,'C' call printer mov al,'O' call printer mov al,'M' call printer mov al,'P' call printer mov al,'U' call printer mov al,'T' call printer mov al,'E' call printer mov al,'R' call printer mov al,' ' call printer mov al,'E' call printer mov al,'N' call printer mov al,'G' call printer mov al,'I' call printer mov al,'N' call printer mov al,'E' call printer mov al,'E' call printer mov al,'R' call printer mov al,'I' call printer mov al,'N' call printer mov al,'G' call printer call print_next_line mov al,'P' call printer mov al,'R' call printer mov al,'O' call printer mov al,'J' call printer mov al,'E' call printer mov al,'C' call printer mov al,'T' call printer mov al,' ' call printer mov al,'D' call printer mov al,'E' call printer mov al,'S' call printer mov al,'I' call printer mov al,'G' call printer mov al,'N' call printer call print_next_line mov al,'M' call printer mov al,'P' call printer mov al,'U' call printer mov al,'-' call printer mov al,'B' call printer mov al,'A' call printer mov al,'S' call printer mov al,'E' call printer mov al,'D' call printer mov al,' ' call printer mov al,'E' call printer mov al,'N' call printer mov al,'C' call printer mov al,'R' call printer mov al,'O' call printer mov al,'A' call printer mov al,'C' call printer mov al,'M' call printer mov al,'E' call printer mov al,'N' call printer mov al,'T' call printer call print_next_line mov al,'S' call printer mov al,'E' call printer mov al,'C' call printer mov al,'U' call printer mov al,'R' call printer mov al,'I' call printer mov al,'T' call printer mov al,'Y' call printer mov al,' ' call printer mov al,'A' call printer mov al,'C' call printer mov al,'C' call printer mov al,'E' call printer mov al,'S' call printer mov al,'S' call printer mov al,' ' call printer mov al,'S' call printer mov al,'Y' call printer mov al,'S' call printer mov al,'T' call printer mov al,'E' call printer mov al,'M' call printer call print_next_line call print_next_line call print_next_line call print_next_line mov al,' ' call printer mov al,' ' call printer mov al,' ' call printer mov al,' ' call printer mov al,'L' call printer mov al,'O' call printer mov al,'G' call printer mov al,' ' call printer mov al,'L' call printer mov al,'I' call printer mov al,'S' call printer mov al,'T' call printer ret print_next_line: mov al,0Dh ; carriage return call printer mov al,0Ah ; line feed call printer ret printer: ; printer routine for printing mov dx,40h out dx,al mov al, 04h ; selectIN=0 init=1 autofeed=0 strobe=0 mov dx, 42h out dx, al call printer_timing mov al, 05h ; let know the printer if data is transmitted out dx, al ; where ( selectIN=0 init=1 autofeed=0 strobe=1) ack: mov dx, 41h ; detect if data has been acknowledge by the printer in al,dx and al, 01h jz ack busy: mov dx,41h ; detect if printer is busy in al, dx and al, 02h jnz busy ret printer_timing: mov cx,0f00h prn: loop prn ret |