1 ; User installable disassembler and single-step run for paulmon2
3 ; Please email comments, suggestions, bugs to paul@pjrc.com
5 ; This code is in the public domain. It is distributed in
6 ; the hope that it will be useful, but without any warranty;
7 ; without even the implied warranty of merchantability or fitness
8 ; for a particular purpose.
10 ; For more information, please see
12 ; http://www.pjrc.com/tech/8051/pm2_docs/index.html
14 .equ locat, 0x1000 ;location for these commands (usually 1000)
15 .equ paulmon2, 0x0000 ;location where paulmon2 is at (usually 0000)
17 .equ phex1, 0x2E+paulmon2
18 .equ cout, 0x30+paulmon2 ;send acc to uart
19 .equ phex, 0x34+paulmon2 ;print acc in hex
20 .equ phex16, 0x36+paulmon2 ;print dptr in hex
21 .equ pstr, 0x38+paulmon2 ;print string @dptr
22 .equ ghex, 0x3A+paulmon2 ;get two-digit hex (acc)
23 .equ ghex16, 0x3C+paulmon2 ;get four-digit hex (dptr)
24 .equ upper, 0x40+paulmon2 ;convert acc to uppercase
25 .equ newline, 0x48+paulmon2
26 .equ pcstr, 0x45+paulmon2
27 .equ pint, 0x50+paulmon2
28 .equ smart_wr, 0x56+paulmon2
29 .equ cin_filter, 0x62+paulmon2
30 .equ asc2hex, 0x65+paulmon2
33 .equ list_key, 'L' ;list (disassemble)
34 .equ step_key, 'S' ;single step run
35 .equ vtedit_key, 'E' ;memory editor
38 ;.equ list_key, 'K' ;list (disassemble)
39 ;.equ step_key, 'W' ;single step run
40 ;.equ vtedit_key, 'E' ;memory editor
44 ;location of two bytes used by single-step in internal ram which we
45 ;hope the user's program won't write over while it's running. These
46 ;two bytes hold the address of the previous instruction, so we can
47 ;show the last executed instruction with the current value of the
48 ;registers, which is much more intuitive than displaying the next
49 ;instruction by grabbing the program counter from the stack as was
50 ;done in PAULMON1's single step.
52 .equ lastpc, 0x7C ;don't forget to update the docs below
57 ;---------------------------------------------------------;
61 ;---------------------------------------------------------;
65 .db 0xA5,0xE5,0xE0,0xA5 ;signiture
66 .db 254,list_key,0,0 ;id (254=user installed command)
67 .db 0,0,0,0 ;prompt code vector
71 .db 0,0,0,0 ;user defined
72 .db 255,255,255,255 ;length and checksum (255=unused)
75 newline_h:ljmp newline
77 .org locat+64 ;executable code begins here
79 ; disassembler register usage
80 ; r0 = temporary storage
81 ; r1 = temporart storage
82 ; r2 = first instruction byte
83 ; r3 = second instruction byte
84 ; r4 = third instruction byte
86 ; r6 = program counter (lsb)
87 ; r7 = program counter (msb)
91 clr psw.1 ;use ordinary long format
97 ;print out the memory location and fetch the next three bytes
119 ;fetch constants for instructions not using R0-R7
123 anl a, #01111000b ;grab upper 4 bits
124 mov r0, a ;keep in r0 for a moment
126 anl a, #00000111b ;get lower 3 bits
127 orl a, r0 ;combine in upper 4
128 mov dptr, #opot1 ;opot=operand offset table
132 ;fetch constants for R0-R7 instructions
140 ;now we'll unpack the operand code (# bytes and addr mode)
141 unpack: anl a, #00000011b
144 ;increment the r7/r6 pointer
151 ;now print the bytes and spaces (r0 has # of bytes to print)
155 jb psw.1, pmnu ;skip bytes if running single-step
171 pbytes4:acall space_h
175 ;prints the mnunonic name and spaces
180 mov dptr, #mnot1 ;mnot=mnunonic offset table
183 anl a, #01111000b ;grab upper 4 bits
184 mov r0, a ;keep in r0 for a moment
186 anl a, #00000111b ;get lower 3 bits
187 orl a, r0 ;combine in upper 4
192 mov dptr, #mnot2 ;16 byte table for r0-r7 instructions
198 pmnu0: mov dptr, #mnu_tbl
215 mov a, #dasm2 & 255 ;(low)
217 mov a, #dasm2 >> 8 ;(high)
225 ;fetch constants for instructions not using R0-R7
229 anl a, #01111000b ;grab upper 4 bits
230 mov r0, a ;keep in r0 for a moment
232 anl a, #00000111b ;get lower 3 bits
233 orl a, r0 ;combine in upper 4
234 mov dptr, #opot1 ;opot=operand offset table
238 ;fetch constants for R0-R7 instructions
252 mov dptr, #oprt ;oprt=operand routine table
265 oprt: ajmp opcd1 ;addr11
271 ajmp opcd7 ;direct,#data
274 ajmp opcd10 ;A,direct,rel
275 ajmp opcd11 ;A,#data,rel
276 ajmp opcd12 ;Rn,#data,rel
277 ajmp opcd13 ;@Ri,#data,rel
285 ajmp opcd21 ;direct,rel
293 ajmp opcd29 ;Rn,direct
294 ajmp opcd30 ;Rn,#data
295 ajmp opcd31 ;direct,Rn
296 ajmp opcd32 ;direct,direct
297 ajmp opcd33 ;direct,@Ri
299 ajmp opcd35 ;@Ri,direct
300 ajmp opcd36 ;@Ri,#data
302 ajmp opcd38 ;DPTR,#data16
303 ajmp opcd39 ;A,@A+DPTR
321 opcd3: ;A,direct done
328 pdir1: mov dptr,#sfrmnu
361 mov dptr,#bitptr ;it's a Special Function Reg.
371 pbit1: mov a,r0 ;it's between 20h and 2Fh
381 opcd10: ;A,direct,rel done
402 pat: ;prints the '@' symbol
408 pcomma: ;prints a comma
414 plb: ;prints the '#' symbol
419 opcd6: ;direct,A done
433 opcd26: ;@A+DPTR done
449 opcd1: mov a, r7 ;addr11 done
480 opcd7: ;direct,#data done
490 opcd11: ;A,#data,rel done
497 opcd12: ;Rn,#data,rel done
500 opcd13: ;@Ri,#data,rel done
511 opcd21: ;direct,rel done
514 opcd24: ;bit,rel done
521 opcd29: ;Rn,direct done
525 opcd30: ;Rn,#data done
528 opcd31: ;direct,Rn done
532 opcd32: ;direct,direct done
542 opcd33: ;direct,@Ri done
550 opcd35: ;@Ri,direct done
554 opcd36: ;@Ri,#data done
557 opcd38: ;DPTR,#data16 done
561 opcd27: mov a, r3 ;addr16 done
565 opcd39: ;A,@A+DPTR done
572 opcd40: ;A,@A+PC done
581 opcd41: ;A,@DPTR done
585 opcd42: ;@DPTR,A done
595 sfrmnu: .db 0xE0,"AC",'C'+128
597 .db 0x82,"DP",'L'+128
598 .db 0x83,"DP",'H'+128
603 .db 0x99,"SBU",'F'+128
604 .db 0xCD,"TH",'2'+128
605 .db 0xC8,"T2CO",'N'+128
606 .db 0xCC,"TL",'2'+128
607 .db 0xCB,"RCAP2",'H'+128
608 .db 0xCA,"RCAP2",'L'+128
609 .db 0x8C,"TH",'0'+128
610 .db 0x8A,"TL",'0'+128
611 .db 0x8D,"TH",'1'+128
612 .db 0x8B,"TL",'1'+128
613 sfr1: .db 0xF0,'B'+128 ;5
614 sfr2: .db 0xD0,"PS",'W'+128 ;7
615 sfr3: .db 0xA8,'I','E'+128
616 sfr4: .db 0xB8,'I','P'+128
617 sfr5: .db 0x89,"TMO",'D'+128 ;8
618 sfr6: .db 0x88,"TCO",'N'+128 ;8
619 sfr7: .db 0x98,"SCO",'N'+128 ;8
620 sfr8: .db 0x87,"PCO",'N'+128 ;8
624 opot2: .db 0x59, 0x59, 0x09, 0x09 ;inc, dec, add, addc
625 .db 0x09, 0x09, 0x09, 0x7A ;orl, anl, xrl, mov
626 .db 0x7E, 0x09, 0x76, 0x33 ;mov, subb, mov, cjne
627 .db 0x09, 0x52, 0x09, 0x71 ;xch, djnz, mov, mov
629 bitptr: .db 0x00, 0x02, 0x06, 0x08, 0x0C, 0x0E, 0x10, 0x12
630 .db 0x14, 0x16, 0x1B, 0x1E, 0x20, 0x23, 0x24, 0x25
633 ;some stuff used by single step... it's here to fill up some of
634 ;the unused space from the end of the disassembler code and the
635 ;beginning of the single-step header (which must begin on a 256
639 wr_check: ;write to memory and check that it worked.
640 ;acc=0 if it worked, nonzero if it didn't write
641 mov r0, a ;keep a copy of the data in r0
649 ;delay for approx 1 character transmit time
670 ;---------------------------------------------------------;
672 ; single step command ;
674 ;---------------------------------------------------------;
677 .db 0xA5,0xE5,0xE0,0xA5 ;signiture
678 .db 254,step_key,0,0 ;id (254=user installed command)
679 .db 0,0,0,0 ;prompt code vector
680 .dB 0,0,0,0 ;reserved
681 .db 0,0,0,0 ;reserved
682 .db 0,0,0,0 ;reserved
683 .db 0,0,0,0 ;user defined
684 .db 255,255,255,255 ;length and checksum (255=unused)
686 .org locat+0x440 ;executable code begins here
691 ;first check to make sure they connect int1 low
693 mov dptr, #sserr1 ;give error msg if int1 not grounded
697 ssrun2: ;make sure there's a ljmp at the int1 vector location
703 mov dptr, #sserr2 ;give error that paulmon2 was not found.
705 ssrun3: ;now write an ljmp to "step" in the ram and check it.
713 mov dph, r0 ;now data pointer points to int1 target
727 mov dptr, #sserr3 ;error: couldn't write to memory @xxxx
734 ssrun5: mov a, ip ;set to high priority interrupt
737 ;let's not beat around the bush (like paulmon1), all
738 ;we need to know is where to jump into memory.
747 lcall ghex16 ;ask for the jump location
753 ssrun6: mov r6, dpl ;where we'll begin executing
755 ssrun7: clr tcon.2 ;need low-level triggered int1
756 mov dptr,#ssmsg ;tell 'em we're starting
761 mov sp, #8 ;just like after a reset
762 push acc ;unlike a 8051 start-up, push return addr
763 push acc ;of 0000, just in case they end w/ ret
764 mov dpl, r6 ;load the program's address into dptr
766 mov psw, a ;and clear everything to zero
776 mov lastpc, #ssstart & 255
777 mov (lastpc+1), #ssstart >> 8
779 setb ea ;turn on the interrupt
794 step: ;this is the single step interrupt service code...
796 push psw ;Stack Contents: (in this order)
797 push dph ;PC_L PC_H ACC PSW DPH DPL R0 R1
803 ;in case the previous instruction was "clr ti", we
804 ;must wait for a character transmit time "in case it
805 ;was a move to SBUF) and then set ti so that our cout
806 ;doesn't hang when we transmit the first character!
810 ;now print out a line that looks like this:
811 ;ACC B C DPTR R0 R1 R2 R3 R4 R5 R6 R7 SP PC Instruction
812 ;00 00 0 3F00 00:00:00:00:00:00:00:00 00 - 0000: LJMP 0825
818 mov r0, a ;r0 points to user's acc on stack
820 acall phexsp ;print acc
822 acall phexsp ;print b register
827 acall phex1_h ;print carry bit
831 acall phex_h ;print dptr (msb)
834 acall phexsp ;print dptr (lsb)
838 acall prcolon ;print r0
841 acall prcolon ;print r1
843 acall prcolon ;print r2
845 acall prcolon ;print r3
847 acall prcolon ;print r4
849 acall prcolon ;print r5
851 acall prcolon ;print r6
853 acall phexsp ;print r7
857 acall phexsp ;print stack pointer
860 ;now the trick is to disassemble the instruction... this isn't
861 ;easy, since the user wants to see the last instruction that
862 ;just executed, but program counter on the stack points to the
863 ;next instruction to be executed. The dirty trick is to grab
864 ;the program counter from last time where we stashed it in some
865 ;memory that hopefully the user's program hasn't overwritten.
878 setb psw.1 ;tell it to use a compact format
879 ;the disassembler uses quite a bit of stack space... if the
880 ;user didn't leave enough room for the stack to grow with
881 ;all this overhead, it will likely crash somewhere in the
882 ;disassembler... oh well, not much I can do about it. The
883 ;worst case stack usage for disasm is 9 bytes. We just
884 ;pushed 5 and 6 at the beginning of step. With the two
885 ;bytes for the interrupt, a total of 22 bytes of free stack
886 ;space must be available to use the single-step feature.
896 ;now grab the user's PC value to keep it for next time
899 mov r0, a ;r0 points to user's acc on stack
908 step1: lcall cin_filter
910 step2: cjne a, #13, step7
912 step7: cjne a, #' ', step8 ;check space
914 step8: cjne a,#'?',step10 ;check '?'
918 step10: cjne a,#'Q',step11 ;check 'Q'=quit and run normal
923 mov 8, #0 ;force return to 0000
928 cjne a,#'H',step12 ;check 'H'=hex dump internal ram
930 step12: cjne a,#'R',step13 ;check 'R'=print out registers
932 step13: cjne a,#'S',step14 ;check 'S'=skip next inst
934 step14: cjne a,#'A',step15 ;check 'A'=change acc value
936 step15: cjne a,#'.',step20
967 ssdmp2: acall space_h
973 cjne r0, #0x80, ssdmp1
986 acall phexsp ;print psw
995 acall psfr ;print tmod
998 acall psfr ;print tcon
1001 acall psfr ;print smod
1004 acall psfr ;print pcon
1011 acall phex_h ;print Timer 0
1020 mov a, 8Dh ;print Timer 1
1034 ;skip the next instruction
1037 ssskip2:acall space_h
1043 mov r0, a ;set r0 to point to pc on stack
1045 mov lastpc, r6 ;keep r6/r7 safe in lastpc
1046 mov r6, a ;put user's pc into r6/r7
1057 setb psw.1 ;tell it to use a compact format
1058 acall disasm ;run disasm to show 'em what was skipped
1067 mov r0, a ;set r0 to point to pc on stack
1069 mov r6, lastpc ;restore r6/r7
1070 mov lastpc, a ;update lastpc with next inst addr
1071 mov @r0, a ;also update user's pc!!
1082 mov r0, a ;r0 points to acc on stack
1091 chacc2: mov dptr, #abort
1098 ;stuff some of the disassembler tables, strings, etc since we have a
1099 ;bit of space before the beginning of the editor command code
1102 ;opcode offset table (gives #bytes for the instruction
1103 ;and the number of the routine to print the operands)
1105 opot1: .db 0xAD, 0x06, 0x6F, 0x39, 0x39, 0x46, 0x49, 0x49 ;0
1106 .db 0x63, 0x06, 0x6F, 0x39, 0x39, 0x46, 0x49, 0x49 ;1
1107 .db 0x63, 0x06, 0xAD, 0x39, 0x16, 0x0E, 0x11, 0x11 ;2
1108 .db 0x63, 0x06, 0xAD, 0x39, 0x16, 0x0E, 0x11, 0x11 ;3
1109 .db 0x66, 0x06, 0x1A, 0x1F, 0x16, 0x0E, 0x11, 0x11 ;4
1110 .db 0x66, 0x06, 0x1A, 0x1F, 0x16, 0x0E, 0x11, 0x11 ;5
1111 .db 0x66, 0x06, 0x1A, 0x1F, 0x16, 0x0E, 0x11, 0x11 ;6
1112 .db 0x66, 0x06, 0x22, 0x69, 0x16, 0x1F, 0x92, 0x92 ;7
1113 .db 0x66, 0x06, 0x22, 0xA1, 0x4D, 0x83, 0x86, 0x86 ;8
1114 .db 0x9B, 0x06, 0x96, 0x9D, 0x16, 0x0E, 0x11, 0x11 ;9
1115 .db 0x26, 0x06, 0x22, 0x5D, 0x4D, 0xAD, 0x8E, 0x8E ;A
1116 .db 0x26, 0x06, 0x42, 0x3D, 0x2F, 0x2B, 0x37, 0x37 ;B
1117 .db 0x46, 0x06, 0x42, 0x3D, 0x39, 0x0E, 0x11, 0x11 ;C
1118 .db 0x46, 0x06, 0x42, 0x3D, 0x39, 0x57, 0x11, 0x11 ;D
1119 .db 0xA5, 0x06, 0x11, 0x11, 0x39, 0x0E, 0x11, 0x11 ;E
1120 .db 0xA9, 0x06, 0x89, 0x89, 0x39, 0x1A, 0x89, 0x89 ;F
1122 mnot1: ;mnunonic offset table (gives offset into above table)
1124 .db 0x5A, 0x0E, 0x48, 0x73 ;nop, ajmp, ljmp, rr
1125 .db 0x2B, 0x2B, 0x2B, 0x2B ;inc, inc, inc, inc
1126 .db 0x30, 0x00, 0x43, 0x75 ;jbc, acall, lcall rrc
1127 .db 0x21, 0x21, 0x21, 0x21 ;
1129 .db 0x2E, 0x0E, 0x67, 0x6E ; etc...
1130 .db 0x06, 0x06, 0x06, 0x06 ;
1131 .db 0x38, 0x00, 0x6A, 0x70 ;
1132 .db 0x0A, 0x0A, 0x0A, 0x0A ;
1134 .db 0x33, 0x0E, 0x5D, 0x5D ;
1135 .db 0x5D, 0x5D, 0x5D, 0x5D ;
1136 .db 0x3B, 0x00, 0x12, 0x12 ;
1137 .db 0x12, 0x12, 0x12, 0x12 ;
1139 .db 0x41, 0x0E, 0x8F, 0x8F ;
1140 .db 0x8F, 0x8F, 0x8F, 0x8F ;
1141 .db 0x3E, 0x00, 0x5D, 0x35 ;
1142 .db 0x4C, 0x4C, 0x4C, 0x4C ;
1144 .db 0x7C, 0x0E, 0x12, 0x4F ;
1145 .db 0x24, 0x4C, 0x4C, 0x4C ;
1146 .db 0x4C, 0x00, 0x4C, 0x4F ;
1147 .db 0x80, 0x80, 0x80, 0x80 ;
1149 .db 0x5D, 0x0E, 0x4C, 0x2B ;
1150 .db 0x57, 0x92, 0x4C, 0x4C ;
1151 .db 0x12, 0x00, 0x1C, 0x1C ;
1152 .db 0x15, 0x15, 0x15, 0x15 ;
1154 .db 0x63, 0x0E, 0x19, 0x19 ;
1155 .db 0x84, 0x88, 0x88, 0x88 ;
1156 .db 0x60, 0x00, 0x78, 0x78 ;
1157 .db 0x1F, 0x27, 0x8B, 0x8B ;
1159 .db 0x53, 0x0E, 0x53, 0x53 ;
1160 .db 0x19, 0x4C, 0x4C, 0x4C ;
1161 .db 0x53, 0x00, 0x53, 0x53 ;
1162 .db 0x1C, 0x4C, 0x4C, 0x4C ;
1165 mnot2: .db 0x2B, 0x21, 0x06, 0x0A ;inc, dec, add, addc
1166 .db 0x5D, 0x12, 0x8F, 0x4C ;orl, anl, xlr, mov
1167 .db 0x4C, 0x80, 0x4C, 0x15 ;mov, subb, mov, cjne
1168 .db 0x88, 0x27, 0x4C, 0x4C ;xch, djnz, mov, mov
1171 ;---------------------------------------------------------;
1173 ; External Memory Editor ;
1175 ;---------------------------------------------------------;
1179 ; bit0: 0=display CODE memory, 1=display DATA memory
1180 ; bit1: 0=editing disabled, 1=editing enabled
1181 ; bit2: 0=editing in hex, 1=editing in ascii
1182 ; bit3: 0=normal, 1=in middle of hex entry (value in r5)
1183 ; R6/R7, current memory location
1187 .db 0xA5,0xE5,0xE0,0xA5 ;signiture
1188 .db 254,vtedit_key,0,0 ;id (254=user installed command)
1189 .db 0,0,0,0 ;prompt code vector
1190 .dB 0,0,0,0 ;reserved
1191 .db 0,0,0,0 ;reserved
1192 .db 0,0,0,0 ;reserved
1193 .db 0,0,0,0 ;user defined
1194 .db 255,255,255,255 ;length and checksum (255=unused)
1195 .db "Memory Editor (VT100)",0
1197 .org locat+0x0840 ;executable code begins here
1206 main2: lcall cin_filter
1208 cmd1: cjne a, #27, cmd2 ;quit
1210 cmd2: cjne a, #11, cmd3 ;up
1212 cmd3: cjne a, #10, cmd4 ;down
1214 cmd4: cjne a, #8, cmd5 ;left
1216 cmd5: cjne a, #21, cmd6 ;right
1218 cmd6: cjne a, #12, cmd7 ;redraw
1221 cmd7: cjne a, #17, cmd8 ;quit
1223 cmd8: cjne a, #3, cmd9 ;code memory
1232 cmd9: cjne a, #4, cmd10 ;data memory
1241 cmd10: cjne a, #7, cmd11 ;goto memory loc
1243 cmd11: cjne a, #5, cmd12 ;toggle editing
1245 cmd12: cjne a, #6, cmd13 ;fill memory
1247 cmd13: cjne a, #1, cmd14 ;edit in ascii
1252 acall erase_commands
1253 acall print_commands
1256 cmd14: cjne a, #24, cmd15 ;edit in hex
1261 acall erase_commands
1262 acall print_commands
1265 cmd15: cjne a, #25, cmd16 ;page up
1267 cmd16: cjne a, #26, cmd17 ;page down
1272 cmd_data: ;the input character wasn't any particular command, so
1273 ;maybe it's some input data being typed for edit mode
1274 mov b, a ;keep a copy of user data in b
1278 ajmp main ;ignore if not in edit mode
1280 jnb acc.2, input_hex
1284 cjne a, b, cmd_abort ;check that input is an ascii char
1287 lcall smart_wr ;write the char to memory
1294 jc cmd_abort ;ignore if not hex
1295 mov r0, a ;keep hex value of input in r0
1296 mov dph, r7 ;load dptr with address
1299 jb acc.3, input_hex_2nd
1304 setb acc.3 ;remember that we're waiting for 2nd char
1309 mov a, r5 ;get data from memory
1310 swap a ;shift nibbles
1311 anl a, #11110000b ;just in case
1312 add a, r0 ;add in this input to lower part
1313 lcall smart_wr ;write back to memory
1320 ;the main input routine will always call here when a new
1321 ;byte is entered... so we can do something special if we
1322 ;were waiting for the second character and it is not a
1323 ;legal hex character
1327 ;if editing is disabled, don't do anything
1332 inck2d: jnb acc.3, inck2b
1333 ;if we get here, we were actually waiting for the 2nd char
1338 jnc inck2c ;proceed normally if it is valid
1339 ;if we get here, we did not get a hex legal char
1342 cjne a, #esc_char, inck2e
1348 pop acc ;don't return and do the quit cmd
1349 pop acc ;just quit this entry and wait for next cmd
1351 inck2e: mov dph, r7 ;load dptr with address
1354 lcall smart_wr ;write to memory
1362 ; bit0: 0=display CODE memory, 1=display DATA memory
1363 ; bit1: 0=editing disabled, 1=editing enabled
1364 ; bit2: 0=editing in hex, 1=editing in ascii
1365 ; bit3: 0=normal, 1=in middle of hex entry (value in r5)
1372 ajmp main ;don't allow if not in editing mode
1374 acall erase_commands
1377 mov dptr, #fill_prompt1
1381 jb psw.5, cmd_fill_abort
1384 mov dptr, #fill_prompt2
1388 jb psw.5, cmd_fill_abort
1391 mov dptr, #fill_prompt3
1395 jb psw.5, cmd_fill_abort
1405 ;now r4 is restored to its normal value, dptr holds the
1406 ;first location to fill, and r6/r7 holds the last location to
1407 ;fill, and r2 has the fill value.
1412 cjne a, dpl, cmd_fill_next
1414 cjne a, dph, cmd_fill_next
1415 ;when we get here, we're done!
1416 acall erase_commands
1417 acall print_commands
1427 acall erase_commands
1428 acall print_commands
1433 .db "Fill",31,131,"; First: ",0
1440 acall erase_commands
1444 acall print_commands
1449 acall erase_commands
1450 mov dptr, #goto_prompt
1458 jb psw.5, cmdgt_abort
1464 acall print_commands
1471 acall print_commands
1477 .db 31,131,31,129,": ",0
1600 ; bit0: 0=display CODE memory, 1=display DATA memory
1601 ; bit1: 0=editing disabled, 1=editing enabled
1602 ; bit2: 0=editing in hex, 1=editing in ascii
1603 ; bit3: 0=normal, 1=in middle of hex entry (value in r5)
1604 ; R6/R7, current memory location
1609 mov dptr, #str_cl ;clear screen
1611 acall print_title_line
1613 acall print_addr_line
1615 acall print_dash_line
1619 acall print_dash_line
1621 acall print_commands
1626 ;compute first byte address to display on the screen
1629 ;now display the data
1631 rd2: acall newline_hh
1649 rd4: acall read_dptr
1665 ;make the ascii character inverse
1676 ;now make the hex value inverse
1746 anl a, #01111111b ;avoid unprintable characters
1747 cjne a, #127, aonly2
1752 jnc aonly3 ;avoid control characters
1767 rddptr2:movx a, @dptr
1781 rdr6r7b:movx a, @dptr
1796 cursor_down: ;acc is # of lines to move down
1802 cursor_up: ;acc is # of lines to move up
1808 cursor_left: ;acc is # of characters to move left
1814 cursor_right: ;acc is # of characters to move right
1824 str_so: .db esc_char, "[0;7m", 0
1830 str_se: .db esc_char, "[0m", 0
1852 cjne r0, #16, paddrl
1853 mov dptr, #str_ascii_equiv
1869 ptitle2:mov dptr, #str_data
1870 ptitle3:acall pstr_hh
1874 mov dptr, #str_title
1889 ; bit0: 0=display CODE memory, 1=display DATA memory
1890 ; bit1: 0=editing disabled, 1=editing enabled
1891 ; bit2: 0=editing in hex, 1=editing in ascii
1892 ; bit3: 0=normal, 1=in middle of hex entry (value in r5)
1896 jnb acc.1, pcmd_no_edit
1898 jb acc.2, pcmd_ascii
1912 str_cmd1: .db " ^G=Goto ^C=Code ^D=Data ^L=Redraw ^Q=Quit", 0
1913 str_cmd2: .db "^E-Edit",0
1914 str_cmd3: .db "^A=", esc_char, "[0;7m", "ASCII", esc_char, "[0m", " ^X=Hex", 0
1915 str_cmd4: .db "^A=ASCII ^X=", esc_char, "[0;7m", "Hex", esc_char, "[0m", 0
1916 str_cmd5: .db " ^F=Fill",0
1919 str_cl: .db esc_char, "[H", esc_char, "[2J", 0
1921 str_addr: .db "ADDR:",0
1922 str_ascii_equiv: .db " ASCII EQUIVILANT",0
1923 str_title: .db "8051",31,154,31,131,31,216,"or,",31,248,31,254,", 1996",0
1924 str_code: .db "CODE",0
1925 str_data: .db "DATA",0
1931 newline_hh:ljmp newline
1937 ;---------------------------------------------------------;
1939 ; single step strings ;
1941 ;---------------------------------------------------------;
1945 prompt4:.db "), or <ESC> to exit: ",0
1946 prompt8:.db 13,31,136,128,131,129," (",0
1947 abort: .db " Command Aborted.",13,10,0
1950 sserr1: .db 13,161,197," connect INT1 (pin 13) low"
1951 .db 128,186,207,204,13,0
1952 sserr2: .db 148,"2",179,199,174,129," 0013",13,0
1953 sserr3: .db 31,184,179,255,165," vector",174," ",0
1954 ssmsg: .db 13,"Now",134,"ning",166,207,204," mode: "
1955 .db "<RET>=",204,", ?= Help",13,13,0
1957 sskip1: .db "Skipping Instruction-> ",0
1958 ssdmps1:.db 13,10,"Loc: Int RAM Memory Contents",13,10,0
1959 chaccs1:.db "New Acc Value: ",0
1962 .db 31,207,31,204,31,158,":",13
1963 .db "<RET> ",134,212,246,13
1964 .db " <SP> ",134,212,246,13
1965 .db " '?' ",255,142,215,13
1966 .db " '.' ",255,196,253,"s",13
1967 .db " 'R' ",255," special function",196,"s",13
1968 .db " 'H' ",132,219,192,146,13
1969 .db " 'S' ",252,212,246,13
1970 .db " 'A' ",240,162," Acc value",13
1971 .db " 'Q' ",200,207,204,13,14
1973 squit: .db "Quit",13,10,0
1975 ssnames:.db " ACC B C DPTR R0 R1 R2 R3 R4 R5 R6 R7 SP"
1976 .db " Addr Instruction",13,10,0
1979 ;---------------------------------------------------------;
1981 ; disassembler data ;
1983 ;---------------------------------------------------------;
1987 mnu_tbl:.db "ACAL",'L'+128
2037 bitmnu: .db 'P','0'+128