Units of length conversion

Contributions to this software library are always welcome. Please ensure that you post program listings rather than .raw files. They give a reasonable idea of what your program does without having to load them into a DM42 and you can also include comments in your code. Check out the following link for a decoder/encoder: https://technical.swissmicros.com/decoders/dm42/

You can then copy/paste the listing and post it in "code" tags.
Post Reply
PKeller
Posts: 5
Joined: Fri Sep 25, 2020 8:22 am

Units of length conversion

Post by PKeller » Sat Oct 10, 2020 6:38 pm

"length" is just a simple program to convert between different units of length.

It consists of 7 menus through which one can cycle:

Menu 1: SI meter, angstrom, micrometer, millimeter, centimeter, kilometer
Menu 2: Imperial: inch, foot, yard, furlong, mile, nautical mile
Menu 3: Astronomical: light-second, astronomical unit, light year, parsec, Hubble length, attoparsec
Menu 4: Physics: Stoney unit of length, Planck length, QCD unit of length, electron radius, atomic unit, electronvolt length
Menu 5: Modern Chinese: cùn, chǐ, bù, zhàng, yǐn, lǐ
Menu 6: Ancient Roman: digitus, cubitum, passus, stadium, mille passus, leuga
Menu 7: Klingon: uj, uj'a, qeli'qam, loghqam

For example, If one wants to know how many meters are in 5 parsecs, one goes to the first menu and clicks on 'm'. Then one cycles down to menu 3, types the number 5 and clicks on 'pc'.

To set another reference unit, click on "m" again and then go to another unit and click on it to make it the new reference.

Clicking on 'arrow up' or 'arrow down' cycles through the menus, and 'EXIT' cleans up the flag and variables and ends the program.

The program uses registers 00 to 06 and 10 to 17.
length.raw
(1.5 KiB) Downloaded 10 times

Code: Select all

