58TP326 V4.indd
öÜÙúǰǰđéßîÙøĉ îìøŤ ĜġĤ üćøÿćøøćßïĆ èæĉ ê÷ÿëćî ðŘ ìĊę ǰĤĪǰÞïĆ ïìĊę ǰĥǰê Ù í Ù ǰģĦĦĨ main proc cli mov ax,0 mov ds,ax mov es,ax mov ss,ax mov ax,8000h mov sp,ax FRQ¿J V IRU PRGH RQ $ % ;ports A, C = input, B = output mov al,10011001b out ppi_ctrl_port1,al out ppi_ctrl_port2,al sti cirloop: mov ch,0 mov dh,01h outloop: mov al,dh out ppi_port1_b,al call delay2 call delay2 call delay2 call delay2 mov cl,0 mov dl,01h inloop: call delay1 in al,ppi_port1_a cmp al,dl je getone shl dl,1 inc cl cmp cl,4 jb inloop point1: shl dh,1 inc ch cmp ch,4 jb outloop mov al,0FFh call outport2 mov al,0 call outport2 jmp cirloop getone: mov bl,cl shl bl,1 shl bl,1 add bl,ch mov al,bl out ppi_port2_b,al ;prevent other interrupts ;set all segments to 0000h ;set stack top at 8000h ;enable system interrupts ;col count starts at 0 ;col value starts at 1 ;col value: dh = 1->2->4->8 ;pull up one col hi ;slow down the scan ;row count starts at 0 ;row value starts at 1 ;read key data ;row value: dl = 1->2->4->8 ;a key is pressed ;row value x 2 ;next row ;end of row scan? ;No! ;col value x 2 ;next col ;end of col scan? ;No! ;no keys pressed ;all LEDs light up ;turn off all LEDs ;repeat key scan ;a key is pressed ;bl = 4*row ;bl = 4*row + col = 0->1->2 … ->E->F ;al = keycode ;display keycode 58TP326 V4.indd 169 8/7/2558 BE 3:44 PM
Made with FlippingBook
RkJQdWJsaXNoZXIy NTk0NjM=