📄 paulmon1.asm
字号:
mov a,#',' lcall cout lcall space retplb: ;prints the '#' symbol mov a,#'#' lcall cout retpa: ;prints 'A' mov a,#'A' lcall cout retprc: ;prints 'C' mov a,#'C' lcall cout retpac: ;print "A," acall pa acall pcomma retpdptr: ;prints DPTR push dph push dpl mov dptr,#sdptr lcall pstr pop dpl pop dph retpoweron: MOV SP,#30H clr psw.3 ;set for register bank 0 (init needs it) clr psw.4 LCALL INIT setb ti ;ti is normally set in this program clr ri ;ri is normallt cleared mov r0,#8 lcall newline djnz r0,* MOV DPTR,#logon lCALL PSTR mov dptr,#program MENU: PUSH DPL PUSH DPH MOV DPTR,#PROMPT1 lCALL PSTR POP DPH POP DPL lCALL PHEX16 PUSH DPL PUSH DPH MOV DPTR,#PROMPT2 lCALL PSTR lCALL CIN ;GET THE INPUT CHARACTER lcall upper .equ char, 0x20 MOV CHAR,A MOV DPTR,#CMD_TBL ;BEGIN SEARCH THRU THE TABLEMENU1: CLR A MOVC A,@A+DPTR JZ MENU3 ;JUMP IF END OF TABLE REACHED CJNE A,CHAR,MENU2 ;JUMP IF THIS IS NOT THE COMMAND TYPED INC DPTR ;OK, SO THIS IS THE RIGHT ONE... CLR A MOVC A,@A+DPTR PUSH Acc INC DPTR CLR A MOVC A,@A+DPTR pop b push dpl push dph MOV DPL,A mov DPH,b lCALL PSTR ;PRINT THE COMMAND NAME lCALL NEWLINE pop dph pop dpl INC DPTR CLR A MOVC A,@A+DPTR MOV 22h,A CLR A INC DPTR MOVC A,@A+DPTR mov 21h,a POP 23h POP 24h mov dptr,#menu push dpl push dph mov dpl,24h mov dph,23h PUSH 21h PUSH 22h RET ;SIMULATED CALL TO THE ROUTINE lJMP MENUMENU2: INC DPTR ;SKIP THIS TABLE ENTRY INC DPTR INC DPTR INC DPTR INC DPTR lJMP MENU1MENU3: POP DPH ;NOW WE TELL 'EM THEY TYPED POP DPL ;AN ILLEGAL CHARACTER lCALL NEWLINE lJMP MENU ;this prints the instructions for status and skip in single-stepinst: mov a,r1 ;r0 must point to pc push acc mov a,r2 push acc mov a,r3 push acc mov a,r4 push acc mov a,r5 push acc mov a,r6 push acc mov a,r7 push acc mov dph,@r0 ;put pc into dptr for disasm dec r0 mov dpl,@r0 lcall disasm pop acc mov r7,a pop acc mov r6,a pop acc mov r5,a pop acc mov r4,a pop acc mov r3,a pop acc mov r2,a pop acc mov r1,a ret ;---------------------------------------------------------;; ;; Here begins the data tables and strings: ;; ;;---------------------------------------------------------; logon: .db "\r \r " .db 12,"Welcome to the new and possibly even " .db "improved 8031 monitor/debugger\r" .db "by Paul Stoffregen on 14-OCT-91 " .db "for no good reason whatsoever...\r\r" ;columbs 1234567890123456789012345678901234567890 .db "These are some of the features offered " .db "by this particular debugger:\r\r" .db " Download programs from PC " .db "User-Friendliness!!!!!\r" .db " Run Program " .db "Uses no external RAM\r" .db " (Normal, or single-step) " .db "<ESC> key is supported\r" .db " List assemble code from memory " .db "automatic baud rate detection\r" .db " Hex Dump and Edit external RAM " .db "On-line help (type '?')\r" .db "\rHowever, you don't get somethin' for " .db "nothin'... The code for this debugger\r" .db "requires quite a bit more room than is " .db "typical for a debugger, but it will all\r" .db "fit into a 2764 (8K x 8) EPROM.\r" .db "\rNO Copyright!! Please distribute freely. " .db "Make as many copies as you want.\r\r\r",0 mnu_tbl:.db "ACAL",'L'+128 ;comma is ok .db "AD",'D'+128,' ' .db "ADD",'C'+128 .db "AJM",'P'+128 .db "AN",'L'+128 .DB "CJN",'E'+128 .DB "CL",'R'+128 .DB "CP",'L'+128 .DB "D",'A'+128 .DB "DE",'C'+128 .DB "DI",'V'+128 .DB "DJN",'Z'+128 .DB "IN",'C'+128 .DB "J",'B'+128 .DB "JB",'C'+128 .DB "J",'C'+128 .DB "JM",'P'+128 .DB "JN",'B'+128 .DB "JN",'C'+128 .DB "JN",'Z'+128 .DB "J",'Z'+128 .DB "LCAL",'L'+128 .DB "LJM",'P'+128 .DB "MO",'V'+128 .DB "MOV",'C'+128 .DB "MOV",'X'+128 .DB "MU",'L'+128 .DB "NO",'P'+128 .DB "OR",'L'+128 .DB "PO",'P'+128 .DB "PUS",'H'+128 .DB "RE",'T'+128 .DB "RET",'I'+128 .DB "R",'L'+128 .DB "RL",'C'+128 .DB "R",'R'+128 .DB "RR",'C'+128 .DB "SET",'B'+128 .DB "SJM",'P'+128 .DB "SUB",'B'+128 .DB "SWA",'P'+128 .DB "XC",'H'+128 .DB "XCH",'D'+128 .DB "XR",'L'+128 .DB "??",'?'+128,0bitmnu: .db 'P','0'+128 .db "TCO",'N'+128 .db 'P','1'+128 .db "SCO",'N'+128 .DB 'P','2'+128 .DB 'I','E'+128 .DB 'P','3'+128 .DB 'I','P'+128 .DB 'C','0'+128 .DB "T2CO",'N'+128 .DB "PS",'W'+128 .DB 'D','8'+128 .DB "AC",'C'+128 .DB 'E'+'8'+128 .DB 'B'+128 .DB 'F'+'8'+128 .DB 0sfrmnu: .db 0xE0,"AC",'C'+128 .db 0x81,'S','P'+128 .DB 0x82,"DP",'L'+128 .DB 0x83,"DP",'H'+128 .DB 0x80,'P','0'+128 .DB 0x90,'P','1'+128 .DB 0xA0,'P','2'+128 .DB 0xB0,'P','3'+128 .DB 0x99,"SBU",'F'+128 .DB 0xCD,"TH",'2'+128 .DB 0xC8,"T2CO",'N'+128 .DB 0xCC,"TL",'2'+128 .DB 0xCB,"RCAP2",'H'+128 .DB 0xCA,"RCAP2",'L'+128 .DB 0x8C,"TH",'0'+128 .DB 0x8A,"TL",'0'+128 .DB 0x8D,"TH",'1'+128 .DB 0x8B,"TL",'1'+128sfr1: .db 0xF0,'B'+128 ;5sfr2: .db 0xD0,"PS",'W'+128 ;7sfr3: .DB 0xA8,'I','E'+128sfr4: .DB 0xB8,'I','P'+128sfr5: .DB 0x89,"TMO",'D'+128 ;8sfr6: .DB 0x88,"TCO",'N'+128 ;8sfr7: .DB 0x98,"SCO",'N'+128 ;8sfr8: .DB 0x87,"PCO",'N'+128 ;8 .DB 0mnot: ;mnunonic offset table (gives offset into above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 27h,27h,27h,27h,27h,27h,27h,27h ;DJNZ .DB 53h,0Eh,53h,53h,19h,4Ch,4Ch,4Ch .DB 4Ch,4Ch,4Ch,4Ch,4Ch,4Ch,4Ch,4Ch ;MOV .DB 53h,00h,53h,53h,1Ch,4Ch,4Ch,4Ch .DB 4Ch,4Ch,4Ch,4Ch,4Ch,4Ch,4Ch,4Ch ;MOVbitptr: .db 00h,02h,06h,08h,0Ch,0Eh,10h,12h .db 14h,16h,1Bh,1Eh,20h,23h,24h,25h opot: ;opcode offset table (gives #bytes for the instruction ;and the number of the routine to print the operands) .db 43*4+1,1*4+2,27*4+3,14*4+1 ;00 .db 14*4+1,17*4+2,18*4+1,18*4+1 .db 89,89,89,89,89,89,89,89 ;inc .db 24*4+3,1*4+2,27*4+3,14*4+1 ;10 .db 14*4+1,17*4+2,18*4+1,18*4+1 .db 89,89,89,89,89,89,89,89 ;dec .db 24*4+3,1*4+2,43*4+1,14*4+1 ;20 .db 5*4+2,3*4+2,4*4+1,4*4+1 .db 9,9,9,9,9,9,9,9 ;add .db 24*4+3,1*4+2,43*4+1,14*4+1 ;30 .db 5*4+2,3*4+2,4*4+1,4*4+1 .db 9,9,9,9,9,9,9,9 ;addc .db 25*4+2,1*4+2,6*4+2,7*4+3 ;40 .db 5*4+2,3*4+2,4*4+1,4*4+1 .db 9,9,9,9,9,9,9,9 ;orl .db 25*4+2,1*4+2,6*4+2,7*4+3 ;50 .db 5*4+2,3*4+2,4*4+1,4*4+1 .db 9,9,9,9,9,9,9,9 ;anl .db 25*4+2,1*4+2,6*4+2,7*4+3 ;60 .db 5*4+2,3*4+2,4*4+1,4*4+1 .db 9,9,9,9,9,9,9,9 ;xrl .db 25*4+2,1*4+2,8*4+2,26*4+1 ;70 .db 5*4+2,7*4+3,36*4+2,33*4+2 .db 122,122,122,122,122,122,122,122 ;mov .db 25*4+2,1*4+2,34,40*4+1 ;80 .db 19*4+1,32*4+3,33*4+2,33*4+2 .db 126,126,126,126,126,126,126,126 ;mov .db 38*4+3,1*4+2,37*4+2,39*4+1 ;90 .db 5*4+2,3*4+2,4*4+1,4*4+1 .db 9,9,9,9,9,9,9,9 ;subb .db 9*4+2,1*4+2,8*4+2,23*4+1 ;A0 .db 19*4+1,43*4+1,35*4+2,35*4+2 .db 118,118,118,118,118,118,118,118 ;mov .db 9*4+2,1*4+2,16*4+2,15*4+1 ;B0 .db 11*4+3,10*4+3,13*4+3,13*4+3 .db 51,51,51,51,51,51,51,51 ;cjne .db 17*4+2,1*4+2,16*4+2,15*4+1 ;C0 .db 14*4+1,3*4+2,4*4+1,4*4+1 .db 9,9,9,9,9,9,9,9 ;xch .db 17*4+2,1*4+2,16*4+2,15*4+1 ;D0 .db 14*4+1,21*4+3,4*4+1,4*4+1 .db 82,82,82,82,82,82,82,82 ;djnz .db 41*4+1,1*4+2,4*4+1,4*4+1 ;E0 .db 14*4+1,3*4+2,4*4+1,4*4+1 .db 9,9,9,9,9,9,9,9 ;mov .db 42*4+1,1*4+2,34*4+1,34*4+1 ;F0 .db 14*4+1,6*4+2,34*4+1,34*4+1 .db 113,113,113,113,113,113,113,113 ;movedits1: .db "\rEditing External RAM...<ESC> to quit\r",0edits2: .db " Editing finished, this location unchanged\r\r",0dwlds1: .db "\r\rBegin ascii transmission of " .db "Intel HEX format file, " .db "or <ESC> to abort\r\r",0dwlds2: .db "Download aborted by user\r\r",0dwlds3: .db "\r\r\r\rDownload completed\r\r",0runstd: .db "Run normally",0runs1: .db "\rNow running the program...\r\r",0runss: .db "Run in single step mode",0sserr1: .db "\r\rThe single step run feature will not function" .db " unless INT1 (pin #13) is\r" .db "connected to ground or otherwise held low.\r\r",0ssmsg: .db "\rNow running in single step mode: " .db "<RET>=default, ?=Help\r\r",0sskip1: .db "Skipping ------>",0sskip2: .db "Next will be -->",0ssdmps1:.db "\rLoc: Internal Ram Memory Contents\r",0chaccs1:.db "New Acc Value: ",0squit: .db "\rQuit single step mode, now running normally.\r\r",0sdptr: .db "DPTR",0CMD_TBL:.DB '?' .DW CMD_hlp .DW HELP .db 'R' .dw CMD_run .dw run .db 'D' .dw CMD_dwl .dw download .db 'N' .dw CMD_new .dw new_loc .db 'H' .dw CMD_dmp .dw dump .db 'L' .dw CMD_lst .dw list .db 'E' .dw CMD_edt .dw edit .DB 00hCMD_run:.db " Run program",0CMD_new:.db " New memory location",0CMD_dmp:.db " HEX Dump Memory to the Screen",0CMD_lst:.db " List assembly code",0CMD_hlp:.DB " Help???",0CMD_dwl:.Db " Download program from PC",0CMD_edt:.db " Edit external ram",0Help1txt: .db 12,"These commands are currently " .db "supported:\r\r",0help2txt: ; 1234567890123456789012345678901234567890 .db "\rAll numerical values are shown in hex. " .db "Pressing <ESC> key will exit the\r" .db "current command, even while listing/dumping. " .db "Most prompts require a\r" .db "single character, typically the first letter " .db "of the desired option.\r\rFor information " .db "regarding the single-step run feature,\r" .db "type '?' when asked 'Single-step/Normal' " .db "before running the program.\r\r",0Help3txt: ; 1234567890123456789012345678901234567890 .db 12,"The single step run feature allows you " .db "to execute your program from memory\r" ;1 .db "one instruction at a time, while monitoring " .db "the registers and instructions.\r" ;2 .db "It it NOT a simulation, the program is " .db "executed by the 8031/51 processor.\r" ;3 .db "External Interrupt #1 must be held low " .db "to make the single step function.\r" ;4 .db "\r" ;5 .db "Despite attempts to make the single " .db "step run compatible with all programs,\r" ;6 .db "there will always be some basic limitations " .db "due to its nature:\r\r" ;7 8 .db " 1- External Interrupt #1 must not be" .db " disabled, e.g. MOV IE,#81h\r" ;9 .db " 2- Timer #1 must be correctly generating " .db " the baud rate for the serial port\r" ;10 .db " 3- TI and RI will not work normally, " .db "e.g. 2003: JNB RI,2003, use skip...\r" ;11 .db " 4- Interrupts will not get service " .db "or will interrupt the single step\r" ;12 .db " 5- About 30 bytes of space must be " .db "left available on the stack!\r" ;13 .db " 6- ??? Other problems may also " .db "exist, (this program is FREE, you know)\r" ;14 ; 1234567890123456789012345678901234567890 .db "\r" ;15 .db "Perhaps the worst limitation of the " .db "single step run is that it takes a\r" ;16 .db "very long time to execute even short " .db "pieces of code. It is recommended that\r" ;17 .db "a normal run be attempted first to " .db "estimate where the program goes astray,\r" ;18 .db "the attempt a single step at the beginning " .db "of the questionable code, with a\r" ;19 .db "hardcopy of the assembly listing file " .db "on-hand for memory location reference.\r\r",0 ;20 21 ; 1234567890123456789012345678901234567890 Help4txt: .db 12,"Between steps, the monitor uses absolutely " .db "NO internal or external memory.\r" .db "However, about 30 bytes of stack space " .db "must be left available...\r\r" .db "During a single step run, pressing RETURN " .db "repeatedly will be the usual course\r" .db "of action. However, other options are " .db "available.\r\r" .db " " .db "Typing '?' will display this help screen\r\r",0Help5txt: .db "Single Step Commands:\r\r" .db " <RET> Print Status and execute " .db "the next instruction\r" .db " <SPACE> Execute next instruction w/out status lines\r" .db " '?' Display this on-line help\r" .db " 'R' Print out Special Function Registers\r" .db " 'H' Hex dump internal ram\r" .db " 'S' Skip this instruction\r" .db " 'A' Change the Accumulator's value\r" .db " 'Q' Quit Single Step, continue executing normally\r" .db "\r",0
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -