Code:
input---input---input-input---input---input
;****** BASIC CODE **********************
;-Line--0008----Open Com=PORTB.1,9600 For Input As #1--
sbi PORTB,1
;-Line--0010----Input #1, text--
ldi r25,10
ldi xl,Low(text)
ldi xh,high(text)
call _InS1
;-Line--0012----End--
L0000:
jmp L0000
;****** End OF BASIC CODE ****************
;////// Com1Input /////////////////////////
_Com1I: ldi r24,0x09
_C1I1: sbic PINB,1
rjmp _C1I1
ldi r23,135
rcall _Wtic
_C1I2: ldi r23,135
rcall _Wtic
ldi r23,135
rcall _Wtic
clc
sbic PINB,1
sec
dec r24
breq _C1I3
ror zl
rjmp _C1I2
_C1I3: ret
;////// Soft Input On Com1 ///////////////
_SIC1: ldi xl,Low(RAMEND - 32)
ldi xh,high(RAMEND - 32)
ldi r25,0x06
_InS1: rcall _Com1I
cpi zl,0x0a
breq _InS1
cpi zl,0x0d
breq _InE1
cpi zl,0x08
breq _InB1
tst r25
breq _InS1
st X+,zl
dec r25
rjmp _InS1
_InE1: clr zl
st X,zl
ret
_InB1: inc r25
sbiw xl,0x01
rjmp _InS1
;////// Wait r23 ticks /////////////////////
_Wtic: dec r23
brne _Wtic
ret
print---print-----print-print---print-----print
;****** BASIC CODE **********************
;-Line--0008----Open Com=PORTB.0,9600 For Output As #1--
sbi PORTB,0
sbi DDRB,0
;-Line--0010----text="pebi"--
ldi zl,Low(S000*2)
ldi zh,high(S000*2)
ldi r20,11
ldi xl,Low(text)
ldi xh,high(text)
call _StStC
;-Line--0012----Print #1, text--
ldi zl,Low(text)
ldi zh,high(text)
call _PC1St
call _C1OCL
;-Line--0013----End--
L0000:
jmp L0000
;****** End OF BASIC CODE ****************
; String constants:
S000: .db "pebi", 0
;////// StoreStrConst /////////////////////
_StStC: tst r20
breq _StSC4
_StSC3: lpm
tst r0
breq _StSC2
dec r20
breq _StSC1
st X+,r0
adiw zl,0x01
rjmp _StSC3
_StSC1: clr r0
_StSC2: st X+,r0
sbiw xl,0x01
_StSC4: ret
;////// Print String //////////////////////
_PC1St: ld r24,Z+
tst r24
breq _PC1S1
rcall _Com1O
rjmp _PC1St
_PC1S1: ret
;////// Print Cr, Lf On Com1 //////////////
_C1OCL: ldi r24,0x0d
rcall _Com1O
ldi r24,0x0a
;////// Com1Out /////////////////////////////
_Com1O: ldi r25,10
Com r24
sec
_C1O0: brcc _C1O1
cbi PORTB,0
rjmp _C1O2
_C1O1: sbi PORTB,0
Nop
_C1O2: ldi r23,135
rcall _Wtic
ldi r23,135
rcall _Wtic
lsr r24
dec r25
brne _C1O0
ret
;////// Wait r23 ticks /////////////////////
_Wtic: dec r23
brne _Wtic
ret
Lesezeichen