📄 paddcmd.htm
字号:
<title>Adding PMON Commands</title> <h1 align=center>Adding PMON Commands</h1><!--INDEX "Adding PMON Commands" mycmd -->Adding commands to PMON is very simple. In this example, we wish toadd a command called mycmd. This command simply identifiesitself and prints out a list of its arguments. The function is placedin a file called mycmd.c in the pmon subdirectory. Notice that it iscalled with an argc/argv argument list in exactly the same way asa normal C program is called. As with UNIX, the name of the command is located in argv[0].<p><pre><b>pmon/mycmd.c</b> Optdesc mycmd_opts[] = { {"","My Command"}, {0}}; mycmd(argc,argv) int argc; char *argv[]; { int i; printf("This is my command. Arguments were: "); for (i=1;i<argc;i++) printf("%s ",argv[i]); printf("\n"); }</pre>Note that you can also list any options that your new command accepts, tothe mycmd_opts array. The first field can contain the list of options. Additional lines would explain those options. For example,<p><pre> Optdesc mycmd_opts[] = { {"[-fl]","My Command"}, {"-f","Find bug"}, {"-l","Lose bug"}, {0}};</pre>The name of this function must now be installed in the table ofcommands. The easiest way to do this is by using addCmdRec(). Youcan place this call almost anywhere, but perhaps the best place isin the CPU-specific high-init init code, eg. c4101.c. There is alreadya list of commands in this file, you just need to all yours to the list.<p><pre> CmdRec cmds[] = { {"cache",mycmd_opts,mycmd}, ..... {0}};</pre>Finally, the new module must be added to the list used by the Makefile.<p><pre><b>pmon/files.mk</b> CFILES = sonic.c main.c commands.c dis.c hist.c regs.c sym.c \ set.c stty.c more.c memtst.c go.c load.c debug.c \ cmdtable.c sbrk.c mycmd.c</pre>To support arguments that can be complex expressions, convert theargument from ascii to binary using the function get_rsa(). Thisfunction has the prototype:<pre> int get_rsa(unsigned long *value, char *source);</pre>Where:<p> <dl><dd><table><tr><td> <var>source</var> </td><td>is the input ascii string. </td></tr><tr><td> <var>value</var> </td><td>is the place where the binary value is to be written. </td></tr><tr><td colspan=2> The return value is 1 if the conversion was successful, otherwise it is zero. get_rsa() prints its own messages if the conversion was unsuccessful. </td></tr></table></dl><p>Example:<p><pre> if(!get_rsa(&adr,av[i])) return;</pre>Once the files havebeen modified, you need to rebuild PMON and <ahref="mkroms.htm">make</a> new <a href="romdef.htm">ROMs</a>.<p></dl><p><hr><b>Navigation:</b> <a href="index.htm">Document Home</a> | <a href="doctoc.htm">Document Contents</a> | <a href="docindex.htm">Document Index</a> <p>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -