-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlibrary.lst
1025 lines (883 loc) · 41.4 KB
/
library.lst
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
ARM Macro Assembler Page 1
1 00000000 AREA LIBRARY, CODE, READWRITE
2 00000000
3 00000000
4 00000000 EXPORT uart_init
5 00000000 EXPORT pin_connect_block_setup_for_uar
t0
6 00000000 EXPORT read_character
7 00000000 EXPORT output_character
8 00000000 EXPORT read_string
9 00000000 EXPORT output_string
10 00000000 EXPORT display_digit_on_7_seg
11 00000000 EXPORT read_from_push_btns
12 00000000 EXPORT illuminateLEDs
13 00000000 EXPORT illuminate_RGB_LED
14 00000000 EXPORT div_and_mod
15 00000000
16 00000000
17 00000000 ; Constants
18 00000000 00000014
U0LSR EQU 0x14 ; UART0 Line Status
Register
19 00000000 E002C000
PINSEL0 EQU 0xE002C000 ;pin select 0
20 00000000 E000C000
UART0 EQU 0xE000C000 ;Base address of UA
RT0
21 00000000 E0028000
IOBASE EQU 0xE0028000
22 00000000 0000000C
IO0CLR EQU 0xC
23 00000000 0000001C
IO1CLR EQU 0x1C
24 00000000 00000004
IO0SET EQU 0x4
25 00000000 00000014
IO1SET EQU 0x14
26 00000000 00000010
IO1PIN EQU 0x10
27 00000000 00000008
IO0DIR EQU 0x8 ; GPIO Direction Re
gister Port 0 Addre
ss
28 00000000 00000018
IO1DIR EQU 0x18 ; GPIO Direction Re
gister Port 1 Addre
ss
29 00000000
30 00000000 ALIGN
31 00000000 digits_SET
32 00000000 00001F80 DCD 0x00001F80 ; 0
33 00000004 00000300 DCD 0x00000300 ; 1
34 00000008 00002D80 DCD 0x00002D80 ; 2
35 0000000C 00002780 DCD 0x00002780 ; 3
36 00000010 00003300 DCD 0x00003300 ; 4
37 00000014 00003680 DCD 0x00003680 ; 5
38 00000018 00003E80 DCD 0x00003E80 ; 6
39 0000001C 00000380 DCD 0x00000380 ; 7
40 00000020 00003F80 DCD 0x00003F80 ; 8
41 00000024 00003780 DCD 0x00003780 ; 9
ARM Macro Assembler Page 2
42 00000028 00003B80 DCD 0x00003B80 ; 10 (A)
43 0000002C 00003E00 DCD 0x00003E00 ; 11 (b)
44 00000030 00001C80 DCD 0x00001C80 ; 12 (C)
45 00000034 00002F00 DCD 0x00002F00 ; 13 (d)
46 00000038 00003C80 DCD 0x00003C80 ; 14 (E)
47 0000003C 00003880 DCD 0x00003880 ; 15 (F)
48 00000040 00000000 DCD 0x00000000 ; 16 (clear)
49 00000044 00002000 DCD 0x00002000 ; 17 (-)
50 00000048 ALIGN
51 00000048
52 00000048 uart_init
53 00000048 ;rewrite C code serial_init 3 lines loading addresses an
d numbers
54 00000048 E92D4003 STMFD sp!, {r0, r1, lr}
55 0000004C ; 8-bit word length, 1 stop bit, no parity
56 0000004C ; Disable break control
57 0000004C ; Enable divisor latch access
58 0000004C E59F036C LDR r0, =0xE000C000
59 00000050 E3A01083 MOV r1, #131
60 00000054 E580100C STR r1, [r0, #0xC]
61 00000058
62 00000058 ; Set lower divisor latch for 14,400 baud
63 00000058 E3A01050 MOV r1, #80
64 0000005C E5801000 STR r1, [r0]
65 00000060
66 00000060 ; Set upper divisor latch for 9,600 baud
67 00000060 E3A01000 MOV r1, #0
68 00000064 E5801004 STR r1, [r0, #4]
69 00000068
70 00000068 ; 8-bit word length, 1 stop bit, no parity,
71 00000068 ; Disable break control
72 00000068 ; Disable divisor latch access
73 00000068 E3A01003 MOV r1, #3
74 0000006C E580100C STR r1, [r0, #0xC]
75 00000070
76 00000070 E8BD4003 LDMFD sp!, {r0, r1, lr}
77 00000074 E12FFF1E BX lr
78 00000078
79 00000078 pin_connect_block_setup_for_uart0
80 00000078 E92D4003 STMFD sp!, {r0, r1, lr}
81 0000007C E59F0340 LDR r0, =0xE002C000 ; PINSEL0
82 00000080 E5901000 LDR r1, [r0]
83 00000084 E3811005 ORR r1, r1, #5
84 00000088 E3C1100A BIC r1, r1, #0xA
85 0000008C E5801000 STR r1, [r0]
86 00000090 E8BD4003 LDMFD sp!, {r0, r1, lr}
87 00000094 E12FFF1E BX lr
88 00000098
89 00000098
90 00000098 ; Takes NONE
91 00000098 ; Returns NONE
92 00000098 read_character
93 00000098 E92D4000 STMFD SP!,{lr} ; Store register lr
on stack
94 0000009C E59F031C LDR r0, =0xE000C000
; Load base address
95 000000A0 read_char_loop
96 000000A0 E5D01014 LDRB r1, [r0, #U0LSR] ; Add offset
ARM Macro Assembler Page 3
97 000000A4 E2011001 AND r1, #0x01 ; Set all bytes to
zero except RDR
98 000000A8 E3510001 CMP r1, #0x01 ; Compare RDR to 1
99 000000AC 1AFFFFFB BNE read_char_loop ; Go back to sta
rt if 0
100 000000B0 E5902000 LDR r2, [r0] ; Read byte from re
cieve reg
101 000000B4 E8BD4000 LDMFD sp!, {lr}
102 000000B8 E12FFF1E BX lr
103 000000BC
104 000000BC
105 000000BC ; Takes NONE
106 000000BC ; Returns NONE
107 000000BC output_character
108 000000BC E92D4003 STMFD SP!,{lr, r0, r1} ; Store regist
ers r0, r1, r2 on s
tack
109 000000C0 E59F02F8 LDR r0, =0xE000C000
; Load base address
110 000000C4 output_char_loop
111 000000C4 E5D01014 LDRB r1, [r0, #U0LSR] ; Add offset
112 000000C8 E2011020 AND r1, #0x20 ; Set all bytes to
zero except THRE
113 000000CC E3510020 CMP r1, #0x20 ; Compare THRE to 1
114 000000D0 1AFFFFFB BNE output_char_loop ; Go back to s
tart if 0
115 000000D4 E5C02000 STRB r2, [r0] ; Store byte in tra
nsmit register
116 000000D8 E8BD4003 LDMFD sp!, {lr, r0, r1}
117 000000DC E12FFF1E BX lr
118 000000E0
119 000000E0
120 000000E0 ; Takes NONE
121 000000E0 ; Returns r4=input number from -9999 to 9999
122 000000E0 read_string
123 000000E0 ;reads a string and stores it as a null-terminated strin
g in memory.
124 000000E0 ;User terminates the string by hitting Enter.
125 000000E0 ;Base address of the string should be passed into the ro
utine in r4.
126 000000E0 E92D4004 STMFD SP!, {lr, r2}
127 000000E4 E3A06000 MOV r6, #0 ; Initialize sign f
lag
128 000000E8 E3A0500A MOV r5, #0xA ; r5 will multiply
by 10
129 000000EC E3A04000 MOV r4, #0
130 000000F0 read_string_loop
131 000000F0 EBFFFFFE BL read_character ; Read the first
input
132 000000F4 E352000D CMP r2, #0x0D ; Check if enter wa
s pushed
133 000000F8 0A000009 BEQ check_sign ; If enter was push
ed stop read_string
134 000000FC E352002D CMP r2, #0x2D
135 00000100 1A000002 BNE not_negative ; Check if "-"
136 00000104 E3A06001 MOV r6, #1
ARM Macro Assembler Page 4
137 00000108 EBFFFFFE BL output_character
138 0000010C EAFFFFF7 B read_string_loop
139 00000110 not_negative
140 00000110 EBFFFFFE BL output_character ; Output the i
nput to the termina
l
141 00000114 E2422030 SUB r2, r2, #0x30 ; Convert from AS
CII to dec
142 00000118 E0040495 MUL r4, r5, r4 ; Move the previous
input to the next
tens spot
143 0000011C E0844002 ADD r4, r4, r2 ; Add the new input
to the ones spot
144 00000120 EAFFFFF2 B read_string_loop ; Check for ne
xt input
145 00000124 check_sign
146 00000124 E3560000 CMP r6, #0 ; If flag is not se
t, end the loop
147 00000128 0A000001 BEQ end_read_str
148 0000012C
149 0000012C E1E04004 MVN r4, r4 ; If flag is set, T
wo's complement
150 00000130 E2844001 ADD r4, r4, #1
151 00000134 end_read_str
152 00000134 E8BD4004 LDMFD SP!, {lr, r2}
153 00000138 E12FFF1E BX lr
154 0000013C ;range -9999 ~ +9999
155 0000013C ;repeat read_character until ENTER(0x0D) key is entered.
156 0000013C
157 0000013C ;if past range, disp error (change string and send to ou
tput string)
158 0000013C ;Push it to a memory location
159 0000013C ;return base address of the string into the routine in r
4
160 0000013C
161 0000013C ; Takes NONE
162 0000013C ; Returns NONE
163 0000013C output_string
164 0000013C E92D400C STMFD SP!,{lr, r2, r3} ; Store regist
ers lr, r2, r3 on s
tack
165 00000140 output_str_loop
166 00000140 E4D32001 LDRB r2, [r3], #1 ; Load first byte
of prompt and post
increment one byte
167 00000144 E3520000 CMP r2, #0 ; Check if null cha
racter
168 00000148 1BFFFFFE BLNE output_character
; Output character
169 0000014C E3520000 CMP r2, #0 ; Check if null cha
racter
170 00000150 1AFFFFFA BNE output_str_loop ; check next ch
aracter
171 00000154 E8BD400C LDMFD sp!, {lr, r2, r3}
172 00000158 E12FFF1E BX lr
173 0000015C
174 0000015C
ARM Macro Assembler Page 5
175 0000015C
176 0000015C display_digit_on_7_seg
177 0000015C E59F0264 LDR r0, =IOBASE ; Load base address
178 00000160 E5901008 LDR r1, [r0, #IO0DIR] ; Load Port 0
GPIO Direction Reg
ister
179 00000164 E3811DFE ORR r1, r1, #0x3F80 ; Set Port 0 P
in 7~13 as output
180 00000168 E5801008 STR r1, [r0, #IO0DIR] ;
181 0000016C E92D400A STMFD SP!, {r1, r3, lr }
182 00000170 E59F1250 LDR r1, =0xE0028000
183 00000174 E59F3250 LDR r3, =digits_SET
184 00000178 E1A04104 MOV r4, r4, LSL #2
185 0000017C E7932004 LDR r2, [r3, r4]
186 00000180 E5812000 STR r2, [r1]
187 00000184 E8BD400A LDMFD SP!, {r1, r3, lr }
188 00000188 E12FFF1E BX lr
189 0000018C
190 0000018C read_from_push_btns
191 0000018C E92D4006 STMFD SP!, {r1, r2, lr}
192 00000190
193 00000190 E59F1238 LDR r1, =0XE0028010 ; load I01PIN a
ddress
194 00000194 E5910000 LDR r0, [r1] ; load IO1PIN addre
ss on r0
195 00000198 E200060F AND r0, r0, #0xF00000 ; Look only p
ins 20-23
196 0000019C
197 0000019C E1A00A20 MOV r0, r0, LSR #20 ; Shift to most
-right for byte
198 000001A0 E220000F EOR r0, r0, #0xF ; Invert the last
byte data
199 000001A4
200 000001A4 EBFFFFFE BL illuminateLEDs ; Light up LEDs
201 000001A8 E8BD4006 LDMFD SP!, {r1, r2, lr}
202 000001AC E12FFF1E BX lr
203 000001B0
204 000001B0 ; takes in r4,
205 000001B0 ;r4=0x0 turn 4 leds on
206 000001B0 ;r4=0x10000 turn 3 leds on
207 000001B0 ;r4=0x30000 turn 2 leds on
208 000001B0 ;r4=0x70000 turn 1 leds on
209 000001B0 ;r4=0xF0000 turn 0 leds on
210 000001B0 illuminateLEDs
211 000001B0 E92D4006 STMFD SP!, {r1, r2, lr}
212 000001B4 E59F620C LDR r6, =IOBASE ; Load base address
213 000001B8 E5961018 LDR r1, [r6, #IO1DIR] ; Load Port 1
GPIO Direction Reg
ister
214 000001BC E381180F ORR r1, r1, #0xF0000 ; Set Port 1.
Pin 16~19 as output
215 000001C0 E5861018 STR r1, [r6, #IO1DIR]
216 000001C4
217 000001C4 E59F11FC LDR r1, =IOBASE ; load base address
218 000001C8
ARM Macro Assembler Page 6
219 000001C8 E3A0280F MOV r2, #0xF0000 ; SET LED - pins 2
0-23 in IO1CLR this
turns them
220 000001CC E581201C STR r2, [r1, #IO1CLR] ; all off by
storing 0xF0000 on
IO1CLR address
221 000001D0
222 000001D0 ; Clear the LEDs wanted on by putting a zero in IO1SET
223 000001D0 E5814014 STR r4, [r1, #IO1SET]
; IO1SET EQU 0x14
224 000001D4
225 000001D4 E8BD4006 LDMFD SP!, {r1, r2, lr}
226 000001D8 E12FFF1E BX lr
227 000001DC
228 000001DC ; red is port 17, blue is 18, and green is 21
229 000001DC illuminate_RGB_LED
230 000001DC E92D4005 STMFD SP!, {lr, r0, r2 }
231 000001E0 E59F01EC LDR r0, =0xE002C004
; PINSEL1 address
232 000001E4 E5901000 LDR r1, [r0]
233 000001E8 E59F21E8 LDR r2, = 0xC30C
234 000001EC E1C11002 BIC r1, r1, r2 ; Clear bits 5:2, 1
1:10 This sets
235 000001F0 ; P0.17, P0.18 and P0.21 as pin
236 000001F0 ; connect blocks to use.
237 000001F0 E5801000 STR r1, [r0]
238 000001F4
239 000001F4 E59F01E0 LDR r0, =0xE0028008 ; PORT0 IODIR a
ddress
240 000001F8 E5901000 LDR r1, [r0]
241 000001FC E3811826 ORR r1, r1, #0x260000 ; set bits 17
, 18, 21 to 1 for o
utput
242 00000200 E5801000 STR r1, [r0]
243 00000204
244 00000204 E3540000 CMP r4, #0
245 00000208 0A00000B BEQ set_red
246 0000020C E3540001 CMP r4, #1
247 00000210 0A000013 BEQ set_green
248 00000214 E3540002 CMP r4, #2
249 00000218 0A00001B BEQ set_blue
250 0000021C E3540003 CMP r4, #3
251 00000220 0A000023 BEQ set_purple
252 00000224 E3540004 CMP r4, #4
253 00000228 0A00002B BEQ set_yellow
254 0000022C E3540005 CMP r4, #5
255 00000230 0A000033 BEQ set_white
256 00000234 E3540006 CMP r4, #6
257 00000238 0A000037 BEQ set_off
258 0000023C set_red
259 0000023C E59F019C LDR r0, =0xE0028004 ; PORT0 IOSET a
ddress
260 00000240 E5901000 LDR r1, [r0]
261 00000244 E3811709 ORR r1, r1, #0x240000 ; set pin 18
and 21, green=off,
blue=off
262 00000248 E5801000 STR r1, [r0]
263 0000024C
264 0000024C E59F0190 LDR r0, =0xE002800C ; PORT0 IOCLR a
ARM Macro Assembler Page 7
ddress
265 00000250 E5901000 LDR r1, [r0]
266 00000254 E3811802 ORR r1, r1, #0x20000 ; set pin 17,
red=on
267 00000258 E5801000 STR r1, [r0]
268 0000025C E8BD4005 LDMFD SP!, {lr, r0, r2 }
269 00000260 E12FFF1E BX lr
270 00000264 set_green
271 00000264 E59F0174 LDR r0, =0xE0028004 ; PORT0 IOSET a
ddress
272 00000268 E5901000 LDR r1, [r0]
273 0000026C E3811806 ORR r1, r1, #0x60000 ; set pin 17 a
nd 18, red=off, blu
e=off
274 00000270 E5801000 STR r1, [r0]
275 00000274
276 00000274 E59F0168 LDR r0, =0xE002800C ; PORT0 IOCLR a
ddress
277 00000278 E5901000 LDR r1, [r0]
278 0000027C E3811602 ORR r1, r1, #0x200000 ; set pin 21,
green=on
279 00000280 E5801000 STR r1, [r0]
280 00000284 E8BD4005 LDMFD SP!, {lr, r0, r2 }
281 00000288 E12FFF1E BX lr
282 0000028C set_blue
283 0000028C E59F014C LDR r0, =0xE0028004 ; PORT0 IOSET a
ddress
284 00000290 E5901000 LDR r1, [r0]
285 00000294 E3811822 ORR r1, r1, #0x220000 ; set pin 17
and 21, red=off, gr
een=off
286 00000298 E5801000 STR r1, [r0]
287 0000029C
288 0000029C E59F0140 LDR r0, =0xE002800C ; PORT0 IOCLR a
ddress
289 000002A0 E5901000 LDR r1, [r0]
290 000002A4 E3811701 ORR r1, r1, #0x40000 ; set pin 18,
blue=on
291 000002A8 E5801000 STR r1, [r0]
292 000002AC E8BD4005 LDMFD SP!, {lr, r0, r2 }
293 000002B0 E12FFF1E BX lr
294 000002B4 set_purple
295 000002B4 E59F0124 LDR r0, =0xE0028004 ; PORT0 IOSET a
ddress
296 000002B8 E5901000 LDR r1, [r0]
297 000002BC E3811602 ORR r1, r1, #0x200000 ; set pin 18,
green=off
298 000002C0 E5801000 STR r1, [r0]
299 000002C4
300 000002C4 E59F0118 LDR r0, =0xE002800C ; PORT0 IOCLR a
ddress
301 000002C8 E5901000 LDR r1, [r0]
302 000002CC E3811806 ORR r1, r1, #0x60000 ; set pin 17 a
nd 18, red=on blue=
on
303 000002D0 E5801000 STR r1, [r0]
304 000002D4 E8BD4005 LDMFD SP!, {lr, r0, r2 }
305 000002D8 E12FFF1E BX lr
306 000002DC set_yellow
ARM Macro Assembler Page 8
307 000002DC E59F00FC LDR r0, =0xE0028004 ; PORT0 IOSET a
ddress
308 000002E0 E5901000 LDR r1, [r0]
309 000002E4 E3811701 ORR r1, r1, #0x40000 ; set pin 18,
blue=off
310 000002E8 E5801000 STR r1, [r0]
311 000002EC
312 000002EC E59F00F0 LDR r0, =0xE002800C ; PORT0 IOCLR a
ddress
313 000002F0 E5901000 LDR r1, [r0]
314 000002F4 E3811822 ORR r1, r1, #0x220000 ; set pin 17
and 21, red=on gree
n=on
315 000002F8 E5801000 STR r1, [r0]
316 000002FC E8BD4005 LDMFD SP!, {lr, r0, r2 }
317 00000300 E12FFF1E BX lr
318 00000304 set_white
319 00000304 E59F00D8 LDR r0, =0xE002800C ; PORT0 IOCLR a
ddress
320 00000308 E5901000 LDR r1, [r0]
321 0000030C E3811826 ORR r1, r1, #0x260000 ; set pin 17,
18, and 21 red=on
green=on blue=on
322 00000310 E5801000 STR r1, [r0]
323 00000314 E8BD4005 LDMFD SP!, {lr, r0, r2 }
324 00000318 E12FFF1E BX lr
325 0000031C set_off
326 0000031C E59F00BC LDR r0, =0xE0028004 ; PORT0 IOSET a
ddress
327 00000320 E5901000 LDR r1, [r0]
328 00000324 E3811826 ORR r1, r1, #0x260000 ; set pin 17,
18, 21 red=off, bl
ue=off and green=of
f
329 00000328 E5801000 STR r1, [r0]
330 0000032C E8BD4005 LDMFD SP!, {lr, r0, r2 }
331 00000330 E12FFF1E BX lr
332 00000334
333 00000334
334 00000334 ; Takes r0=dividend, r1=divisor
335 00000334 ; Returns r0=quotient, r1=remainder
336 00000334 div_and_mod
337 00000334 E92D5FFC STMFD r13!, {r2-r12, r14}
338 00000338
339 00000338 ; Your code for the signed division/mod routine goes her
e.
340 00000338 ; The dividend is passed in r0 and the divisor in r1.
341 00000338 ; The quotient is returned in r0 and the remainder in r1
.
342 00000338 E3A02011 MOV r2, #17 ; Initialize 16 bit
counter
343 0000033C E3A03000 MOV r3, #0 ; Initialize Quotie
nt
344 00000340 E3A04000 MOV r4, #0 ; Initialize the si
gn for the dividend
and divisor. 0,2=p
ositive, 1=negative
345 00000344 E3500000 CMP r0, #0 ; check if dividend
ARM Macro Assembler Page 9
is negative
346 00000348 CA000002 BGT POSI
347 0000034C E1E00000 MVN r0, r0 ; One's compliment
for dividend
348 00000350 E2800001 ADD r0, r0, #1 ; Two's compliment
for r0
349 00000354 E3A04001 MOV r4, #1 ; Reminder that div
idend is negative
350 00000358 E3510000
POSI CMP r1, #0 ; Check if divisor
is negative
351 0000035C CA000002 BGT POS2
352 00000360 E1E01001 MVN r1, r1 ; One's compliment
for divisor
353 00000364 E2811001 ADD r1, r1, #1 ; Two's compliment
for divisor
354 00000368 E2844001 ADD r4, r4, #1 ; Sign for the divi
dend and divisor. 0
,2=positive, 1=nega
tive
355 0000036C
356 0000036C E1A01801
POS2 LSL r1, #16 ; Shift divisor by
number of bits
357 00000370
358 00000370 E2422001
LOOP SUB r2, r2, #1 ; decrement the cou
nter
359 00000374 E0400001 SUB r0, r0, r1 ; Calculate the rem
ainder
360 00000378 E3500000 CMP r0, #0 ; Is remainder less
than zero
361 0000037C BA000002 BLT YES ;
362 00000380
363 00000380 E1A03083 MOV r3, r3, LSL #1 ; Left Shift Quo
tient LSB = 1
364 00000384 E2833001 ADD r3 ,#1 ;
365 00000388 EB000001 BL WOW ;
366 0000038C
367 0000038C E0800001
YES ADD r0, r0, r1 ; Calculate the rem
ainder
368 00000390 E1A03083 MOV r3, r3, LSL #1 ;
369 00000394
370 00000394 E1A010E1
WOW MOV r1, r1, ROR #1 ; rotate the div
isor right
371 00000398
372 00000398 E3520000 CMP r2, #0 ; See if counter is
positive
373 0000039C CAFFFFF3 BGT LOOP ; If positive, loop
374 000003A0
375 000003A0 E3540001 CMP r4, #1 ; Check if dividend
was negative
376 000003A4 1A000001 BNE DONE ;
377 000003A8 E1E03003 MVN r3, r3 ; Convert the quoti
ent to negative
378 000003AC E2833001 ADD r3, r3, #1 ; by using Two's co
ARM Macro Assembler Page 10
mpliment
379 000003B0 E1A01000
DONE MOV r1, r0 ; Move the remainde
r to the r1 registe
r
380 000003B4 E1A00003 MOV r0, r3 ; Move the quotient
into r0 register
381 000003B8
382 000003B8 E8BD5FFC LDMFD r13!, {r2-r12, r14}
383 000003BC E12FFF1E BX lr ; Return to the C p
rogram
384 000003C0
385 000003C0
386 000003C0 END
E000C000
E002C000
E0028000
00000000
E0028010
E002C004
0000C30C
E0028008
E0028004
E002800C
Command Line: --debug --xref --apcs=interwork -olibrary.o -IC:\Keil\ARM\INC -IC
:\Keil\ARM\INC\Philips --predefine="__EVAL SETA 1" --list=library.lst library.s
ARM Macro Assembler Page 1 Alphabetic symbol ordering
Relocatable symbols
DONE 000003B0
Symbol: DONE
Definitions
At line 379 in file library.s
Uses
At line 376 in file library.s
Comment: DONE used once
LIBRARY 00000000
Symbol: LIBRARY
Definitions
At line 1 in file library.s
Uses
None
Comment: LIBRARY unused
LOOP 00000370
Symbol: LOOP
Definitions
At line 358 in file library.s
Uses
At line 373 in file library.s
Comment: LOOP used once
POS2 0000036C
Symbol: POS2
Definitions
At line 356 in file library.s
Uses
At line 351 in file library.s
Comment: POS2 used once
POSI 00000358
Symbol: POSI
Definitions
At line 350 in file library.s
Uses
At line 346 in file library.s
Comment: POSI used once
WOW 00000394
Symbol: WOW
Definitions
At line 370 in file library.s
Uses
At line 365 in file library.s
Comment: WOW used once
YES 0000038C
Symbol: YES
Definitions
At line 367 in file library.s
Uses
At line 361 in file library.s
Comment: YES used once
check_sign 00000124
Symbol: check_sign
ARM Macro Assembler Page 2 Alphabetic symbol ordering
Relocatable symbols
Definitions
At line 145 in file library.s
Uses
At line 133 in file library.s
Comment: check_sign used once
digits_SET 00000000
Symbol: digits_SET
Definitions
At line 31 in file library.s
Uses
At line 183 in file library.s
Comment: digits_SET used once
display_digit_on_7_seg 0000015C
Symbol: display_digit_on_7_seg
Definitions
At line 176 in file library.s
Uses
At line 10 in file library.s
Comment: display_digit_on_7_seg used once
div_and_mod 00000334
Symbol: div_and_mod
Definitions
At line 336 in file library.s
Uses
At line 14 in file library.s
Comment: div_and_mod used once
end_read_str 00000134
Symbol: end_read_str
Definitions
At line 151 in file library.s
Uses
At line 147 in file library.s
Comment: end_read_str used once
illuminateLEDs 000001B0
Symbol: illuminateLEDs
Definitions
At line 210 in file library.s
Uses
At line 12 in file library.s
At line 200 in file library.s
illuminate_RGB_LED 000001DC
Symbol: illuminate_RGB_LED
Definitions
At line 229 in file library.s
Uses
At line 13 in file library.s
Comment: illuminate_RGB_LED used once
not_negative 00000110
Symbol: not_negative
Definitions
At line 139 in file library.s
ARM Macro Assembler Page 3 Alphabetic symbol ordering
Relocatable symbols
Uses
At line 135 in file library.s
Comment: not_negative used once
output_char_loop 000000C4
Symbol: output_char_loop
Definitions
At line 110 in file library.s
Uses
At line 114 in file library.s
Comment: output_char_loop used once
output_character 000000BC
Symbol: output_character
Definitions
At line 107 in file library.s
Uses
At line 7 in file library.s
At line 137 in file library.s
At line 140 in file library.s
At line 168 in file library.s
output_str_loop 00000140
Symbol: output_str_loop
Definitions
At line 165 in file library.s
Uses
At line 170 in file library.s
Comment: output_str_loop used once
output_string 0000013C
Symbol: output_string
Definitions
At line 163 in file library.s
Uses
At line 9 in file library.s
Comment: output_string used once
pin_connect_block_setup_for_uart0 00000078
Symbol: pin_connect_block_setup_for_uart0
Definitions
At line 79 in file library.s
Uses
At line 5 in file library.s
Comment: pin_connect_block_setup_for_uart0 used once
read_char_loop 000000A0
Symbol: read_char_loop
Definitions
At line 95 in file library.s
Uses
At line 99 in file library.s
Comment: read_char_loop used once
read_character 00000098
Symbol: read_character
Definitions
At line 92 in file library.s
ARM Macro Assembler Page 4 Alphabetic symbol ordering
Relocatable symbols
Uses
At line 6 in file library.s
At line 131 in file library.s
read_from_push_btns 0000018C
Symbol: read_from_push_btns
Definitions
At line 190 in file library.s
Uses
At line 11 in file library.s
Comment: read_from_push_btns used once
read_string 000000E0
Symbol: read_string
Definitions
At line 122 in file library.s
Uses
At line 8 in file library.s
Comment: read_string used once
read_string_loop 000000F0
Symbol: read_string_loop
Definitions
At line 130 in file library.s
Uses
At line 138 in file library.s
At line 144 in file library.s
set_blue 0000028C
Symbol: set_blue
Definitions
At line 282 in file library.s
Uses
At line 249 in file library.s
Comment: set_blue used once
set_green 00000264
Symbol: set_green
Definitions
At line 270 in file library.s
Uses
At line 247 in file library.s
Comment: set_green used once
set_off 0000031C
Symbol: set_off
Definitions
At line 325 in file library.s
Uses
At line 257 in file library.s
Comment: set_off used once
set_purple 000002B4
Symbol: set_purple
Definitions
At line 294 in file library.s
Uses
ARM Macro Assembler Page 5 Alphabetic symbol ordering
Relocatable symbols
At line 251 in file library.s
Comment: set_purple used once
set_red 0000023C
Symbol: set_red
Definitions
At line 258 in file library.s
Uses
At line 245 in file library.s
Comment: set_red used once
set_white 00000304
Symbol: set_white
Definitions
At line 318 in file library.s
Uses
At line 255 in file library.s
Comment: set_white used once
set_yellow 000002DC
Symbol: set_yellow
Definitions
At line 306 in file library.s
Uses
At line 253 in file library.s
Comment: set_yellow used once
uart_init 00000048
Symbol: uart_init
Definitions
At line 52 in file library.s
Uses
At line 4 in file library.s
Comment: uart_init used once
33 symbols
ARM Macro Assembler Page 1 Alphabetic symbol ordering
Absolute symbols
IO0CLR 0000000C
Symbol: IO0CLR
Definitions
At line 22 in file library.s
Uses
None
Comment: IO0CLR unused
IO0DIR 00000008
Symbol: IO0DIR
Definitions
At line 27 in file library.s
Uses
At line 178 in file library.s
At line 180 in file library.s
IO0SET 00000004
Symbol: IO0SET
Definitions
At line 24 in file library.s
Uses
None
Comment: IO0SET unused
IO1CLR 0000001C
Symbol: IO1CLR
Definitions
At line 23 in file library.s
Uses
At line 220 in file library.s
Comment: IO1CLR used once
IO1DIR 00000018
Symbol: IO1DIR
Definitions
At line 28 in file library.s
Uses
At line 213 in file library.s
At line 215 in file library.s
IO1PIN 00000010
Symbol: IO1PIN
Definitions
At line 26 in file library.s
Uses
None
Comment: IO1PIN unused
IO1SET 00000014
Symbol: IO1SET
Definitions
At line 25 in file library.s
Uses
At line 223 in file library.s
Comment: IO1SET used once
IOBASE E0028000
ARM Macro Assembler Page 2 Alphabetic symbol ordering
Absolute symbols
Symbol: IOBASE
Definitions
At line 21 in file library.s
Uses
At line 177 in file library.s
At line 212 in file library.s
At line 217 in file library.s
PINSEL0 E002C000