这个HLA程序是要求用户输入一定数量的密码,让用户输入两次进行验证(MISMATCH不匹配)。一切正常,但如果我输入两个密码,例如 qwerty 和 foo,它只会打印出来:
Verification:
foo
foo
我无法围绕这个逻辑绞尽脑汁,因为 dword pass1 应该允许打印出所有不同的密码,有什么想法吗?
#include ("stdlib.hhf");
static
strname: string;
strname2: string;
mismatch: string := "MISMATCH";
num: int32 := 0;
pass1: dword;
procedure Password;
begin Password;
if( str.eq(strname, strname2)) then
stdout.put("Passwords match!!!", nl, nl);
mov(strname,[ecx+ebx]);
else
stdout.put("NO MATCH!!!", nl, nl);
mov(mismatch,[ecx+ebx]);
endif;
end Password;
begin week3;
xor (eax,eax);
stdout.put("How many passwords are you entering? ", nl);
stdin.geti32();
mov(eax,num);
shl(2,num);
mem.alloc(num);
mov(eax,pass1);
stralloc(64);
mov(eax,strname);
stralloc(64);
mov(eax,strname2);
mov(pass1,ecx);
for(mov(0,ebx);ebx<num;add(4,ebx)) do
stdout.put("Enter password (64 CHARACTERS MAX): ", nl);
stdin.flushInput();
stdin.gets(strname);
mov(eax,[ecx+ebx]);
stdout.put("Enter again: ", nl);
stdin.flushInput();
stdin.gets(strname2);
mov(eax,[ecx+ebx]);
Password();
endfor;
stdout.put("Verification: ", nl);
for(mov(0,ebx);ebx<num;add(4,ebx)) do
stdout.put((type string [ecx+ebx]), nl);
endfor;
strfree(strname);
strfree(strname2);
mem.free(pass1);
end week3;