00 { 1537-Byte Prgm }
01▸LBL "Length"
02 0
03 STO 11
04 STO 12
05 R↓
06 CF 00
07 XEQ 07
08▸LBL 11
09 1
10 STO 10
11 R↓
12 21
13 STO 17
14 R↓
15 "m"
16 ASTO 01
17 CLA
18 20
19 XTOA
20 ASTO 02
21 R↓
22 "μm"
23 ASTO 03
24 "mm"
25 ASTO 04
26 "cm"
27 ASTO 05
28 "km"
29 ASTO 06
30 GTO 04
31▸LBL 21
32 CLA
33 ARCL 01
34 KEY 1 GTO 31
35 CLA
36 ARCL 02
37 KEY 2 GTO 32
38 CLA
39 ARCL 03
40 KEY 3 GTO 33
41 CLA
42 ARCL 04
43 KEY 4 GTO 34
44 CLA
45 ARCL 05
46 KEY 5 GTO 35
47 CLA
48 ARCL 06
49 KEY 6 GTO 36
50 KEY 7 GTO 17
51 KEY 8 GTO 12
52 KEY 9 GTO 09
53 MENU
54 STOP
55▸LBL 12
56 2
57 STO 10
58 R↓
59 22
60 STO 17
61 R↓
62 "in"
63 ASTO 01
64 "ft"
65 ASTO 02
66 "yd"
67 ASTO 03
68 "fur"
69 ASTO 04
70 "mi"
71 ASTO 05
72 "nmi"
73 ASTO 06
74 GTO 04
75▸LBL 22
76 CLA
77 ARCL 01
78 KEY 1 GTO 31
79 CLA
80 ARCL 02
81 KEY 2 GTO 32
82 CLA
83 ARCL 03
84 KEY 3 GTO 33
85 CLA
86 ARCL 04
87 KEY 4 GTO 34
88 CLA
89 ARCL 05
90 KEY 5 GTO 35
91 CLA
92 ARCL 06
93 KEY 6 GTO 36
94 KEY 7 GTO 11
95 KEY 8 GTO 13
96 KEY 9 GTO 09
97 MENU
98 STOP
99▸LBL 13
100 3
101 STO 10
102 R↓
103 23
104 STO 17
105 R↓
106 "ls"
107 ASTO 01
108 "au"
109 ASTO 02
110 "ly"
111 ASTO 03
112 "pc"
113 ASTO 04
114 "cH"
115 ASTO 05
116 "apc"
117 ASTO 06
118 GTO 04
119▸LBL 23
120 CLA
121 ARCL 01
122 KEY 1 GTO 31
123 CLA
124 ARCL 02
125 KEY 2 GTO 32
126 CLA
127 ARCL 03
128 KEY 3 GTO 33
129 CLA
130 ARCL 04
131 KEY 4 GTO 34
132 CLA
133 ARCL 05
134 KEY 5 GTO 35
135 CLA
136 ARCL 06
137 KEY 6 GTO 36
138 KEY 7 GTO 12
139 KEY 8 GTO 14
140 KEY 9 GTO 09
141 MENU
142 STOP
143▸LBL 14
144 4
145 STO 10
146 R↓
147 24
148 STO 17
149 R↓
150 "lS"
151 ASTO 01
152 "lP"
153 ASTO 02
154 "lQCD"
155 ASTO 03
156 "re"
157 ASTO 04
158 "a0"
159 ASTO 05
160 "eV"
161 ASTO 06
162 GTO 04
163▸LBL 24
164 CLA
165 ARCL 01
166 KEY 1 GTO 31
167 CLA
168 ARCL 02
169 KEY 2 GTO 32
170 CLA
171 ARCL 03
172 KEY 3 GTO 33
173 CLA
174 ARCL 04
175 KEY 4 GTO 34
176 CLA
177 ARCL 05
178 KEY 5 GTO 35
179 CLA
180 ARCL 06
181 KEY 6 GTO 36
182 KEY 7 GTO 13
183 KEY 8 GTO 15
184 KEY 9 GTO 09
185 MENU
186 STOP
187▸LBL 15
188 5
189 STO 10
190 R↓
191 25
192 STO 17
193 R↓
194 "cun"
195 ASTO 01
196 "chi"
197 ASTO 02
198 "bu"
199 ASTO 03
200 "zha"
201 ASTO 04
202 "yin"
203 ASTO 05
204 "Li"
205 ASTO 06
206 GTO 04
207▸LBL 25
208 CLA
209 ARCL 01
210 KEY 1 GTO 31
211 CLA
212 ARCL 02
213 KEY 2 GTO 32
214 CLA
215 ARCL 03
216 KEY 3 GTO 33
217 CLA
218 ARCL 04
219 KEY 4 GTO 34
220 CLA
221 ARCL 05
222 KEY 5 GTO 35
223 CLA
224 ARCL 06
225 KEY 6 GTO 36
226 KEY 7 GTO 14
227 KEY 8 GTO 16
228 KEY 9 GTO 09
229 MENU
230 STOP
231▸LBL 16
232 6
233 STO 10
234 R↓
235 26
236 STO 17
237 R↓
238 "digi"
239 ASTO 01
240 "cubit"
241 ASTO 02
242 "pace"
243 ASTO 03
244 "stade"
245 ASTO 04
246 "mille"
247 ASTO 05
248 "leuga"
249 ASTO 06
250 GTO 04
251▸LBL 26
252 CLA
253 ARCL 01
254 KEY 1 GTO 31
255 CLA
256 ARCL 02
257 KEY 2 GTO 32
258 CLA
259 ARCL 03
260 KEY 3 GTO 33
261 CLA
262 ARCL 04
263 KEY 4 GTO 34
264 CLA
265 ARCL 05
266 KEY 5 GTO 35
267 CLA
268 ARCL 06
269 KEY 6 GTO 36
270 KEY 7 GTO 15
271 KEY 8 GTO 17
272 KEY 9 GTO 09
273 MENU
274 STOP
275▸LBL 17
276 7
277 STO 10
278 R↓
279 27
280 STO 17
281 R↓
282 "uj"
283 ASTO 01
284 "uj'a"
285 ASTO 02
286 "qeli'"
287 ASTO 03
288 "logh'"
289 ASTO 04
290 " "
291 ASTO 05
292 " "
293 ASTO 06
294▸LBL 27
295 CLA
296 ARCL 01
297 KEY 1 GTO 31
298 CLA
299 ARCL 02
300 KEY 2 GTO 32
301 CLA
302 ARCL 03
303 KEY 3 GTO 33
304 CLA
305 ARCL 04
306 KEY 4 GTO 34
307 CLA
308 ARCL 05
309 KEY 5 GTO 27
310 CLA
311 ARCL 06
312 KEY 6 GTO 27
313 KEY 7 GTO 16
314 KEY 8 GTO 11
315 KEY 9 GTO 09
316 MENU
317 STOP
318▸LBL 31
319 1
320 STO 13
321 R↓
322 GTO 01
323▸LBL 32
324 2
325 STO 13
326 R↓
327 GTO 01
328▸LBL 33
329 3
330 STO 13
331 R↓
332 GTO 01
333▸LBL 34
334 4
335 STO 13
336 R↓
337 GTO 01
338▸LBL 35
339 5
340 STO 13
341 R↓
342 GTO 01
343▸LBL 36
344 6
345 STO 13
346 R↓
347 GTO 01
348▸LBL 01
349 CLA
350 ARCL IND 13
351 31
352 POSA
353 -1
354 X≠Y?
355 GTO 02
356 FS? 00
357 GTO 03
358 R↓
359 R↓
360 CLA
361 31
362 XTOA
363 ARCL IND 13
364 ASTO IND 13
365 SF 00
366 R↓
367 RCL 10
368 STO 11
369 R↓
370 RCL 13
371 STO 14
372 R↓
373 RCL 11
374 1
375 -
376 6
377 ×
378 RCL 14
379 +
380 STO 16
381 R↓
382 GTO IND 17
383▸LBL 02
384 R↓
385 R↓
386 CLA
387 "xxxxx"
388 ARCL IND 13
389 ASHF
390 ASTO IND 13
391 CF 00
392 0
393 STO 14
394 STO 11
395 R↓
396 GTO IND 17
397▸LBL 03
398 R↓
399 R↓
400 RCL 10
401 STO 12
402 R↓
403 RCL 13
404 STO 15
405 R↓
406 RCL 12
407 1
408 -
409 6
410 ×
411 RCL 15
412 +
413 1
414 STOIJ
415 R↓
416 R↓
417 RCLEL
418 ×
419 RCL 16
420 1
421 STOIJ
422 R↓
423 R↓
424 RCLEL
425 ÷
426 STOP
427 GTO IND 17
428▸LBL 04
429 20
430 RCL 10
431 +
432 STO 00
433 R↓
434 FS? 00
435 GTO 05
436 GTO IND 00
437▸LBL 05
438 RCL 10
439 RCL 11
440 X≠Y?
441 GTO 06
442 R↓
443 R↓
444 CLA
445 31
446 XTOA
447 ARCL IND 14
448 ASTO IND 14
449 R↓
450 GTO IND 00
451▸LBL 06
452 R↓
453 R↓
454 GTO IND 00
455▸LBL 07
456 1
457 ENTER
458 DIM "CM"
459 R↓
460 R↓
461 INDEX "CM"
462 GROW
463 1
464 STOEL
465 R↓
466 1ᴇ-10
467 J+
468 STOEL
469 R↓
470 1ᴇ-6
471 J+
472 STOEL
473 R↓
474 1ᴇ-3
475 J+
476 STOEL
477 R↓
478 0.01
479 J+
480 STOEL
481 R↓
482 1ᴇ3
483 J+
484 STOEL
485 R↓
486 0.0254
487 J+
488 STOEL
489 R↓
490 0.3048
491 J+
492 STOEL
493 R↓
494 0.9144
495 J+
496 STOEL
497 R↓
498 201.168
499 J+
500 STOEL
501 R↓
502 1609.344
503 J+
504 STOEL
505 R↓
506 1852
507 J+
508 STOEL
509 R↓
510 299792458
511 J+
512 STOEL
513 R↓
514 149597870700
515 J+
516 STOEL
517 R↓
518 9460730472580800
519 J+
520 STOEL
521 R↓
522 30856775814913700
523 J+
524 STOEL
525 R↓
526 13623451880516352ᴇ10
527 J+
528 STOEL
529 R↓
530 0.0308567758149137
531 J+
532 STOEL
533 R↓
534 1381ᴇ-38
535 J+
536 STOEL
537 R↓
538 161625518ᴇ-43
539 J+
540 STOEL
541 R↓
542 2103ᴇ-19
543 J+
544 STOEL
545 R↓
546 28179428531ᴇ-25
547 J+
548 STOEL
549 R↓
550 529177208319ᴇ-22
551 J+
552 STOEL
553 R↓
554 197ᴇ-9
555 J+
556 STOEL
557 R↓
558 0.032
559 J+
560 STOEL
561 R↓
562 0.32
563 J+
564 STOEL
565 R↓
566 1.6
567 J+
568 STOEL
569 R↓
570 3.2
571 J+
572 STOEL
573 R↓
574 32
575 J+
576 STOEL
577 R↓
578 576
579 J+
580 STOEL
581 R↓
582 0.0185
583 J+
584 STOEL
585 R↓
586 0.444
587 J+
588 STOEL
589 R↓
590 1.48
591 J+
592 STOEL
593 R↓
594 185
595 J+
596 STOEL
597 R↓
598 1480
599 J+
600 STOEL
601 R↓
602 2220
603 J+
604 STOEL
605 R↓
606 0.3483
607 J+
608 STOEL
609 R↓
610 3.1347
611 J+
612 STOEL
613 R↓
614 2285.1963
615 J+
616 STOEL
617 R↓
618 11825913090726ᴇ3
619 J+
620 STOEL
621 R↓
622 RTN
623▸LBL 09
624 CF 00
625 CLV "CM"
626 END

Post Reply