1 ; this copy is hacked to write to page 0Fxxxx when receiving
2 ; an intel-hex download... so it hopefully work on Matt's
7 ; This is a hacked copy of paulmon2 which is intended to work
8 ; with the XA processor. Automatic baud rate detection is not
9 ; supported, and the extras package is not avaialble. Flash
10 ; ROM is not supported. Paulmon2 only understands the first 64k
11 ; of memory, and only recognizes intel-hex with 64k address
12 ; space. Due to differences in arrangement of the XA, Paulmon2
13 ; may crash if it receives invalid intel-hex code (untested).
14 ; See comments in "dnld_ghex" for details about this.
16 ; Other bugs may exist, but the system seems to work.
18 ; Paulmon2 does NOT run in the XA's special 8051 compatibility
19 ; mode. Paulmon2 shuts off the watchdog timer and runs all
20 ; code in system mode (highest priority).
45 ; PAULMON2, a user-friendly 8051 monitor, by Paul Stoffregen
46 ; Please email comments, suggestions, bugs to paul@ece.orst.edu
48 ; It's free. You may copy sections of code from PAULMON2
49 ; into your own programs, even for commercial purposes.
50 ; PAULMON2 should only be distributed free of charge, but may
51 ; be bundled as 'value-added' with other products, such as
52 ; development boards, CDROMs, etc. Please distribute the
53 ; PAULMON2.DOC file and other files, not just the object code!
55 ; The PAULMON2.EQU and PAULMON2.HDR files contain valuable
56 ; information that could help you to write programs for use
59 ; PAULMON2 is in the public domain. PAULMON2 is distributed in
60 ; the hope that it will be useful, but without any warranty;
61 ; without even the implied warranty of merchantability or fitness
62 ; for a particular purpose.
69 ;---------------------------------------------------------;
71 ; PAULMON2's default configuration ;
73 ;---------------------------------------------------------;
75 ; PAULMON2 should be assembled using the modified AS31 assembler,
76 ; originally written by Ken Stauffer, many small changes by Paul
77 ; Stoffregen. This free assembler is available on the web at
78 ; http://www.ece.orst.edu/~paul/8051-goodies/goodies-index.html
79 ; As well, these web pages have a fill-out form which makes it
80 ; very easy to custom configure PAULMON2. Using this form will
81 ; edit the code for you, run the AS31 assmebler, and send you the
82 ; object code to program into your chip.
87 ; These three parameters tell PAULMON2 where the user's memory is
88 ; installed. "bmem" and "emem" define the space that will be searched
89 ; for program headers, user installed commands, start-up programs, etc.
90 ; "bmem" and "emem" should be use so they exclude memory areas where
91 ; perphreal devices may be mapped, as reading memory from an io chip
92 ; may reconfigure it unexpectedly. If flash rom is used, "bmem" and "emem"
93 ; should also include the space where the flash rom is mapped.
95 pgm EQU $F000 ;default location for the user program
96 bmem EQU $0000 ;where is the beginning of memory
97 emem EQU $FFFF ;end of the memory
100 ; Please note... much of the memory management code only looks at the
101 ; upper 8 bits of an address, so it's not a good idea to somehow map
102 ; your memory chips (with complex address decoding logic) into chunks
103 ; less than 256 bytes. In other words, only using a piece of a flash
104 ; rom chip and mapping it between C43A to F91B would confuse PAULMON2
105 ; (as well as require quit a bit of address decoding logic circuitry)
107 ; To set the baud rate, use this formula or set to 0 for auto detection
108 ; baud_const = 256 - (crystal / (4 * 16 * baud)) <-- for XA chip
110 ;baud_const EQU 247 ;19200 baud w/ 11.0592 MHz (XA)
111 ;baud_const EQU 253 ;57600 baud w/ 11.0592 MHz (XA)
112 baud_const EQU 251 ;57600 baud w/ 18.432 MHz (XA)
113 ;baud_const EQU 241 ;19200 baud w/ 18.432 MHz (XA)
114 ;baud_const EQU 236 ;19531 baud w/ 25 MHz (XA)
117 ; About download speed: when writing to ram, PAULMON2 can accept data
118 ; at the maximum baud rate (baud_const=255 or 57600 baud w/ 11.0592 MHz).
119 ; Most terminal emulation programs introduce intentional delays when
120 ; sending ascii data, which you would want to turn off for downloading
121 ; larger programs into ram. For Flash ROM, the maximum speed is set by
122 ; the time it takes to program each location... 9600 baud seems to work
123 ; nicely for the AMD 28F256 chip. The "character pacing" delay in a
124 ; terminal emulation program should be sufficient to download to flash
125 ; rom and any baud rate.
128 ; Several people didn't like the key definations in PAULMON1.
129 ; Actually, I didn't like 'em either, but I never took the time
130 ; to change it. Eventually I got used to them, but now it's
131 ; really easy to change which keys do what in PAULMON2. You
132 ; can guess what to do below, but don't use lowercase.
134 help_key EQU '?' ;help screen
135 dir_key EQU 'M' ;directory
136 run_key EQU 'R' ;run program
137 dnld_key EQU 'D' ;download
138 upld_key EQU 'U' ;upload
139 nloc_key EQU 'N' ;new memory location
140 jump_key EQU 'J' ;jump to memory location
141 dump_key EQU 'H' ;hex dump memory
142 intm_key EQU 'I' ;hex dump internal memory
143 edit_key EQU 'E' ;edit memory
144 clrm_key EQU 'C' ;clear memory
145 erfr_key EQU 'Z' ;erase flash rom
146 xdump_key EQU 'X' ;hex dump ext data memory
149 ;location of parameter table used by download command
150 ;sixteen bytes of internal memory are required beginning at this
156 ;---------------------------------------------------------;
158 ; Interrupt Vectors ;
159 ; (and little bits of code crammed in the empty spaces) ;
161 ;---------------------------------------------------------;
166 breakvec: dw $8f00, vector + breakvec
167 tracevec: dw $8f00, vector + tracevec
168 stackovvec: dw $8f00, vector + stackovvec
169 div0vec: dw $8f00, vector + div0vec
170 uretivec: dw $8f00, vector + uretivec
172 trap0vec: dw $8800, vector + trap0vec
173 trap1vec: dw $8800, vector + trap1vec
174 trap2vec: dw $8800, vector + trap2vec
175 trap3vec: dw $8800, vector + trap3vec
176 trap4vec: dw $8800, vector + trap4vec
177 trap5vec: dw $8800, vector + trap5vec
178 trap6vec: dw $8800, vector + trap6vec
179 trap7vec: dw $8800, vector + trap7vec
180 trap8vec: dw $8800, vector + trap8vec
181 trap9vec: dw $8800, vector + trap9vec
182 trap10vec: dw $8800, vector + trap10vec
183 trap11vec: dw $8800, vector + trap11vec
184 trap12vec: dw $8800, vector + trap12vec
185 trap13vec: dw $8800, vector + trap13vec
186 trap14vec: dw $8800, vector + trap14vec
187 trap15vec: dw $8800, vector + trap15vec
189 int0vec: dw $8900, vector + int0vec
190 tmr0vec: dw $8900, vector + tmr0vec
191 int1vec: dw $8900, vector + int1vec
192 tmr1vec: dw $8900, vector + tmr1vec
193 tmr2vec: dw $8900, vector + tmr2vec
195 rxd0vec: dw $8900, vector + rxd0vec
196 txd0vec: dw $8900, vector + txd0vec
197 rxd1vec: dw $8900, vector + rxd1vec
198 txd1vec: dw $8900, vector + txd1vec
200 swi1vec: dw $8100, vector + swi1vec
201 swi2vec: dw $8200, vector + swi2vec
202 swi3vec: dw $8300, vector + swi3vec
203 swi4vec: dw $8400, vector + swi4vec
204 swi5vec: dw $8500, vector + swi5vec
205 swi6vec: dw $8600, vector + swi6vec
206 swi7vec: dw $8700, vector + swi7vec
213 space: MOV.B R4L,#' '
222 ;---------------------------------------------------------;
224 ; The jump table for user programs to call ;
225 ; subroutines within PAULMON ;
227 ;---------------------------------------------------------;
229 ; no jump table anymore... use TRAP or conditional assembly.
232 ;---------------------------------------------------------;
234 ; Subroutines for serial I/O ;
236 ;---------------------------------------------------------;
239 ;these are the only three routines which access the serial port directly
240 ;but poweron/autobaud to the initial setup
247 CLR ti_0 ;clr ti before the mov to sbuf!
250 esc: ;checks to see if <ESC> is waiting on serial port
251 ;C=clear if no <ESC>, C=set if <ESC> pressed
264 ;everything else from here on should only access the serial
265 ;port using cin/cout/etc
276 ;get 2 digit hex number from serial port
277 ; c = set if ESC pressed, clear otherwise
278 ; flag0 = set if return w/ no input, clear otherwise
282 CALL cin ;get first digit
284 CJNE.B R4L,#27,ghex8f
288 ghex8f: CJNE.B R4L,#13,ghex8h
293 ghex8h: MOV.B R1L,R4L
296 XCH.B R4L,R1L ;r2 will hold hex value of 1st digit
299 CALL cin ;get second digit
301 CJNE.B R4L,#27,ghex8k
303 ghex8k: CJNE.B R4L,#13,ghex8m
307 ghex8m: CJNE.B R4L,#8,ghex8p
310 ghex8p: CJNE.B R4L,#21,ghex8q
312 ghex8q: MOV.B R1H,R4L
326 ;carry set if esc pressed
327 ;flag0 set if return pressed w/ no input
329 MOV.B R1L,#0 ;start out with 0
331 MOV.B R2L,#4 ;number of digits left
337 CJNE.B R4L,#27,ghex16d
338 SETB carry ;handle esc key
343 ghex16d: CJNE.B R4L,#8,ghex16f
345 ghex16f: CJNE.B R4L,#127,ghex16g ;handle backspace
346 ghex16k: CJNE.B R2L,#4,ghex16e ;have they entered anything yet?
352 ghex16g: CJNE.B R4L,#13,ghex16i ;return key
355 CJNE.B R2L,#4,ghex16h
362 ghex16i: MOV.B R2H,R4L ;keep copy of original keystroke
382 ghex16x: ;multiply r3-r2 by 16 (shift left by 4)
398 ghex16y: ;divide r3-r2 by 16 (shift right by 4)
414 asc2hex: ;carry set if invalid input
426 AND.B R4L,#11110000Q ;just in case
442 phex_b: ADD.B R4L,#58
450 phex_c: ADD.B R4L,#58
466 ;a not so well documented feature of pstr is that you can print
467 ;multiple consecutive strings without needing to reload dptr
468 ;(which takes 3 bytes of code!)... this is useful for inserting
469 ;numbers or spaces between strings.
486 ;---------------------------------------------------------;
488 ; The 'high-level' stuff to interact with the user ;
490 ;---------------------------------------------------------;
493 menu: ;first we print out the prompt
494 MOV.W R6,#prompt1 ;give 'em the first part of prompt
505 ;now we're past the prompt, so let's get some input
506 CALL cin ;get the input
510 menu1a: CJNE.B R4L,#help_key,menu1b
515 menu1b: CJNE.B R4L,#dir_key,menu1c
520 menu1c: CJNE.B R4L,#run_key,menu1d
525 menu1d: CJNE.B R4L,#dnld_key,menu1e
530 menu1e: CJNE.B R4L,#upld_key,menu1f
535 menu1f: CJNE.B R4L,#nloc_key,menu1g
540 menu1g: CJNE.B R4L,#jump_key,menu1h
545 menu1h: CJNE.B R4L,#dump_key,menu1i
550 menu1i: CJNE.B R4L,#edit_key,menu1j
555 menu1j: CJNE.B R4L,#clrm_key,menu1l
560 menu1l: CJNE.B R4L,#intm_key,menu1m
565 menu1m: CJNE.B R4L,#xdump_key,menu1n
572 ;invalid input, no commands to run...
573 menu_end: ;at this point, we have not found
574 CALL newline ;anything to run, so we give up.
577 ;..........................................................
579 ;---------------------------------------------------------;
581 ;dnlds1 = "Begin sending Intel HEX format file <ESC> to abort"
582 ;dnlds2 = "Download aborted"
583 ;dnlds3 = "Download completed"
586 ;16 byte parameter table: (eight 16 bit values)
587 ; * 0 = lines received
588 ; * 1 = bytes received
589 ; * 2 = bytes written
590 ; * 3 = bytes unable to write
591 ; * 4 = incorrect checksums
592 ; * 5 = unexpected begin of line
593 ; * 6 = unexpected hex digits (while waiting for bol)
594 ; * 7 = unexpected non-hex digits (in middle of a line)
598 CALL pcstr ;"begin sending file <ESC> to abort"
601 dnld0: movs.w [r5+],#0 ;initialize all parameters to 0
604 ;look for begining of line marker ':'
606 CJNE.B R4L,#27,dnld2 ;Test for escape
608 dnld2: CJNE.B R4L,#':',dnld2b
612 dnld2b: ;check to see if it's a hex digit, error if it is
618 ;begin taking in the line of data
619 dnld3: MOV.B R4L,#'.'
621 MOV.B R2L,#0 ;r4 will count up checksum
623 MOV.B R0L,R4L ;R0 = # of data bytes
626 MOV.B dph,R4L ;High byte of load address
630 MOV.B dpl,R4L ;Low byte of load address
633 CALL dnld_ghex ;Record type
638 CJNE.B R4L,#1,dnld4 ;End record?
641 dnld5: CALL dnld_ghex ;Get data byte
649 CALL smart_wr ;c=1 if an error writing
654 ; 3 = bytes unable to write
664 CALL dnld_ghex ;get checksum
666 JZ dnld1 ;should always add to zero
672 dnld_end: ;handles the proper end-of-download marker
673 CALL dnld_ghex ;get the last checksum
674 ;assume no data in this line.
679 CALL pcstr ;"download went ok..."
680 ;consume any cr or lf character that may have been
681 ;on the end of the last line
686 dnld_esc: ;handle esc received in the download stream
689 CALL pcstr ;"download aborted."
692 dnld_dly: ;a short delay since most terminal emulation programs
693 ;won't be ready to receive anything immediately after
694 ;they've transmitted a file... even on a fast Pentium(tm)
695 ;machine with 16550 uarts!
697 dnlddly2: MOV.B R0H,#0
698 dnlddly3: DJNZ.B R0H,dnlddly3 ;roughly 128k cycles, appox 0.1 sec
707 ;a special version of ghex just for the download. Does not
708 ;look for carriage return or backspace. Handles ESC key by
709 ;poping the return address (I know, nasty, but it saves many
710 ;bytes of code in this 4k ROM) and then jumps to the esc
711 ;key handling. This ghex doesn't echo characters, and if it
712 ;sees ':', it pops the return and jumps to an error handler
713 ;for ':' in the middle of a line. Non-hex digits also jump
714 ;to error handlers, depending on which digit.
716 ; XA compatibility issue: This code pops the return address
717 ; off the stack and does a jump to an error handler. The
718 ; code should examine the mode bit to see if return addresses
719 ; are 16 or 32 bits on the stack. As it is, it will probably
720 ; work in non 16-bit mode (default), but this code could
721 ; use some attention to this detail nonetheless.
726 CJNE.B R4L,#27,dnldgh3
727 dnldgh2: POP.B acc ;<-- compatibility problem!!! Check XA mode
728 POP.B acc ;<-- and pop correct number of words off stack
730 dnldgh3: CJNE.B R4L,#':',dnldgh5
733 adds.w [r5+10], #1 ;handle unexpected beginning of line
734 POP.B acc ;<-- compatibility problem!!! Check XA mode
735 POP.B acc ;<-- and pop correct number of words off stack
736 JMP dnld3 ;and now we're on a new line!
737 dnldgh5: CALL asc2hex
742 dnldgh6: MOV.B R1L,R4L ;keep first digit in r2
745 CJNE.B R4L,#27,dnldgh8
747 dnldgh8: CJNE.B R4L,#':',dnldgh9
749 dnldgh9: CALL asc2hex
754 dnldghA: XCH.B R4L,R1L
760 ;dnlds5 = " lines received"
761 ;dnlds6a = " bytes received"
762 ;dnlds6b = " bytes written"
764 dnld_sum: ;print out download summary
783 dnld_err: ;now print out error summary
784 MOV.w r5, #dnld_parm + 6
788 bne dnlder3 ;any errors?
790 ;no errors, so we print the nice message
794 dnlder3: ;there were errors, so now we print 'em
797 ;but let's not be nasty... only print if necessary
833 dnlder8: CALL newline
837 ;dnlds8: = " bytes unable to write"
838 ;dnlds9: = " incorrect checksums"
839 ;dnlds10: = " unexpected begin of line"
840 ;dnlds11: = " unexpected hex digits"
841 ;dnlds12: = " unexpected non-hex digits"
842 ;dnlds13: = "No errors detected"
846 ;---------------------------------------------------------;
872 jump_doit: ;jump to user code @dptr (this used by run command also)
880 ;---------------------------------------------------------;
883 MOV.B R1L,#16 ;number of lines to print
893 CALL phex16 ;tell 'em the memory location
897 MOV.B R1H,#16 ;r3 counts # of bytes to print
903 CALL phex ;print each byte in hex
906 CALL space ;print a couple extra space
914 AND.B R4L,#01111111Q ;avoid unprintable characters
917 BCC dump4 ;avoid control characters
918 MOV.B R4L,#(' ' - 20h)
919 dump4: ADD.B R4L,#20h
927 DJNZ.B R1L,dump1 ;loop back up to print next line
931 msg_code: db "Code:",0
932 msg_xram: db "Xram:",0
934 ;---------------------------------------------------------;
938 MOV.B R1L,#16 ;number of lines to print
948 CALL phex16 ;tell 'em the memory location
952 MOV.B R1H,#16 ;r3 counts # of bytes to print
958 CALL phex ;print each byte in hex
961 CALL space ;print a couple extra space
969 AND.B R4L,#01111111Q ;avoid unprintable characters
972 BCC xdump4 ;avoid control characters
973 MOV.B R4L,#(' ' - 20h)
974 xdump4: ADD.B R4L,#20h
982 DJNZ.B R1L,xdump1 ;loop back up to print next line
989 ;---------------------------------------------------------;
1002 nloc2: MOV.W R6,#abort
1007 ;---------------------------------------------------------;
1010 edit: ;edit external ram...
1039 edit2: MOV.W R6,#edits2
1043 ;---------------------------------------------------------;
1054 MOV.B dph,#high bmem
1055 dir1: CALL find ;find the next program in memory
1057 dir_end: CALL newline ;we're done if no more found
1062 MOV.B dpl,#32 ;print its name
1064 MOV.B dpl,#32 ;how long is the name
1070 MOV.B R4L,#' ' ;print the right # of spaces
1074 CALL phex16 ;print the memory location
1079 MOV.B dpl,#4 ;now figure out what type it is
1082 MOV.B R1L,dph ;save this, we're inside a search
1084 dir5: CJNE.B R4L,#254,dir5b
1085 MOV.W R6,#type1 ;it's an external command
1087 dir5b: CJNE.B R4L,#255,dir5c
1088 MOV.W R6,#type1a ;it's some system thing
1090 dir5c: CJNE.B R4L,#253,dir5d
1091 MOV.W R6,#type1b ;it's a startup routine
1093 dir5d: CJNE.B R4L,#35,dir5e
1094 MOV.W R6,#type2 ;it's an ordinary program
1096 dir5e: CJNE.B R4L,#143,dir5f
1097 MOV.W R6,#type3 ;it's a background task
1099 dir5f: CJNE.B R4L,#69,dir5g
1100 MOV.W R6,#type4 ;it's a data file
1103 dir6: MOV.W R6,#type5 ;who knows what the hell it is
1105 dir7: CALL pcstr ;print out the type
1106 MOV.B dph,R1L ;go back and find the next one
1108 CJNE.B dph,#high emem, dir8 ;did we just print the last one?
1115 ; type1a=Misc System Thing
1116 ; type1b=Power-Up Code
1118 ; type3=Background Task
1122 ;---------------------------------------------------------;
1131 ;---------------------------------------------------------;
1160 MOV.B R2L,#xdump_key
1180 CJNE.B R4L,#254,help3a ;only FE is an ext command
1192 help3a: ADDS.B dph,#1
1198 help2: ;print 11 standard lines
1199 CALL space ;given key in R4 and name in dptr
1209 ;---------------------------------------------------------;
1214 ;assume we've got the beginning address in r3/r2
1215 ;and the final address in r5/r4 (r4=lsb)...
1217 ;print out what we'll be doing
1232 ;need to adjust end location by 1...
1242 CJNE.B R4L,#27,upld2e
1244 upld2e: CALL newline
1248 upld3: MOV.B R4L,R2L ;how many more bytes to output??
1254 JNZ upld4 ;if >256 left, then do next 16
1256 JZ upld7 ;if we're all done
1257 AND.B R4L,#11110000Q
1258 JNZ upld4 ;if >= 16 left, then do next 16
1259 BR upld5 ;otherwise just finish it off
1260 upld4: MOV.B R1L,#16
1261 upld5: MOV.B R4L,#':' ;begin the line
1264 CALL phex ;output # of data bytes
1265 CALL phex16 ;output memory location
1269 MOV.B R1H,R4L ;r3 will become checksum
1271 CALL phex ;output 00 code for data
1274 CALL phex ;output each byte
1278 DJNZ.B R1L,upld6 ;do however many bytes we need
1282 CALL phex ;and finally the checksum
1285 BCC upld3 ;keep working if no esc pressed
1287 upld7: MOV.B R4L,#':'
1302 ;---------------------------------------------------------;
1304 get_mem: ;this thing gets the begin and end locations for
1305 ;a few commands. If an esc or enter w/ no input,
1306 ;it pops it's own return and returns to the menu
1307 ;(nasty programming, but we need tight code for 4k rom)
1347 CJNE.B R4L,#'Y',abort_it
1350 ;now we actually do it
1352 clrm2: MOV.B dph,R1H
1364 ;---------------------------------------------------------;
1369 CJNE.w r5, #512, intm3
1372 intm3: mov.b r4l,r5h
1382 AND.B R4L,#00001111Q
1388 ;---------------------------------------------------------;
1390 ; Subroutines for memory managment and non-serial I/O ;
1392 ;---------------------------------------------------------;
1395 ;finds the next header in the external memory.
1396 ; Input DPTR=point to start search (only MSB used)
1397 ; Output DPTR=location of next module
1398 ; C=set if a header found, C=clear if no more headers
1402 CJNE.B R4L,#0xA5,find3
1406 CJNE.B R4L,#0xE5,find3
1410 CJNE.B R4L,#0xE0,find3
1414 CJNE.B R4L,#0xA5,find3
1415 MOV.B dpl,#0 ;found one here!
1419 CJNE.B dph, #high emem, find4 ;did we just check the end
1422 find4: ADDS.B dph,#1 ;keep on searching
1428 ;Write to ordinary RAM. Carry bit will indicate
1429 ;if the value was successfully written, C=1 if not written.
1436 wr_ram: MOV.B R4L,R4H
1437 MOVX.B [R6],R4L ;write the value to memory
1439 MOVC.B A,[A+dptr] ;read it back from code memory
1443 MOVX.B R4L,[R6] ;read it back from data memory
1456 ;---------------------------------------------------------;
1458 ; Power-On initialization code and such... ;
1460 ;---------------------------------------------------------;
1462 ;first the hardware has to get initialized.
1466 mov.b wdcon, #0 ;shut off watchdog
1470 ;or.b p1cfga, #$C0 ;for testing
1471 ;or.b p1cfgb, #$C0 ;for testing
1473 ;clr p1.7 ;for testing
1475 ;no automatic baud rate detection anymore
1478 MOV.B R4L,#baud_const
1481 MOV.B tmod,#$22 ;set timer #1 for 8 bit auto-reload
1483 SETB tr1 ;start the baud rate timer
1485 ab_loop1: DJNZ.w r5, ab_loop1
1487 ;clr p1.6 ;for testing
1492 welcm2: CALL newline
1495 ;setb p1.7 ;for testing
1505 ;CALL dir ;skip dir for now
1514 ;---------------------------------------------------------;
1516 ; More subroutines, but less frequent used ;
1518 ;---------------------------------------------------------;
1524 pint8u: ;prints the unsigned 8 bit value in Acc in base 10
1529 pint8: ;prints the signed 8 bit value in Acc in base 10
1539 pint8b: MOV.B R4H,#100
1546 pint8c: MOV.B R4L,R4H
1551 pint8d: ADD.B R4L,#'0'
1553 pint8e: MOV.B R4L,R4H
1562 ;print 16 bit unsigned integer in DPTR (r6), using base 10.
1566 pint16a: ;ten-thousands digit
1576 pint16b: ;thousands digit
1583 pint16c: ADD.B R4L,#'0'
1586 pint16d: ;hundreds digit
1592 pint16e: ADD.B R4L,#'0'
1595 pint16f: ;tens digit
1600 pint16g: ADD.B R4L,#'0'
1602 pint16h: ;ones digit
1603 MOV.B R4L,R2h ;and finally the ones digit
1611 upper: ;converts the ascii code in Acc to uppercase, if it is lowercase
1615 BCS upper2 ;is it a lowercase character
1619 ADD.B R4L,#224 ;convert to uppercase
1621 upper2: POP.B acc ;don't change anything
1625 lenstr: MOV.B R0L,#0 ;returns length of a string in r0
1627 lenstr1: MOVS R4L,#0
1639 ;pcstr prints the compressed strings. A dictionary of 128 words is
1640 ;stored in 4 bit packed binary format. When pcstr finds a byte in
1641 ;a string with the high bit set, it prints the word from the dictionary.
1642 ;A few bytes have special functions and everything else prints as if
1643 ;it were an ordinary string.
1645 ; special codes for pcstr:
1648 ; 14 = CR/LF and end of string
1649 ; 31 = next word code should be capitalized
1651 pcstr: push r0, r2, r4
1660 pcstrs1: CJNE.B R4L,#13,pcstrs2
1664 pcstrs2: CJNE.B R4L,#31,pcstrs3
1667 pcstrs3: CJNE.B R4L,#14,pcstrs4
1674 pcstr2: pop r0, r2, r4
1677 ;dcomp actually takes care of printing a word from the dictionary
1679 ; dptr = position in packed words table
1680 ; r4=0 if next nibble is low, r4=255 if next nibble is high
1682 decomp: AND.B R4L,#0x7F
1683 MOV.B R0L,R4L ;r0 counts which word
1684 JB flag1,decomp1 ;avoid leading space if first word
1692 ;here we must seek past all the words in the table
1693 ;that come before the one we're supposed to print
1695 dcomp2: CALL get_next_nibble
1697 ;when we get here, a word has been skipped... keep doing
1698 ;this until we're pointing to the correct one
1700 dcomp3: ;now we're pointing to the correct word, so all we have
1701 ;to do is print it out
1702 CALL get_next_nibble
1704 CJNE.B R4L,#15,dcomp4
1705 ;the character is one of the 12 least commonly used
1706 CALL get_next_nibble
1711 dcomp4: ;the character is one of the 14 most commonly used
1716 dcomp5: ;decide if it should be uppercase or lowercase
1720 CJNE.B R0L,#20,dcomp6
1722 dcomp6: CJNE.B R0L,#12,dcomp7
1730 get_next_nibble: ;...and update dptr and r4, of course
1735 AND.B R4L,#00001111Q
1740 AND.B R4L,#00001111Q
1744 ;---------------------------------------------------------;
1746 ; Here begins the data tables and strings ;
1748 ;---------------------------------------------------------;
1750 ;this is the dictionary of 128 words used by pcstr.
1753 DB 0x82,0x90,0xE8,0x23,0x86,0x05,0x4C,0xF8
1754 DB 0x44,0xB3,0xB0,0xB1,0x48,0x5F,0xF0,0x11
1755 DB 0x7F,0xA0,0x15,0x7F,0x1C,0x2E,0xD1,0x40
1756 DB 0x5A,0x50,0xF1,0x03,0xBF,0xBA,0x0C,0x2F
1757 DB 0x96,0x01,0x8D,0x3F,0x95,0x38,0x0D,0x6F
1758 DB 0x5F,0x12,0x07,0x71,0x0E,0x56,0x2F,0x48
1759 DB 0x3B,0x62,0x58,0x20,0x1F,0x76,0x70,0x32
1760 DB 0x24,0x40,0xB8,0x40,0xE1,0x61,0x8F,0x01
1761 DB 0x34,0x0B,0xCA,0x89,0xD3,0xC0,0xA3,0xB9
1762 DB 0x58,0x80,0x04,0xF8,0x02,0x85,0x60,0x25
1763 DB 0x91,0xF0,0x92,0x73,0x1F,0x10,0x7F,0x12
1764 DB 0x54,0x93,0x10,0x44,0x48,0x07,0xD1,0x26
1765 DB 0x56,0x4F,0xD0,0xF6,0x64,0x72,0xE0,0xB8
1766 DB 0x3B,0xD5,0xF0,0x16,0x4F,0x56,0x30,0x6F
1767 DB 0x48,0x02,0x5F,0xA8,0x20,0x1F,0x01,0x76
1768 DB 0x30,0xD5,0x60,0x25,0x41,0xA4,0x2C,0x60
1769 DB 0x05,0x6F,0x01,0x3F,0x26,0x1F,0x30,0x07
1770 DB 0x8E,0x1D,0xF0,0x63,0x99,0xF0,0x42,0xB8
1771 DB 0x20,0x1F,0x23,0x30,0x02,0x7A,0xD1,0x60
1772 DB 0x2F,0xF0,0xF6,0x05,0x8F,0x93,0x1A,0x50
1773 DB 0x28,0xF0,0x82,0x04,0x6F,0xA3,0x0D,0x3F
1774 DB 0x1F,0x51,0x40,0x23,0x01,0x3E,0x05,0x43
1775 DB 0x01,0x7A,0x01,0x17,0x64,0x93,0x30,0x2A
1776 DB 0x08,0x8C,0x24,0x30,0x99,0xB0,0xF3,0x19
1777 DB 0x60,0x25,0x41,0x35,0x09,0x8E,0xCB,0x19
1778 DB 0x12,0x30,0x05,0x1F,0x31,0x1D,0x04,0x14
1779 DB 0x4F,0x76,0x12,0x04,0xAB,0x27,0x90,0x56
1780 DB 0x01,0x2F,0xA8,0xD5,0xF0,0xAA,0x26,0x20
1781 DB 0x5F,0x1C,0xF0,0xF3,0x61,0xFE,0x01,0x41
1782 DB 0x73,0x01,0x27,0xC1,0xC0,0x84,0x8F,0xD6
1783 DB 0x01,0x87,0x70,0x56,0x4F,0x19,0x70,0x1F
1784 DB 0xA8,0xD9,0x90,0x76,0x02,0x17,0x43,0xFE
1785 DB 0x01,0xC1,0x84,0x0B,0x15,0x7F,0x02,0x8B
1786 DB 0x14,0x30,0x8F,0x63,0x39,0x6F,0x19,0xF0
1787 DB 0x11,0xC9,0x10,0x6D,0x02,0x3F,0x91,0x09
1788 DB 0x7A,0x41,0xD0,0xBA,0x0C,0x1D,0x39,0x5F
1789 DB 0x07,0xF2,0x11,0x17,0x20,0x41,0x6B,0x35
1790 DB 0x09,0xF7,0x75,0x12,0x0B,0xA7,0xCC,0x48
1791 DB 0x02,0x3F,0x64,0x12,0xA0,0x0C,0x27,0xE3
1792 DB 0x9F,0xC0,0x14,0x77,0x70,0x11,0x40,0x71
1793 DB 0x21,0xC0,0x68,0x25,0x41,0xF0,0x62,0x7F
1794 DB 0xD1,0xD0,0x21,0xE1,0x62,0x58,0xB0,0xF3
1795 DB 0x05,0x1F,0x73,0x30,0x77,0xB1,0x6F,0x19
1796 DB 0xE0,0x19,0x43,0xE0,0x58,0x2F,0xF6,0xA4
1797 DB 0x14,0xD0,0x23,0x03,0xFE,0x31,0xF5,0x14
1798 DB 0x30,0x99,0xF8,0x03,0x3F,0x64,0x22,0x51
1799 DB 0x60,0x25,0x41,0x2F,0xE3,0x01,0x56,0x27
1800 DB 0x93,0x09,0xFE,0x11,0xFE,0x79,0xBA,0x60
1801 DB 0x75,0x42,0xEA,0x62,0x58,0xA0,0xE5,0x1F
1802 DB 0x53,0x4F,0xD1,0xC0,0xA3,0x09,0x42,0x53
1803 DB 0xF7,0x12,0x04,0x62,0x1B,0x30,0xF5,0x05
1804 DB 0xF7,0x69,0x0C,0x35,0x1B,0x70,0x82,0x2F
1805 DB 0x2F,0x14,0x4F,0x51,0xC0,0x64,0x25,0x00
1809 logon1: DB "Welcome",128,148,"2 (beta7,XA) by",31,248,31,254,13,14
1810 logon2: DB 32,32,"See",148,"2.DOC,",148,"2.EQU",164
1811 DB 148,"2.HDR",180,213,141,".",14
1812 abort: DB " ",31,158,31,160,"!",14
1813 prompt1: DB 148,"2 (beta7,XA) Loc:",0
1815 prompt3: DB 134,202,130,'(',0
1816 prompt4: DB "),",149,140,128,200,": ",0
1817 prompt5: DB 31,151,130,195,"s",199,166,131,","
1818 DB 186," JUMP",128,134,161,"r",130,13,14
1819 prompt6: DB 13,13,31,135,131,129,": ",0
1820 prompt7: DB 31,228,251," key: ",0
1821 prompt8: DB 13,13,31,136,128,131,129," (",0
1822 prompt9: DB 13,13,31,130,31,253,0
1823 prompt9b: DB 31,129,32,32,32,32,32,31,201,14
1824 prompt10: DB ") ",31,135,31,178,": ",0
1825 beg_str: DB "First",31,129,": ",0
1826 end_str: DB "Last",31,129,":",32,32,0
1827 sure: DB 31,185,161," sure?",0
1828 edits1: DB 13,13,31,156,154,146,",",140,128,200,14
1829 edits2: DB " ",31,156,193,",",142,129,247,13,14
1830 dnlds1: DB 13,13,31,159," ascii",249,150,31,152,132,137
1831 DB ",",149,140,128,160,13,14
1832 dnlds2: DB 13,31,138,160,"ed",13,14
1833 dnlds3: DB 13,31,138,193,"d",13,14
1834 dnlds4: DB "Summary:",14
1835 dnlds5: DB " ",198,"s",145,"d",14
1836 dnlds6a: DB " ",139,145,"d",14
1837 dnlds6b: DB " ",139," written",14
1838 dnlds7: DB 31,155,":",14
1839 dnlds8: DB " ",139," unable",128," write",14
1840 dnlds9: DB 32,32,"bad",245,"s",14
1841 dnlds10: DB " ",133,159,150,198,14
1842 dnlds11: DB " ",133,132,157,14
1843 dnlds12: DB " ",133," non",132,157,14
1844 dnlds13: DB 31,151,155," detected",13,14
1845 runs1: DB 13,134,"ning",130,":",13,14
1846 uplds3: DB 13,13,"Sending",31,152,132,137,172,32,32,0
1847 uplds4: DB " ",128,32,32,0
1848 help1txt: DB 13,13,"Standard",31,158,"s",14
1849 help2txt: DB 31,218,31,244,"ed",31,158,"s",14
1850 type1: DB 31,154,158,0
1852 type1b: DB 31,143,31,226,31,170,0
1854 type3: DB "Reserved",0
1855 type4: DB 31,239,137,0
1857 help_cmd: DB 31,142,215,209,0
1858 help_cmd2: DB 31,215,0
1859 dir_cmd: DB 31,209,130,"s",0
1860 run_cmd: DB 31,134,130,0
1861 dnld_cmd: DB 31,138,0
1862 upld_cmd: DB 31,147,0
1863 nloc_cmd: DB 31,135,129,0
1864 jump_cmd: DB 31,136,128,131,129,0
1865 dump_cmd: DB 31,132,219,154," code",131,0
1866 xdump_cmd: db 31,132,219,154," data",131,0
1867 intm_cmd: DB 31,132,219,192,131,0
1868 edit_cmd: DB 31,156,154,146,0
1869 clrm_cmd: DB 31,237,131,0
1870 erfr_cmd: DB 31,203,153,144,0
1875 ;this code attempts to switch from development mode to run mode
1876 ;on the xa_tiny (8-bit data bus) development board.
1883 ; a bunch of nops, to hopefully flush the xa prefetch buffer
1918 ;make a read from location 0x0EF000 to switch modes
1922 mov.b r4l, [r0] ;make the mode switch
1923 mov.b r4l, [r0] ;make the mode switch
1924 mov.b r4l, [r0] ;make the mode switch
1925 mov.b r4l, [r0] ;make the mode switch
1927 ;now read the start vector from location zero
1930 movc r1l, [r0+] ;read psw value into r1
1932 movc r2l, [r0+] ;read start address into r2