-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_back_up.asm
1579 lines (1207 loc) · 22.5 KB
/
main_back_up.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
.include "m2560def.inc"
.dseg
.macro do_lcd_command
ldi r16, @0
rcall lcd_command
rcall lcd_wait
.endmacro
.macro do_lcd_data
ldi r16, @0
rcall lcd_data
rcall lcd_wait
.endmacro
.macro do_lcd_data_r
mov r16, @0
rcall lcd_data
rcall lcd_wait
.endmacro
item1: .byte 1
item1Cost: .byte 1
item2: .byte 1
item2Cost: .byte 1
item3: .byte 1
item3Cost: .byte 1
item4: .byte 1
item4Cost: .byte 1
item5: .byte 1
item5Cost: .byte 1
item6: .byte 1
item6Cost: .byte 1
item7: .byte 1
item7Cost: .byte 1
item8: .byte 1
item8Cost: .byte 1
item9: .byte 1
item9Cost: .byte 1
.cseg
.def temp1 = r16
.def timerCounter = r17
.def rmask = r18 ; mask for current row during scan
.def cmask = r19 ; mask for current column during scan
.def row = r20 ; current row number
.def col = r21 ; current column number
.def temp2 = r22
.def temp3 = r23
.def temp4 = r24
.def flag1 = r25
.equ TopLED = 0b00000010
.equ SecondLED = 0b00000001
.equ PORTADIR = 0xF0 ; PD7-4: output, PD3-0, input
.equ INITCOLMASK = 0xEF ; scan from the rightmost column,
.equ INITROWMASK = 0x01 ; scan from the top row
.equ ROWMASK = 0x0F ; for obtaining input from Port D
.org 0x0000
jmp Main;
.org INT0addr //for push button
jmp EXT_INT0
.org INT1addr //for push button
jmp EXT_INT1
.org OVF1addr
jmp Timer1
.org OVF0addr
jmp Timer0
jmp DEFAULT
DEFAULT: reti
EXT_INT0:
push temp1
in temp1, SREG
push temp1
cpi r27, 1
brne End
mov temp1, temp4
subi temp1,-'0'
rcall returnInventory
ld temp1, Z
cpi temp1, 10
breq End
inc temp1
st Z, temp1
rcall sleep_250ms
mov temp1, temp4
subi temp1, -'0'
rcall adminMode
End:
pop temp1
out SREG, temp1
pop temp1
reti
EXT_INT1:
push temp1
in temp1, SREG
push temp1
cpi r27, 1
brne End2
mov temp1, temp4
subi temp1,-'0'
rcall returnInventory
ld temp1, Z
cpi temp1,0
breq End2
dec temp1
st Z, temp1
rcall sleep_250ms
mov temp1, temp4
subi temp1, -'0'
rcall adminMode
End2:
pop temp1
out SREG, temp1
pop temp1
reti
Main:
clr r17
clr r18
clr r19
clr r20
clr r21
clr r22
clr flag1
clr r26 //flag2
clr r27 //admin flag
sts DDRK, r22
ldi YH,high(item1)
ldi YL,low(item1)
ldi temp1, 1
st y, temp1
ldi YH,high(item1Cost)
ldi YL,low(item1Cost)
ldi temp1,1
st y, temp1
ldi YH,high(item2)
ldi YL,low(item2)
ldi temp1, 2
st y, temp1
ldi YH,high(item2Cost)
ldi YL,low(item2Cost)
ldi temp1,2
st y, temp1
ldi YH,high(item3)
ldi YL,low(item3)
ldi temp1, 3
st y, temp1
ldi YH,high(item3Cost)
ldi YL,low(item3Cost)
ldi temp1,1
st y, temp1
ldi YH,high(item4)
ldi YL,low(item4)
ldi temp1, 4
st y, temp1
ldi YH,high(item4Cost)
ldi YL,low(item4Cost)
ldi temp1,2
st y, temp1
ldi YH,high(item5)
ldi YL,low(item5)
ldi temp1, 5
st y, temp1
ldi YH,high(item5Cost)
ldi YL,low(item5Cost)
ldi temp1,1
st y, temp1
ldi YH,high(item6)
ldi YL,low(item6)
ldi temp1, 6
st y, temp1
ldi YH,high(item6Cost)
ldi YL,low(item6Cost)
ldi temp1,2
st y, temp1
ldi YH,high(item7)
ldi YL,low(item7)
ldi temp1, 7
st y, temp1
ldi YH,high(item7Cost)
ldi YL,low(item7Cost)
ldi temp1,1
st y, temp1
ldi YH,high(item8)
ldi YL,low(item8)
ldi temp1, 8
st y, temp1
ldi YH,high(item8Cost)
ldi YL,low(item8Cost)
ldi temp1,2
st y, temp1
ldi YH,high(item9)
ldi YL,low(item9)
ldi temp1, 9
st y, temp1
ldi YH,high(item9Cost)
ldi YL,low(item9Cost)
ldi temp1,1
st y, temp1
clr temp1 ; connected to PE4 (externally labelled PE2)
sts OCR3AH, temp1
sts OCR3AL, temp1
ldi temp1, (1 << CS30) ; set the Timer3 to Phase Correct PWM mode.
sts TCCR3B, temp1
ldi temp1, (1 << WGM31)|(1<< WGM30)|(1<<COM3B1)|(1<<COM3A1)
sts TCCR3A, temp1
ser r16
out DDRC, r16
out DDRE, temp1
out DDRG, temp1
ldi r16, low(RAMEND)
out SPL, r16
ldi r16, high(RAMEND)
out SPH, r16
ser r16 ; LCD setup
out DDRF, r16
out DDRA, r16
clr r16
out PORTF, r16
out PORTA, r16
do_lcd_command 0b00111000 ; 2x5x7
rcall sleep_5ms
do_lcd_command 0b00111000 ; 2x5x7
rcall sleep_1ms
do_lcd_command 0b00111000 ; 2x5x7
do_lcd_command 0b00111000 ; 2x5x7
do_lcd_command 0b00001000 ; display off?
do_lcd_command 0b00000001 ; clear display
do_lcd_command 0b00000110 ; increment, no display shift
do_lcd_command 0b00001110 ; Cursor on, bar, no blink
do_lcd_command 0b10000000
ldi r18, 0b00000000 ;Timer setup for start screen 3 second wait
out TCCR0A, r18
ldi r18, 0b00000101
out TCCR0B, r18
ldi r18, 1<<TOIE0
sts TIMSK0, r18
ldi r18, 0b00000000 ;Timer setup for start screen 3 second wait
sts TCCR1A, r18
ldi r18, 0b00000011
sts TCCR1B, r18
;ldi r18, 1<<TOIE1
clr r18
sts TIMSK1, r18
ldi temp1, PORTADIR ;keypad setup
sts DDRL, temp1 ; PA7:4/PA3:0, out/in
sei
do_lcd_data '2'
do_lcd_data '1'
do_lcd_data '2'
do_lcd_data '1'
do_lcd_data ' '
do_lcd_data '1'
do_lcd_data '7'
do_lcd_data 's'
do_lcd_data '1'
do_lcd_data ' '
do_lcd_data ' '
do_lcd_data ' '
do_lcd_data 'E'
do_lcd_data '4'
do_lcd_command 0b10101000
do_lcd_data 'V'
do_lcd_data 'e'
do_lcd_data 'n'
do_lcd_data 'd'
do_lcd_data 'i'
do_lcd_data 'n'
do_lcd_data 'g'
do_lcd_data ' '
do_lcd_data 'M'
do_lcd_data 'a'
do_lcd_data 'c'
do_lcd_data 'h'
do_lcd_data 'i'
do_lcd_data 'n'
do_lcd_data 'e'
rjmp KeypadLoop
halt:
rjmp halt
KeypadLoop:
ldi cmask, INITCOLMASK ; initial column mask
clr col ; initial column
colloop:
cpi col, 4
breq KeypadLoop ; If all keys are scanned, repeat.
sts PORTL, cmask ; Otherwise, scan a column.
ldi temp1, 0xFF ; Slow down the scan operation.
delay: dec temp1
brne delay //assuming this counts down to 0 from 255, otherwise, idk.
lds temp1, PINL ; Read PORTA
andi temp1, ROWMASK ; Get the keypad output value
cpi temp1, 0xF ; Check if any row is low??? 0b1101
breq nextcol ; If yes, find which row is low
ldi rmask, INITROWMASK ; Initialize for row check
clr row ;
rowloop:
cpi row, 4
breq nextcol ; the row scan is over.
mov temp2, temp1
and temp2, rmask ; check un-masked bit
breq convert ; if bit is clear, the key is pressed
inc row ; else move to the next row
lsl rmask
jmp rowloop
nextcol: ; if row scan is over
lsl cmask
inc cmask
inc col ; increase column value
jmp colloop ; go to the next column
SetZero:
mov temp1, temp4
subi temp1,-'0'
rcall returnInventory
clr temp1
st Z, temp1
mov temp1, temp4
subi temp1, -'0'
rcall sleep_100ms
rcall adminMode
rjmp KeypadLoop
convert:
cpi col, 3 ; If the pressed key is in col.3
breq letters ; we have a letter
; If the key is not in col.3 and
cpi row, 3 ; If the key is in row3,
breq symbols ; we have a symbol or 0
mov temp1, row ; Otherwise we have a number in 1-9
lsl temp1
add temp1, row
add temp1, col ; temp1 = row*3 + col
subi temp1, -'1' ; Add the value of character ‘1’ //key pressed is saved as ascii
cpi r27,1
breq Adminjmp
jmp checkEmpty
letters:
ldi temp1, 0b00110010
add temp1, row
cpi r27, 1
brne convert_end
cpi row,0
breq IncreaseCost
cpi row,1
breq DecreaseCost
cpi row,2
breq SetZero
rjmp KeypadLoop
IncreaseCost:
mov temp1, temp4
subi temp1,-'0'
rcall returnInventory
ld temp1, Y
cpi temp1, 3
breq convert_end
inc temp1
st Y, temp1
mov temp1, temp4
subi temp1, -'0'
rcall sleep_100ms
rcall adminMode
rjmp KeypadLoop
DecreaseCost:
mov temp1, temp4
subi temp1,-'0'
rcall returnInventory
ld temp1, Y
cpi temp1, 1
breq convert_end
dec temp1
st Y, temp1
mov temp1, temp4
subi temp1, -'0'
rcall sleep_100ms
rcall adminMode
rjmp KeypadLoop
symbols:
cpi col, 0 ; Check if we have a star
breq star
cpi col, 1 ; or if we have zero
breq zero
ldi temp1, '#'
cpi r27,1
brne convert_end
clr flag1
clr r27
rjmp DisplaySelectScreen2
star:
;ldi temp1,'*'
cpi flag1,1
breq Flag2Check
ldi flag1, 1
ldi temp3, 1<<TOIE1 ;start timer.
sts TIMSK1, temp3
Flag2Check:
cpi r26,1
breq adminModeInitialJump ;this mode should clear r26 and flag1
;out PORTC, temp1 ; Write value to PORTC
jmp KeypadLoop
Adminjmp:
rcall adminMode
rjmp KeypadLoop
zero:
ldi temp1, '0' ; Set to zero
convert_end:
;out PORTC, temp1 ; Write value to PORTC
jmp KeypadLoop ; Restart KeypadLoop loop
.equ LCD_RS = 7
.equ LCD_E = 6
.equ LCD_RW = 5
.equ LCD_BE = 4
.macro lcd_set
sbi PORTA, @0
.endmacro
.macro lcd_clr
cbi PORTA, @0
.endmacro
adminModeInitialJump:
clr temp3
sts TIMSK1, temp3
clr flag1
clr r26
jmp adminModeInitial
Timer0: ;Timer overflow 0
ldi flag1,1
in temp1, SREG
push temp1
inc timerCounter
cpi timerCounter,192
breq displaySelectScreen
pop temp1
out SREG, temp1
reti
Timer1:
push cmask
push rmask
push temp1
push temp2
in temp1,SREG
push temp1
inc timerCounter
ldi cmask, INITCOLMASK ; initial column mask
sts PORTL, cmask ; Otherwise, scan a column.
ldi temp1, 0xFF ; Slow down the scan operation.
Hashdelay: dec temp1
brne Hashdelay //assuming this counts down to 0 from 255, otherwise, idk.
lds temp1, PINL ; Read PORTA
andi temp1, ROWMASK ; Get the keypad output value
cpi temp1, 0xF ; Check if any row is low???
breq Released ; If yes, find which row is low
ldi rmask, INITROWMASK ; Initialize for row check
lsl rmask
lsl rmask
lsl rmask
mov temp2, temp1
and temp2, rmask
breq StillPressed
rjmp Released
StillPressed:
inc timerCounter
;out PORTC, TimerCounter
cpi timerCounter, 25
brlo Finish
;ldi temp1, 0b11110000
;out PORTC, temp1
ldi r26,1
clr temp3
sts TIMSK1, temp3
clr timerCounter
Finish:
pop temp1
out SREG, temp1
pop temp2
pop temp1
pop rmask
pop cmask
reti
Released:
clr temp3
sts TIMSK1, temp3
clr flag1
clr timerCounter
;ldi temp1, 0b11111111
;out PORTC, temp1
pop temp1
out SREG, temp1
pop temp2
pop temp1
pop rmask
pop cmask
reti
displaySelectScreen:
clr timerCounter
clr flag1
clr r18
sts TIMSK0, r18 ; turn off timer.
do_lcd_command 0b00000001 ; clear display
do_lcd_command 0b10000000 ;set cursor to addr 0 on LCD
do_lcd_data 'S'
do_lcd_data 'e'
do_lcd_data 'l'
do_lcd_data 'e'
do_lcd_data 'c'
do_lcd_data 't'
do_lcd_data ' '
do_lcd_data 'i'
do_lcd_data 't'
do_lcd_data 'e'
do_lcd_data 'm'
pop temp1
out SREG, temp1
reti
checkEmpty:
//temp1 is ascii
push temp1
subi temp1, '0'
cpi temp1, 1
breq check1
cpi temp1, 2
breq check2
cpi temp1, 3
breq check3
cpi temp1, 4
breq check4
cpi temp1, 5
breq check5
cpi temp1, 6
breq check6
cpi temp1, 7
breq check7
cpi temp1, 8
breq check8
cpi temp1, 9
breq check9
check1:
ldi ZL, low(item1)
ldi ZH, high(item1)
ld temp2, Z
pop temp1
cpi temp2, 0
breq EmptyScreen
rjmp CoinScreen
check2:
ldi ZL, low(item2)
ldi ZH, high(item2)
ld temp2, Z
pop temp1
cpi temp2, 0
breq EmptyScreen
rjmp CoinScreen
check3:
ldi ZL, low(item3)
ldi ZH, high(item3)
ld temp2, Z
pop temp1
cpi temp2, 0
breq EmptyScreen
rjmp CoinScreen
check4:
ldi ZL, low(item4)
ldi ZH, high(item4)
ld temp2, Z
pop temp1
cpi temp2, 0
breq EmptyScreen
rjmp CoinScreen
check5:
ldi ZL, low(item5)
ldi ZH, high(item5)
ld temp2, Z
pop temp1
cpi temp2, 0
breq EmptyScreen
rjmp CoinScreen
check6:
ldi ZL, low(item6)
ldi ZH, high(item6)
ld temp2, Z
pop temp1
cpi temp2, 0
breq EmptyScreen
rjmp CoinScreen
check7:
ldi ZL, low(item7)
ldi ZH, high(item7)
ld temp2, Z
pop temp1
cpi temp2, 0
breq EmptyScreen
rjmp CoinScreen
check8:
ldi ZL, low(item8)
ldi ZH, high(item8)
ld temp2, Z
pop temp1
cpi temp2, 0
breq EmptyScreen
rjmp CoinScreen
check9:
ldi ZL, low(item9)
ldi ZH, high(item9)
ld temp2, Z
pop temp1
cpi temp2, 0
breq EmptyScreen
rjmp CoinScreen
EmptyScreen:
push temp1
do_lcd_command 0b00000001
do_lcd_data 'O'
do_lcd_data 'u'
do_lcd_data 't'
do_lcd_data ' '
do_lcd_data 'o'
do_lcd_data 'f'
do_lcd_data ' '
do_lcd_data 's'
do_lcd_data 't'
do_lcd_data 'o'
do_lcd_data 'c'
do_lcd_data 'k'
do_lcd_command 0b10101000
pop temp1
do_lcd_data_r temp1
ser temp1
out PORTC, temp1
ldi temp1, TopLED
ori temp1, SecondLED
out PORTG, temp1
rcall sleep_500ms
clr temp1
out PORTC, temp1
out PORTG, temp1
rcall sleep_500ms
ser temp1
out PORTC, temp1
ldi temp1, TopLED
ori temp1, SecondLED
out PORTG, temp1
rcall sleep_500ms
clr temp1
out PORTC, temp1
out PORTG, temp1
rcall sleep_500ms
ser temp1
out PORTC, temp1
ldi temp1, TopLED
ori temp1, SecondLED
out PORTG, temp1
rcall sleep_500ms
clr temp1
out PORTC, temp1
out PORTG, temp1
rcall sleep_500ms
rjmp displaySelectScreen2
displaySelectScreen2:
clr temp1
out PORTC, temp1
out PORTG, temp1
do_lcd_command 0b00000001 ; clear display
do_lcd_command 0b10000000 ;set cursor to addr 0 on LCD
do_lcd_data 'S'
do_lcd_data 'e'
do_lcd_data 'l'
do_lcd_data 'e'
do_lcd_data 'c'
do_lcd_data 't'
do_lcd_data ' '
do_lcd_data 'i'
do_lcd_data 't'
do_lcd_data 'e'
do_lcd_data 'm'
rcall sleep_500ms
rjmp KeypadLoop
CoinScreen:
push temp1
clr r18
sts TIMSK0, r18 ; turn off timer.
do_lcd_command 0b00000001 ; clear display
do_lcd_command 0b10000000 ;set cursor to addr 0 on LCD
do_lcd_data 'I'
do_lcd_data 'n'
do_lcd_data 's'
do_lcd_data 'e'
do_lcd_data 'r'
do_lcd_data 't'
do_lcd_data ' '
do_lcd_data 'c'
do_lcd_data 'o'
do_lcd_data 'i'
do_lcd_data 'n'
do_lcd_data 's'
do_lcd_data ' '
do_lcd_data '#'
;subi temp1, -'1'
pop temp1
mov temp2,temp1
push temp1
do_lcd_data_r temp2
do_lcd_command 0b10101000
rjmp InsertCoin
.macro HashLoop
ldi cmask, INITCOLMASK ; initial column mask
lsl cmask
lsl cmask //third column
sts PORTL, cmask ; Otherwise, scan a column.
ldi temp1, 0xFF ; Slow down the scan operation.
Hashdelay: dec temp1
brne Hashdelay //assuming this counts down to 0 from 255, otherwise, idk.
lds temp1, PINL ; Read PORTA
andi temp1, ROWMASK ; Get the keypad output value
cpi temp1, 0xF ; Check if any row is low???
breq @0 ; If yes, find which row is low
ldi rmask, INITROWMASK ; Initialize for row check
lsl rmask
lsl rmask
lsl rmask
mov temp2, temp1
and temp2, rmask
breq CoinReturn
rjmp @0
.endmacro
InsertCoin:
pop temp1
rcall ReturnInventory
ld temp2,Y
push temp1
clr temp4
clr temp3
out PORTC, temp3
do_lcd_command 0b10101000
mov temp1,temp2
subi temp1,-'0'
do_lcd_data_r temp1
FirstZeroLoop:
push temp1
push temp2
HashLoop Loop2c
Loop2c:
pop temp2
pop temp1
lds temp1, PINK
andi temp1, 0b00000001
cpi temp1, 0
brne FirstZeroLoop
rjmp SecondOneLoop
SecondOneLoop:
lds temp1, PINK
push temp1
push temp2
HashLoop Loopc
Loopc:
pop temp2
pop temp1
andi temp1, 0b00000001
cpi temp1, 1
brne SecondOneLoop
rjmp ThirdZeroLoop
CoinReturn:
cpi temp4,0
breq JumpDisplay
dec temp4