它是一个16位x86代码。我已经存储了每个命令,例如“hi”命令
cmd_hi db 'hi', 0
然后我使用输入字符串
mov di, sp ; get input
call get_string
jcxz loop_start ; blank line?
并将其与存储的命令进行比较
mov si, sp
mov di, cmd_hi ; "hi" command
call strcmp
je .greetme
使用strcmp循环
strcmp:
.loop_start:
mov al, [si] ; grab a byte from SI
cmp al, [di] ; are SI and DI equal?
jne .done ; no, we're done.
test al, al ; zero?
jz .done ; yes, we're done.
inc di ; increment DI
inc si ; increment SI
jmp .loop_start ; loop!
.done:
ret
但现在我想为我的函数添加独立参数,例如2个整数
cmd> hi 1 2
以这种方式解析参数的最佳方法是什么?
通常,在.com文件的情况下(我不确定.exe但我记得它是相同的)你在加载程序的内存段中有两个命令行参数副本。 .com加载为0x100h,命令行参数应在代码段的0到0x100h之间找到。