1
2 ;*
3 ; memmap.mac
4 ;
5 ; Copyright (c) 2002 by Megan Gentry
6 ;
7 ; Abstract:
8 ; This program is designed to locate and report ranges
9 ; of memory in the low 64kb which can be referenced on
10 ; a PDP-11 and report them to the terminal.
11 ;
12 ; The program was designed to be used to map the memory
13 ; on a proto desktop portable pdp-11 which only has a
14 ; 4 line x 40 character LCD screen, which is why it
15 ; displays 3 lines and waits for character input to
16 ; proceed.
17 ;-
18
19 000000 .asect
20 000000 . = 0
21
22 000000 000005 reset ;reset the world
23 000002 000536 br start ; and jump to the code
24
25 000004 000636 .word nxmtrp ; : Address of NXM handler
26 000006 000340 .word 340 ; : PR7
27
28 000300 . = 300
29
30 000300 012700 000646 start: mov #m.head,r0 ;Announce us
31 000304 004767 000226 call ttostr ; ...
32
33 000310 005001 clr r1 ;R1 = Location under test
34 000312 012704 000002 mov #2,r4 ;R4 = Count of lines before wait
35
36 000316 010102 10$: mov r1,r2 ;R2 = Low limit of memory range
37
38 ; Here we look for the end of region of memory which exists
39 ; (we assume that location 0 works)
40
41 000320 000241 20$: clc ;Clear carry (NXM will set carry)
42 000322 105711 tstb @r1 ;Test the location
43 000324 103404 bcs 30$ ;If it is non-existant...
44 000326 010103 mov r1,r3 ;R3 = Hi limit of memory range
45 000330 005201 inc r1 ;Update location under test
46 000332 001372 bne 20$ ; !loop!
47 000334 000407 br 100$ ;When we wrap in 64kb, we're done
48
49 000336 004767 000022 30$: call report ;Report the range (R2,R3)
50
51 ; Here we start looking for the start of the next region of
52 ; responding memory.
53
54 000342 000241 40$: clc ;Clear carry (NXM will set carry)
55 000344 105711 tstb @r1 ;Test the location
56 000346 103363 bcc 10$ ;We've found memory...
57 000350 005201 inc r1 ;Update location under test
.MAIN. MACRO V05.06 00:00 Page 1-1
58 000352 001373 bne 40$ ; !loop!
59 ; br 100$ ;When we wrap in 64kb, we're done
60
61 000354 004767 000004 100$: call report ;Report the range (R2,R3)
62
63 000360 000000 110$: halt ;Stop the world...
64 000362 000776 br 110$ ; and don't let it restart...
65
66
67
68 000364 010200 report: mov r2,r0 ;Print out region low address
69 000366 004767 000106 call octout ; ...
70 000372 012700 000662 mov #m.del,r0 ;Print a delimiter
71 000376 004767 000134 call ttostr ; ...
72 000402 010300 mov r3,r0 ;Print out region hi address
73 000404 004767 000070 call octout ; ...
74 000410 112700 000011 movb #11,r0 ;Another delimiter
75 000414 004767 000166 call ttochr ; ...
76 000420 010300 mov r3,r0 ;Determine number of words (octal)
77 000422 160200 sub r2,r0 ; ...
78 000424 005200 inc r0 ; ...
79 000426 004767 000046 call octout ;Print it out
80 000432 012700 000723 mov #m.crlf,r0 ;On to next line
81 000436 004767 000074 call ttostr ; ...
82 000442 005304 dec r4 ;Should we delay a bit?
83 000444 003014 bgt 10$ ;Nope...
84 000446 012700 000666 mov #m.pak,r0 ;Yes, print out a prompt
85 000452 004767 000060 call ttostr ; ...
86 000456 004767 000140 call ttichr ;Get any character (where is that
87 ; found on a keyboard?)
88 000462 012700 000723 mov #m.crlf,r0 ;On to next line
89 000466 004767 000044 call ttostr ; ...
90 000472 012704 000003 mov #3,r4 ;Reset the line count
91 000476 000207 10$: return
92
93
94
95 000500 010046 octout: mov r0,-(sp) ;Save value
96 000502 042716 177770 bic #177770,@sp ;Isolate an octal digit
97 000506 062716 000060 add #^O60,@sp ;Make it printable
98 000512 006000 ror r0 ;Shift right
99 000514 006200 asr r0 ; three bits
100 000516 006200 asr r0 ; for next digit
101 000520 001402 beq 10$ ;If done... print out
102 000522 004767 177752 call octout ;Not yet, recurse !!
103 000526 012600 10$: mov (sp)+,r0 ;Print a digit
104 000530 004767 000052 call ttochr ; ...
105 000534 000207 return ;Unwind the stack and return
106
107
108
109 000536 010146 ttostr: mov r1,-(sp) ;Save R1 for awhile
110 000540 010001 mov r0,r1 ;Save pointer to string
111 000542 112100 10$: movb (r1)+,r0 ;Get a character of string
112 000544 001406 beq 20$ ;If null, add a <CR><LF>
113 000546 120027 000200 cmpb r0,#200 ;If a <200>, we're done
114 000552 001413 beq 30$ ; ...
.MAIN. MACRO V05.06 00:00 Page 1-2