Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;-------------------------------Deklarationer-------------------------------
- .def AntalBeeps = r19
- .def char_ascii = r20
- .def char_morse = r21
- .def beep_sound_on = r22
- .equ speed = 20
- .equ ton = $1F ;1F
- ;Sätt upp stackpeckaren
- ldi r16,high(RAMEND)
- out sph,r16
- ldi r16,low(RAMEND)
- out spl,r16
- INIT:
- ldi r16, $01
- out DDRA,r16
- ;-------------------------------MAIN-------------------------------
- SETUP: ;Sätt peckare till ordet
- ldi ZL, LOW(NAMN*2)
- ldi ZH, HIGH(NAMN*2)
- MORSE:
- LPM char_ascii, Z+ ;(GET_CHAR) Läs in ascii värdet
- cpi char_ascii, $0 ;Kolla om vi är i slutet
- BREQ KLAR ;Om vi är i slutet hoppa till klar
- cpi char_ascii, $20 ;Kolla om tecknet var ett mellanslag
- BREQ MELLANSLAG ;Om tecknet var ett mellanslag hoppa och gör det i morse
- SEND_IT:
- push ZH
- push ZL
- ldi ZH, HIGH(TABELL*2)
- subi char_ascii, $41
- mov ZL, char_ascii
- LPM char_morse, Z
- pop ZL
- pop ZH
- BEEP_CHAR:
- lsl char_morse
- BRNE SOUND
- KLAR_LJUD:
- ldi AntalBeeps, speed*2
- clr beep_sound_on
- rcall BEEP
- rjmp MORSE
- SOUND:
- BRCC BEEP_1N
- ldi AntalBeeps, speed*3 ;BEEP 3N
- RJMP SOUND_BEEPS
- BEEP_1N:
- ldi AntalBeeps, speed ;BEEP 1N
- SOUND_BEEPS:
- ldi beep_sound_on, $1
- rcall BEEP
- ldi AntalBeeps, speed
- clr beep_sound_on
- rcall BEEP
- rjmp BEEP_CHAR
- ;-------------------------------LJUD-----------------------------------
- BEEP:
- ldi r17, $10
- out PORTA, beep_sound_on
- call TON_BEEP
- ldi r17, $10
- cbi PORTA,0
- call TON_BEEP
- dec AntalBeeps
- BRNE BEEP
- ret
- TON_BEEP:
- ldi r18, ton
- WAIT:
- dec r18
- BRNE WAIT
- dec r17
- BRNE TON_BEEP
- ret
- ;-------------------------------HELP-----------------------------------
- MELLANSLAG:
- clr beep_sound_on
- ldi AntalBeeps, 4*speed
- rcall BEEP
- rjmp MORSE
- KLAR:
- rjmp KLAR
- ;-------------------------------TABELLER-------------------------------
- .org $100 ;256
- NAMN: .db "SOS HEJ HOPP I LINGONBSKOGEN", $00
- .org $180 ;DVS TABELL är på $0300
- TABELL: .db $60, $88, $A8, $90, $40, $28, $D0, $08, $20, $78, $B0, $48, $E0, $A0, $F0, $68, $D8, $50, $10, $C0, $30, $18, $70, $98, $B8, $C8
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement