这个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;
答案 0 :(得分:0)
环境
注意
if( str.eq(strname, strname2)) then
stdout.put("Passwords match!!!", nl, nl);
mov(strname,[ecx+ebx]);
else
示例
program main;
#include ("stdlib.hhf");
static
Original: string;
Matching: string;
MisMatch: string := "MISMATCH";
NumberOfPasswords: int32 := 0;
PasswordLocations: dword;
begin main;
stdout.put("How many passwords are you entering? ", nl);
stdin.get(NumberOfPasswords);
mov(NumberOfPasswords, EDX);
shl(2, EDX);
mem.alloc(EDX);
mov(EAX, PasswordLocations);
mov(EAX, ECX);
stralloc(64);
mov(EAX, Original);
stralloc(64);
mov(EAX, Matching);
for(mov(0, ESI); ESI < NumberOfPasswords; inc(ESI)) do
stdout.put("Enter password (64 CHARACTERS MAX): ", nl);
stdin.flushInput();
stdin.gets(Original);
stdout.put("Enter again: ", nl);
stdin.flushInput();
stdin.gets(Matching);
if( str.eq(Original, Matching)) then
stdout.put("Passwords match!!!", nl, nl);
stralloc(64);
str.cpy(Original, EAX);
mov(EAX, [ECX + ESI*4]);
else
stdout.put("NO MATCH!!!", nl, nl);
mov(MisMatch, [ECX + ESI*4]);
endif;
endfor;
stdout.put("Verification: ", nl);
for(mov(0, ESI); ESI < NumberOfPasswords; inc(ESI)) do
stdout.put((type string [ECX + ESI * 4]), nl);
endfor;
strfree(Original);
strfree(Matching);
mem.free(PasswordLocations);
end main;