13.11.2012 Views

Mis primeros programas en assembler - Micros Designs

Mis primeros programas en assembler - Micros Designs

Mis primeros programas en assembler - Micros Designs

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

22. retlw b'1011011' ; 2<br />

23. retlw b'1001111' ; 3<br />

24. retlw b'1100110' ; 4<br />

25. retlw b'1101101' ; 5<br />

26. retlw b'1111101' ; 6<br />

27. retlw b'0000111' ; 7<br />

28. retlw b'1111111' ; 8<br />

29. retlw b'1101111' ; 9<br />

30. clrf Contador ; Si llega 10, se resetea contador<br />

31. retlw b'0111111' ; 0<br />

32.<br />

33. ;**** Programa principal ****<br />

34. ;**** Configuración de puertos ****<br />

35. Inicio bsf STATUS,RP0 ; Pasamos de Banco 0 a Banco 1.-<br />

36. movlw b'10000000' ; RB7 como <strong>en</strong>trada y los demás como<br />

salida.-<br />

37. movwf TRISB<br />

38. bcf STATUS,RP0 ; Paso del Banco 1 al Banco 0<br />

39. movlw b'0111111' ; Comi<strong>en</strong>za <strong>en</strong> cero.-<br />

40. movwf PORTB<br />

41. clrf Contador<br />

42. ;**** Testeo de Pulsador ****<br />

43. Testeo<br />

44. btfss PORTB,Pulsador ; Testeamos si esta a 1 lógico.-<br />

45. goto Testeo ; No, seguimos testeando.-<br />

46. call Demora_20ms ; Eliminamos Efecto rebote<br />

47. btfss PORTB,Pulsador ; Testeamos nuevam<strong>en</strong>te.-<br />

48. goto Testeo ; Falsa Alarma, seguimos<br />

testeando.-<br />

49. incf Contador,1 ; Se ha pulsado, increm<strong>en</strong>tamos<br />

contador.-<br />

50. movfw Contador ; pasamos contador a W<br />

51. call BCD7SEG ; Llamamos tabla.-<br />

52. movwf PORTB ; Cargamos valor recibido por Tabla<br />

<strong>en</strong> PORTB<br />

53. btfsc PORTB,Pulsador ; Esperamos a que se suelte el pulsador -<br />

**-<br />

54. goto $-1 ; No, PCL - 1, --> btfss<br />

PORTA,Pulsador.-<br />

55. call Demora_20ms ; Eliminamos efecto rebote.-<br />

56. btfsc PORTB,Pulsador ; Testeamos nuevam<strong>en</strong>te.-<br />

57. goto $-4 ; No, Falsa alarma, volvemos a<br />

testear a que se suelte (**).-<br />

58. goto Testeo ; Si, Testeamos nuevam<strong>en</strong>te.-<br />

59.<br />

60. ;**** Demora ****<br />

61. Demora_20ms<br />

62. movlw 0xFF ;<br />

63. movwf Contador1 ; Iniciamos contador1.-<br />

64. Repeticion1<br />

65. movlw 0x19 ;<br />

66. movwf Contador2 ; Iniciamos contador2<br />

67. Repeticion2<br />

68. decfsz Contador2,1 ; Decrem<strong>en</strong>ta Contador2 y si es 0<br />

sale.-<br />

69. goto Repeticion2 ; Si no es 0 repetimos ciclo.-<br />

70. decfsz Contador1,1 ; Decrem<strong>en</strong>ta Contador1.-<br />

71. goto Repeticion1 ; Si no es cero repetimos ciclo.-<br />

72. return ; Regresa de la subrutina.-<br />

73.<br />

74. <strong>en</strong>d<br />

Autor: Suky Mail: inf.pic.suky@live.com.ar Web: www.micros-designs.com.ar

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!