4438 <main>
4438: 3150 9cff add #0xff9c, sp
443c: b012 7e44 call #0x447e <create_password>
4440: 3f40 e444 mov #0x44e4 "Enter the password to continue", r15
4444: b012 9445 call #0x4594 <puts>
4448: 0f41 mov sp, r15
444a: b012 b244 call #0x44b2 <get_password>
444e: 0f41 mov sp, r15
4450: b012 bc44 call #0x44bc <check_password>
4454: 0f93 tst r15
4456: 0520 jnz #0x4462 <main+0x2a>
4458: 3f40 0345 mov #0x4503 "Invalid password; try again.", r15
445c: b012 9445 call #0x4594 <puts>
4460: 063c jmp #0x446e <main+0x36>
4462: 3f40 2045 mov #0x4520 "Access Granted!", r15
4466: b012 9445 call #0x4594 <puts>
446a: b012 d644 call #0x44d6 <unlock_door>
446e: 0f43 clr r15
4470: 3150 6400 add #0x64, sp
create_password로 뭔가 생성하고 get_password로 입력 받은 다음에 check_password로 검사하는 것 같다.447e <create_password>
447e: 3f40 0024 mov #0x2400, r15
4482: ff40 2c00 0000 mov.b #0x2c, 0x0(r15)
4488: ff40 2700 0100 mov.b #0x27, 0x1(r15)
448e: ff40 4800 0200 mov.b #0x48, 0x2(r15)
4494: ff40 6000 0300 mov.b #0x60, 0x3(r15)
449a: ff40 3500 0400 mov.b #0x35, 0x4(r15)
44a0: ff40 6300 0500 mov.b #0x63, 0x5(r15)
44a6: ff40 6c00 0600 mov.b #0x6c, 0x6(r15)
44ac: cf43 0700 mov.b #0x0, 0x7(r15)
44b0: 3041 ret
0x2400 메모리 주소에 0x2c, 0x27, 0x48, 0x60, 0x35, 0x63, 0x6c, 0x00을 넣는다.44bc <check_password>
44bc: 0e43 clr r14
44be: 0d4f mov r15, r13
44c0: 0d5e add r14, r13
44c2: ee9d 0024 cmp.b @r13, 0x2400(r14)
44c6: 0520 jne #0x44d2 <check_password+0x16>
44c8: 1e53 inc r14
44ca: 3e92 cmp #0x8, r14
44cc: f823 jne #0x44be <check_password+0x2>
44ce: 1f43 mov #0x1, r15
44d0: 3041 ret
44d2: 0f43 clr r15
44d4: 3041 ret
xor r14, r14 해서 0으로 초기화하고 검사를 시작한다. 비교 루틴을 굳이 표현하자면,
for(int n = 0; n < 8; ++n)
{
if(*((char*)data + n) == *((char*)created_password + n))
{
r15 = 1;
}
}
if(r15)
{
printf("Access Granted!\n");
}
else
{
printf("Invalid password; try again.\n");
}
대충 이런 느낌이다.
댓글 없음:
댓글 쓰기