-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdriver2_i2c.hc11
830 lines (645 loc) · 32.9 KB
/
driver2_i2c.hc11
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
*******************************************************************************
* I2C Driver for the IMU
* November 2024
* This program uses PORTD pins 4 and 5 as SDA and SCL respectively
* DDRC 0 = INPUT, DDRC 1 = OUTPUT
*******************************************************************************
portd EQU $1008 ; port d data address
ddrd EQU $1009 ; data direction register d
send_buffer EQU $2002 ; location where we store the register address to send over
register EQU $2008 ; ITG-3200 Register Address Storage Locatoin
gyro_write EQU %11010000 ; itg3200 write addr
gyro_read EQU %11010001 ; itg3200 read addr
gyro_nack EQU %11110000 ; test address
gyro_whoami EQU %00000000 ; whoami register
bmp085 EQU %11101110 ; bmp085 address
; OR these to turn that bit off
sda EQU %00010000 ;
scl EQU %00100000
; AND these to turn that bit off
sdam EQU $EF ; inverted bitmask for SDA
sclm EQU $DF ; inverted bitmask for SCL
; testing if my method works at all
i2cstore EQU $2000 ; where I want to keep my i2c data
* HEX OUTPUT OF SENSOR LOCATION
temp_result EQU $2200 ; (2 bytes) spot for the temperature result
remainder EQU $2302 ; spot for the remainder
tmp EQU $2600 ; scratch space for math operations
conv_res EQU $2240 ; spot to store the conversion to human readable
store EQU $2990 ; place to store the bin2bcd
negflag EQU $2292 ; place to store if it is a twos compliment number
ORG $1400
legend FCC 'TEMP|GYRO_X|GYRO_Y|GYRO_Z' ; human readable string
FCB $04 ; end of string byte for the hc11
*******************************************************************************
* SEND BYTE SUBROUTINE
*******************************************************************************
ORG $2400
sb:
ldx #$08 ; send 8 bits
ldab send_buffer
send_byte_loop:
ldaa #scl ; put the clock low = set ddrd high
oraa ddrd
staa ddrd
rolb ; look at the msb
bcs set_sda ; branch depending on its value
bcc clear_sda
set_sda: ; ddrd LOW -> SDA HIGH
ldaa #sdam
anda ddrd
staa ddrd
bra next_bit
clear_sda: ; ddrd HIGH -> SDA LOW
ldaa #sda
oraa ddrd
staa ddrd
bra next_bit
next_bit:
ldaa #sclm ; clock needs to go high now, ddrd is LOW
anda ddrd
staa ddrd
dex
bne send_byte_loop
rts
*******************************************************************************
* READ BYTE SUBROUTINE
*******************************************************************************
rb:
ldx #$08
ldaa #sdam ; release the buss
anda ddrd
staa ddrd
rb_loop:
ldaa #scl ; bring the clock low
oraa ddrd
staa ddrd
ldaa #sclm ; bring it high again
anda ddrd
staa ddrd
jsr read_port ; i am putting it here, because data changes while the clock is low, but
dex ; it may need to be in the first rb: routine also
bne rb_loop ; this was "send_byte_loop", and wasn't working correclty
rts
*******************************************************************************
* START CONDITION
*******************************************************************************
start_condition:
ldaa #sclm ; if the clock line is low, make it high
anda ddrd
staa ddrd
* if SDA is LOW, make it high
ldaa #sdam
anda ddrd
staa ddrd
* then lower it
ldaa #sda
oraa ddrd
staa ddrd
rts
*******************************************************************************
* MAIN I2C READ LOOP *
*******************************************************************************
ORG $3000 ; entry point for i2c driver
* ldaa #$00 ; configure portd as an input
* staa ddrd ; store portd configuratoin
i2cmain:
ldaa #$00 ; initialize i2cstore to zero
staa i2cstore ; ^^
jsr start_condition ; send gyro write
ldaa #gyro_write ; send the gyro write command on the bus
staa send_buffer
jsr sb ; send byte
jsr ack_nack
ldaa register ; Register Address (RA)
staa send_buffer
jsr sb
jsr ack_nack ; ACK
jsr start_condition ; S
ldaa #gyro_read ; ADR + R
staa send_buffer
jsr sb
jsr ack_nack ; ACK
jsr rb ; DATA (for now just want to see data on the bus
jsr ack_nack
jsr stop_condition
rts
* swi
*******************************************************************************
* END I2C MAIN LOOP
*******************************************************************************
*******************************************************************************
* ENTRY POINT OF PROGRAM (DRIVER LOOP)
*******************************************************************************
ORG $3400
main_init:
ldaa #$00 ; iteration counter starts at 0
staa $0f ; place to put the iterations remaining
ldaa #$1B ; TEMP_HIGH register address
staa register ; where we store the register address
ldx #temp_result ; where we want to store the result in the end
stx $39fe
main_loop:
jsr i2cmain ; call the i2c driver
ldx $39fe ; load the address
ldaa i2cstore ; take the data from the temporary i2cstore
staa 0, x ; store the i2c store data in the temp_result locaiton + x
jsr $ffbb ; print the character
ldaa #$20
jsr $ffb8 ; print a space
inx ; increment x and store it for the next iteration
stx $39fe ; probably we can save a step here but i dont care right now
ldaa register ; load the register we are reading into A
inca ; increment it and store it for next iteration
staa register
ldaa $0f ; look at the number of iterations
inca ; add 1
staa $0f ; save the current iteration count
suba #$08 ; number of iterations to stop after
bne main_loop ; if we aren't at 0 keep going.
* jsr $ffc4 ; print a carriange return/linefeed
ldx #legend
jsr $ffc7
jsr $ffc4 ; print a carriange return/linefeed
*******************************************************************************
* Area where we print the conversions to the display
*******************************************************************************
jsr print_temp
jsr prgyro_x
jsr prgyro_y
jsr prgyro_z
*******************************************************************************
* FINISHED PRINTING THAT LINE
*******************************************************************************
jsr $ffc4 ; print a carriage return/linefeed
jsr $ffc4 ; print a carriage return/linefeed
bra main_init
swi
* dont you just wish there were functions?
* in reality this runs forever, but idk why
* be careful we don't touch B
* read operation for ack/nack
ack_nack:
ldaa #scl ; clock low once more, ddrd HIGH
oraa ddrd
staa ddrd
* sda has to be an input. Data is allowed to change only when the clock is low.
* so once the clock goes low that gives our main and secondaries the chance to do their work
ldaa #sdam
anda ddrd
staa ddrd
nop ; just give it some time
nop
* clock high = ddrd low
ldaa #sclm
anda ddrd
staa ddrd
* off by one errors
* clock low once more = ddrd high
ldaa #scl
oraa ddrd
staa ddrd
rts
* i actually need to read in the nack some how
* while the clock is high, address goes high
* putting SDA high = DDRD LOW
stop_condition:
* clock low once more = ddrd high (bus control transfers back to M)
ldaa #scl
oraa ddrd
staa ddrd
* you have to think in terms of what is allowed to happen on the bus
* set SDA HIGH by setting its ddrd bit LOW
ldaa #sda
oraa ddrd
staa ddrd
ldaa #sclm ; clock high = ddrd low
anda ddrd
staa ddrd
nop ; here for superstitious reasons
nop
nop
ldaa #sdam ; set sda to input/high = clear SDA in DDRD
anda ddrd
staa ddrd
rts
swi
*;read port is known to work in a small test
read_port:
ldaa portd
ldy #$05
shift_left: ; shift the data into C
lsra
dey ; decrement x
bne shift_left
ldaa i2cstore
rola
staa i2cstore
rts
*******************************************************************************
* GYRO CONVERSIONS (X,Y,Z) FROM ITG-3200 DATASHEET
* Converts raw 2s compliment hex to a form which can be bin2bcd'ed for
* printing to the screen
* There is a lot of repeat code here, because I'm focused on finishing the project
* Let's see if I grow to regret that in the future.
********************************************************************************
ORG $3500
gyro_x_convert:
ldaa #00 ; set the negflag to zero to start
staa negflag ; (this way it has a known value)
ldaa temp_result+4 ; load D with the gyro_x_result
ldab temp_result+6 ; not sure why this is offset it happening
rola ; check if the number is negative
bcs gx_is_neg ; check the msb for a 1
bcc gx_is_pos ; branch to positive if the msb is a 0, negative if a 1
gx_is_neg:
rora ; get our initial bit back
std tmp ; put the number we are working with away really quick
ldaa #01 ; put a 1 in the LSB of negflag
staa negflag ; to let us know it is negative.
ldd tmp
eora #$ff
eorb #$ff
addd #1
ldx #14 ; load decimal 14 into the denominator
idiv ; divide the gyro x by 14
std remainder ; store the remainder
xgdx ; the quotient gets put into X this part works this part works
* subd #1 ; convert back to twos compliment for addition part
* eora #$ff ; i'm just going backwards on the steps i did earlier
* eorb #$ff ; A and B registers together form the D register
std tmp ; temporarily store d in the temporary scratch space
* ldd #20 ; subtract the linear constant
subd #20 ; 20 + tmp
bmi errorx ; error x we have to flip the subtraction
bpl scx
errorx:
ldd #0020
subd tmp
scx:
std conv_res ; store at $2240
bra decimx
gx_is_pos:
rora
ldx #14 ; load decimal 14 into the denominator
idiv ; divide the gyro x by 14
std remainder ; store the remainder
xgdx ; the quotient gets put into X this part works this part works
std tmp ; temporarily store d in the temporary scratch space
ldd #20 ; subtract the linear constant
addd tmp ; 20 + tmp
std conv_res ; store at $2240
bra decimx
* swi ; sometimes SWI'ing here is nice for debugging
decimx:
ldd remainder ; load the remainder from before
ldx #20 ; load decimal 20 into the denominator
fdiv ; floating point divide
xgdx ; the quotient gets put into X
std tmp+2 ; temporary spot for the "decimalized" remainder
ldd #14
subd tmp+2
std conv_res+2 ; store the decimal part
ldd conv_res
std $2260
rts
* Gyro Y
gyro_y_convert:
ldaa #00 ; set the negflag to zero to start
staa negflag ; (this way it has a known value)
ldaa temp_result+8 ; load D with the gyro_x_result
ldab temp_result+10 ; not sure why this is offset it happening
rola ; check if the number is negative
bcs gy_is_neg ; check the msb for a 1
bcc gy_is_pos ; branch to positive if the msb is a 0, negative if a 1
gy_is_neg:
rora ; get our initial bit back
std tmp
ldaa #01
staa negflag
ldd tmp
eora #$ff
eorb #$ff
addd #1
ldx #14 ; load decimal 14 into the denominator
idiv ; divide the gyro x by 14
std remainder ; store the remainder
xgdx ; the quotient gets put into X this part works this part works
* subd #1 ; convert back to twos compliment for addition part
* eora #$ff ; i'm just going backwards on the steps i did earlier
* eorb #$ff ; A and B registers together form the D register
std tmp ; temporarily store d in the temporary scratch space
* ldd #20 ; subtract the linear constant
subd #20 ; tmp - 20
bmi errory ; error y (we have to flip the subtraction
bpl scy
errory:
ldd #0020 ; 20 - tmp, since the original calculation led to a negative value
subd tmp
scy:
std conv_res ; store at $2240
bra decimy
gy_is_pos:
rora
ldx #14 ; load decimal 14 into the denominator
idiv ; divide the gyro x by 14
std remainder ; store the remainder
xgdx ; the quotient gets put into X this part works this part works
std tmp ; temporarily store d in the temporary scratch space
ldd #20 ; subtract the linear constant
addd tmp ; 20 + tmp
std conv_res ; store at $2240
bra decimy
* swi ; sometimes SWI'ing here is nice for debugging
decimy:
ldd remainder ; load the remainder from before
ldx #20 ; load decimal 20 into the denominator
fdiv ; floating point divide
xgdx ; the quotient gets put into X
std tmp+2 ; temporary spot for the "decimalized" remainder
ldd #14
subd tmp+2
std conv_res+2 ; store the decimal part
ldd conv_res
std $2260
rts
* Gyro Z
gyro_z_convert:
ldaa #00 ; set the negflag to zero to start
staa negflag ; (this way it has a known value)
ldaa temp_result+12 ; load D with the gyro_x_result
ldab temp_result+14 ; not sure why this is offset it happening
rola ; check if the number is negative
bcs gy_is_neg ; check the msb for a 1
bcc gy_is_pos ; branch to positive if the msb is a 0, negative if a 1
gz_is_neg:
rora ; get our initial bit back
std tmp ; put the number we are working with a way rq
ldaa #01 ; it is negative, so remember that
staa negflag ; (put a 1 there to remind us)
ldd tmp ; get the original value we were working with back
eora #$ff
eorb #$ff
addd #1
ldx #14 ; load decimal 14 into the denominator
idiv ; divide the gyro x by 14
std remainder ; store the remainder
xgdx ; the quotient gets put into X this part works this part works
* subd #1 ; convert back to twos compliment for addition part
* eora #$ff ; i'm just going backwards on the steps i did earlier
* eorb #$ff ; A and B registers together form the D register
std tmp ; temporarily store d in the temporary scratch space
* ldd #20 ; subtract the linear constant
subd #20 ; tmp - 20
bmi errorz ; error z (have to flip the subtraction)
bpl scz ; store conversion Z
errorz:
ldd #0020 ; 20 - tmp
subd tmp
scz:
std conv_res ; store at $2240
bra decimz
gz_is_pos:
rora
ldx #14 ; load decimal 14 into the denominator
idiv ; divide the gyro x by 14
std remainder ; store the remainder
xgdx ; the quotient gets put into X this part works this part works
std tmp ; temporarily store d in the temporary scratch space
ldd #20 ; subtract the linear constant
addd tmp ; 20 + tmp
std conv_res ; store at $2240
bra decimz
* swi ; sometimes SWI'ing here is nice for debugging
decimz:
ldd remainder ; load the remainder from before
ldx #20 ; load decimal 20 into the denominator
fdiv ; floating point divide
xgdx ; the quotient gets put into X
std tmp+2 ; temporary spot for the "decimalized" remainder
ldd #14
subd tmp+2
std conv_res+2 ; store the decimal part
ldd conv_res
std $2260
rts
*******************************************************************************
* TEMPERATURE CONVERSION FROM ITG-3200 DATASHEET
* Converts raw 2s compliment hexadecimal to a form which can be
* Bin2BCD'ed for printing to the screen.
* temp_high and temp_low have to be consequetive bytes
* There is probably some storage on X that needs to be done in order
* to use this in a loop.
* Converts the temperature stores in temp_result to a value that can be
* BIN2BCD'ed at $2260
* TODO: Implement the positive decimal case
*******************************************************************************
* ORG $3500 ; commenting out for now to impelment gyro code
temp_convert:
ldaa temp_result ; load D with the temperature (usually $2010)
ldab temp_result+2 ; dont you hate when you wake up and your code is arranging the data every other byte now, and you cant figure out why
eora #$ff ; it is a twos compliment negative number
eorb #$ff ; swap the upper and lower bytes (no EORD instr.)
addd #$01 ; increment by one to complete conversion
ldx #280 ; load decimal 280 into the denominator
idiv ; divide the temperature by 280
std remainder ; store the remainder
xgdx ; the quotient gets put into X this part works this part works
std tmp ; temporarily store d in the temporary scratch space
ldd #82 ; subtract the linear constant
subd tmp ; 82 - tmp
std conv_res ; store at $2240
* swi ; sometimes SWI'ing here is nice for debugging
ldd remainder ; load the remainder from before
ldx #280 ; load decimal 280 into the denominator
fdiv ; floating point divide
xgdx ; the quotient gets put into X
std tmp+2 ; temporary spot for the "decimalized" remainder
ldd #14
subd tmp+2
std conv_res+2 ; store the decimal part
rola
bcs if_neg
bcc if_pos
* there is no way this works on the first try
* if the small part is negative... subtract it...
* if the small part is positive... add it..
* how hard could it be?!?!?!?
* this probably only works on the version we have in memory at this moment (subtraction case)
* there are also probably a bunch of different edge cases
* for sure this one only works if the thing is negative, if it works at all
if_neg:
rora ; we checked the MSB, now get it back from the carry flag
ldab conv_res+2 ; we can only fit the top byte of the decimal, without having a dedicated place in memory
ldaa #0 ; even so, since we are using D, we have to form the byte correctly
eora #$ff ; flip every bit
adda #1 ; add 1 to convert the decimal part to its positive magnitude
ldx #10 ; get ready to divide by 10
idiv ; divide by 10 to get the place value correct
xgdx ; QUOTIENT IS IN X, so put it in D
std tmp ; we're kinda committing to using D here
ldaa conv_res+1 ; only A should be full after the division operation for the expected range of temperatures
ldab #100 ; multiply this by 100
mul ; execute multiplication
subd tmp ; subtract the quotient from earlier
std $2260 ; :prayge:
bra math_done
if_pos:
rora ; we checked the MSB, now get it back from the carry flag
ldab conv_res+2 ; we can only fit the top byte of the decimal, without having a dedicated place in memory
ldaa #0 ; even so, since we are using D, we have to form the byte correctly
eora #$ff ; flip every bit
adda #1 ; add 1 to convert the decimal part to its positive magnitude
ldx #10 ; get ready to divide by 10
idiv ; divide by 10 to get the place value correct
xgdx ; QUOTIENT IS IN X, so put it in D
std tmp ; we're kinda committing to using D here
ldaa conv_res+1 ; only A should be full after the division operation for the expected range of temperatures
ldab #100 ; multiply this by 100
mul ; execute multiplication
addd tmp ; add the quotient from earlier (we are in the positive case)
std $2260 ; :prayge:
bra math_done
math_done:
rts
*******************************************************************************
* BIN2BCD
*******************************************************************************
ORG $3700
bin2bcd:
ldd $2260 ; load the thing we want to convert to bcd
ldx #10000 ; load 10k
idiv ; divide and get quot -> x rem -> d
xgdx ; put quot -> d
stab store ; store d at the first major digit
xgdx ; quot -> x, rem -> d
ldx #1000 ; load 1k
idiv ; divide at get quot - > x, rem -> d
xgdx ; put the quot -> d
stab store+1 ; store d at the second major digit
xgdx ; take it back now yall, quot -> x rem -> d
ldx #100 ; load 100
idiv ; divide to qet quot -> x, rem -> d
xgdx ; quot -> d
stab store+2 ; store d at the third major digit
xgdx ; quot -> x, rem -> d
ldx #10 ; load 10
idiv ; divide to get quot -> x , rem -> d
xgdx ; quot-> d, rem->x
stab store+3 ; store quot at the third major digit
xgdx ; store remainder at the fourth major digit
stab store+4
rts
*******************************************************************************
* PRINT TEMPERATURE CONVERSION
*******************************************************************************
print_temp:
jsr temp_convert
jsr bin2bcd
ldaa $2991 ; output first temperature digit
jsr $ffb5 ; right nibble and out
ldaa $2992 ; output second numerator digit
jsr $ffb5
ldaa #$2e ; output decimal point
jsr $ffb8
ldaa $2993 ; output third temperature digit
jsr $ffb5 ; right nibble convert and print out
ldaa $2994 ; output fourth temperature digit
jsr $ffb5 ; right nibble convert and print out
ldaa #$7c ; output vertical bar
jsr $ffb8 ; output character utility subroutine
rts
*******************************************************************************
* PRINT GYRO X CONVERSION
*******************************************************************************
prgyro_x:
jsr gyro_x_convert
jsr bin2bcd
ldaa negflag ; check if the value is negative
cmpa #01 ; if it is
beq print_min
bne print_plus
print_min:
ldaa #$2d ; ascii for - sign
jsr $ffb8 ; output character utility subroutine
bra digitsx ; go to print the rest of the digits
print_plus
ldaa #$2b ; ascii for + sign
jsr $ffb8 ; output character utility subroutine
bra digitsx ; go to print the rest of the digits
digitsx:
ldaa $2990 ; output first temperature digit
jsr $ffb5 ; right nibble and out
ldaa $2991 ; output first temperature digit
jsr $ffb5 ; right nibble and out
ldaa $2992 ; output second numerator digit
jsr $ffb5
ldaa $2993 ; output third temperature digit
jsr $ffb5 ; right nibble convert and print out
ldaa $2994 ; output fourth temperature digit
jsr $ffb5 ; right nibble convert and print out
ldaa #$7c ; output vertical bar
jsr $ffb8 ; output character utility subroutine
rts
*******************************************************************************
* PRINT GYRO Y CONVERSION
*******************************************************************************
prgyro_y:
jsr gyro_y_convert
jsr bin2bcd
ldaa negflag ; check if the value is negative
cmpa #01 ; if it is
beq min_y
bne plus_y
min_y:
ldaa #$2d ; ascii for - sign
jsr $ffb8 ; output character utility subroutine
bra digitsy ; go to print the rest of the digits
plus_y:
ldaa #$2b ; ascii for + sign
jsr $ffb8 ; output character utility subroutine
bra digitsy ; go to print the rest of the digits
digitsy:
ldaa $2990 ; output first temperature digit
jsr $ffb5 ; right nibble and out
ldaa $2991 ; output first temperature digit
jsr $ffb5 ; right nibble and out
ldaa $2992 ; output second numerator digit
jsr $ffb5
ldaa $2993 ; output third temperature digit
jsr $ffb5 ; right nibble convert and print out
ldaa $2994 ; output fourth temperature digit
jsr $ffb5 ; right nibble convert and print out
ldaa #$7c ; output vertical bar
jsr $ffb8 ; output character utility subroutine
rts
*******************************************************************************
* PRINT GYRO Z CONVERSION
*******************************************************************************
prgyro_z:
jsr gyro_z_convert
jsr bin2bcd
ldaa negflag ; check if value is negative
cmpa #01 ; branch if it is
beq min_z
bne plus_z
min_z:
ldaa #$2d ; ascii for - sign
jsr $ffb8 ; output character utility subroutine
bra digitsz ; go to print the rest of the digits
plus_z:
ldaa #$2b ; ascii for + sign
jsr $ffb8 ; output character utility subroutine
bra digitsz ; go to print the rest of the digits
digitsz:
ldaa $2990 ; output first temperature digit
jsr $ffb5 ; right nibble and out
ldaa $2991 ; output first temperature digit
jsr $ffb5 ; right nibble and out
ldaa $2992 ; output second numerator digit
jsr $ffb5
ldaa $2993 ; output third temperature digit
jsr $ffb5 ; right nibble convert and print out
ldaa $2994 ; output fourth temperature digit
jsr $ffb5 ; right nibble convert and print out
rts