You are on page 1of 3

;

; barrido teclado.asm
;
; Created: 17/06/2018 12:51:59
; Author : Mateo V�squez
;

;declaracion de variables
.def tempo = r16
.def conta = r17
.def numero_A = r18
.def numero_B = r19
.def tecla = r20
.def aux = r21
.def ante = r23

; reserva de memoria
.dseg
binario:.byte 2
bcd0: .byte 1
bcd1: .byte 1
bcd2: .byte 1
bcd3: .byte 1
dig0: .byte 1
dig1: .byte 1
dig2: .byte 1
dig3: .byte 1
num: .byte 1
valor1: .byte 1
valor2: .byte 1
valor3: .byte 1

;********** configuracion puertos*************


.cseg
.org 0x00
ldi tempo,0x00
out ddra,tempo
ldi tempo,0xff
out porta,tempo
ldi tempo,0x0f //teclado
out ddrb,tempo
ldi tempo,0xf0
out portb,tempo
ldi tempo,0x7f //display
out ddrc,tempo
ldi tempo,0x80
out portc,tempo
ldi tempo,0xf0//control de displays
out ddrd,tempo
ldi tempo,0x0f
out portd,tempo

in tempo, mcucr
andi tempo, 0b11101111
out mcucr, tempo

ldi tempo,high(ramend)
out sph,tempo
ldi tempo,low(ramend)
out spl,tempo
ldi tempo,0x00
sts binario,tempo
clr conta
ldi ante,16

inicio:
rcall binario_bcd
rcall bcd_digitos
rcall barrido_display
rcall barrido_teclas
manejo_de_datos:
lds aux,num
cpi aux,10
breq borrar
cpi aux,11
breq resultado
cpi aux,12
breq por
call acomodar
rjmp inicio

borrar:
clr tempo
;sts valor1,tempo
;sts valor2,tempo
;sts valor3,tempo
ldi xh,high(binario)
ldi xl,low(binario)
st x+,tempo
st x,tempo
clr numero_A
;clr numero_B
clr conta
clr r0
clr r1
rjmp inicio
;************* por ******************
por:
sts valor3,numero_A
clr numero_B
clr tempo
sts valor1,tempo
sts valor2,tempo
ldi xh,high(binario)
ldi xl,low(binario)
st x+,tempo
st x,tempo
clr conta

rjmp inicio

;**************** resultado ****************


resultado:
lds numero_B,valor3
mul numero_A,numero_B
ldi xh,high(binario)
ldi xl,low(binario)
st x+,r0
st x,r1
clr conta
rjmp inicio

;************** acomodar ********************


acomodar:
lds numero_A,valor1
lds numero_B,valor2
cpi conta,1
brne modificar
rjmp seguir
modificar:
ldi tempo,10
mul numero_A,tempo
mov numero_A,r0
add numero_A,numero_B
seguir:
sts binario,numero_A
ret

.INCLUDE "binario_bcd.asm"
.INCLUDE "bcd_digitos.asm"
.INCLUDE "barrido_display.asm"
.INCLUDE "barrido_teclas.asm"

You might also like