I've got a problem with gcc (DJGPP). The following Code works.
Code: Select all
char foo(char nFirstValue, char shiftstatus)
{
switch(nFirstValue)
{
case SCANCODE_A:
return 1;
break;
case SCANCODE_B:
return 2;
break;
case SCANCODE_C:
return 3;
break;
case SCANCODE_D:
return 4;
break;
};
return 0;
}
ASM Code:
:00001A90 55 push ebp
:00001A91 89E5 mov ebp, esp
:00001A93 83EC0C sub esp, 0000000C
:00001A96 8B4508 mov eax, dword ptr [ebp+08]
:00001A99 8B550C mov edx, dword ptr [ebp+0C]
:00001A9C 8845FF mov byte ptr [ebp-01], al
:00001A9F 8855FE mov byte ptr [ebp-02], dl
:00001AA2 0FBE45FF movsx eax, byte ptr [ebp-01]
:00001AA6 8945F4 mov dword ptr [ebp-0C], eax
:00001AA9 837DF420 cmp dword ptr [ebp-0C], 00000020
:00001AAD 7437 je 00001AE6
:00001AAF 837DF420 cmp dword ptr [ebp-0C], 00000020
:00001AB3 7F08 jg 00001ABD
:00001AB5 837DF41E cmp dword ptr [ebp-0C], 0000001E
:00001AB9 7410 je 00001ACB
:00001ABB EB32 jmp 00001AEF
:00001ABD 837DF42E cmp dword ptr [ebp-0C], 0000002E
:00001AC1 741A je 00001ADD
:00001AC3 837DF430 cmp dword ptr [ebp-0C], 00000030
:00001AC7 740B je 00001AD4
:00001AC9 EB24 jmp 00001AEF
:00001ACB C745F801000000 mov [ebp-08], 00000001
:00001AD2 EB22 jmp 00001AF6
:00001AD4 C745F802000000 mov [ebp-08], 00000002
:00001ADB EB19 jmp 00001AF6
:00001ADD C745F803000000 mov [ebp-08], 00000003
:00001AE4 EB10 jmp 00001AF6
:00001AE6 C745F804000000 mov [ebp-08], 00000004
:00001AED EB07 jmp 00001AF6
:00001AEF C745F800000000 mov [ebp-08], 00000000
:00001AF6 8B45F8 mov eax, dword ptr [ebp-08]
:00001AF9 C9 leave
:00001AFA C3 ret
Code: Select all
char foo(char nFirstValue, char shiftstatus)
{
switch(nFirstValue)
{
case SCANCODE_A:
return 1;
break;
case SCANCODE_B:
return 2;
break;
case SCANCODE_C:
return 3;
break;
case SCANCODE_D:
return 4;
break;
case SCANCODE_F:
return 5;
break;
};
return 0;
}
ASM Code:
:00001A90 55 push ebp
:00001A91 89E5 mov ebp, esp
:00001A93 83EC0C sub esp, 0000000C
:00001A96 8B4508 mov eax, dword ptr [ebp+08]
:00001A99 8B550C mov edx, dword ptr [ebp+0C]
:00001A9C 8845FF mov byte ptr [ebp-01], al
:00001A9F 8855FE mov byte ptr [ebp-02], dl
:00001AA2 0FBE45FF movsx eax, byte ptr [ebp-01]
:00001AA6 83E81E sub eax, 0000001E
:00001AA9 8945F4 mov dword ptr [ebp-0C], eax
:00001AAC 837DF412 cmp dword ptr [ebp-0C], 00000012
:00001AB0 0F8787000000 ja 00001B3D
:00001AB6 8B55F4 mov edx, dword ptr [ebp-0C]
:00001AB9 8B0495C41A0000 mov eax, dword ptr [4*edx+00001AC4]
:00001AC0 FFE0 jmp eax <-- BUG Jump @0x00 ?!!
..
Hornet (german)