X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f X-Terra-Karma: 0% X-Terra-Hash: 0cf7ebd350a4dea409bb321cca305b0b Received-SPF: pass (soluezi.terra.com.br: domain of itelefonica.com.br designates 200.154.55.129 as permitted sender) client-ip=200.154.55.129; envelope-from=ferrary AT itelefonica DOT com DOT br; helo=itelefonica.com.br; Date: Thu, 30 Jun 2005 14:46:45 -0300 Message-Id: MIME-Version: 1.0 X-Sensitivity: 3 Content-Type: text/plain; charset=iso-8859-1 From: "ferrary" To: "djgpp" X-XaM3-API-Version: 4.1 (B100) X-SenderIP: 201.13.79.175 Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id j5UHklcQ023086 Reply-To: djgpp AT delorie DOT com what is wrong with this code: Nasm program wich i link to DJGPP (keyboard interrupt handler) ******************* [Bits 32] global _ManTCL,_IniTcl,_FimTcl,_Teclas extern ___djgpp_base_address [section .data] IntTecladoAnt times 6 db 0 IntTecladoNovo times 6 db 0 _Teclas times 127 db 0 TeclasTam: [section .text] Inicio: ;**************************************************************************** _IniTcl: push ebp mov ebp,esp mov [IntTecladoNovo+2],dword _ManTcl mov [IntTecladoNovo],cs mov ax,0204h mov bl,09h int 31h jc near Erro mov [IntTecladoAnt],cx mov [IntTecladoAnt],edx mov ax,0205h mov bl,09h mov cx,[IntTecladoNovo] mov edx,[IntTecladoNovo+2] int 31h jc near Erro mov eax, (TeclasTam - IntTecladoAnt) ;sizeof timer_data mov esi, eax shr esi, 16 ;=20 mov edi, eax and edi, 0ffffh ; si:di =3D length of region to lock in bytes lea ebx, [ds:IntTecladoAnt] lea ecx, [ds:IntTecladoAnt] shr ebx, 16 and ecx, 0ffffh ; bx:cx =3D start of linear address to lock add cx, word [___djgpp_base_address] adc bx, word [___djgpp_base_address+2] mov eax, 0600h ; DPMI lock address function int 31h ; call dpmi jc Erro lea eax, [cs:FimManTcl] lea ecx, [cs:Inicio] sub eax, ecx inc eax ; EAX =3D size of timer interrupt handler mov esi, eax shr esi, 16 ;=20 mov edi, eax and edi, 0ffffh ; si:di =3D length of region to lock in bytes lea ebx, [cs:Inicio] lea ecx, [cs:Inicio] shr ebx, 16 and ecx, 0ffffh ; bx:cx =3D start of linear address to lock add cx, word [___djgpp_base_address] adc bx, word [___djgpp_base_address+2] mov eax, 0600h ; DPMI lock address function int 31h ; call dpmi jc Erro xor eax,eax jmp Fim Erro: mov eax,01h Fim: pop ebp ret ;**************************************************************************** ;**************************************************************************** _FimTcl: push ebp mov ebp,esp mov ax,0205h mov bl,09h mov cx,[IntTecladoAnt] mov edx,[IntTecladoAnt+2] int 31h pop ebp ret ;**************************************************************************** ;**************************************************************************** _ManTcl: cli pusha xor ecx,ecx xor ebx, ebx in al,60h mov cl,al cmp cl,128 jbe Incrementa sub cl, 128 jmp Continua Incrementa: inc bl Continua: in al,61h or al,82h out 61h,al and al,7Fh out 61h,al mov edi,_Teclas add edi,ecx mov [edi],bl FimMan: mov al,20h out 20h,al popa sti FimManTcl: iretd ;; ;**************************************************************************** Djgpp program **************************************** #include #include #include extern int volatile IniTcl(); extern void volatile FimTcl(); extern void volatile ManTcl(); extern unsigned char Teclas[127]; int x,y,i; int main() { if (IniTcl() != 0) { printf("Erro ao instalar o teclado"); exit(0); } while (Teclas[1] != 1) { if ( (Teclas[80]) && (Teclas[75]) ) { printf("%d %d",Teclas[80],Teclas[75]); // break;with this line the program works fine } } FimTcl(); return 0; } *********************************** This works fine under windows98, but in windows XP this works fine for some seconds and then crash with message: Exiting due to signal SIGSEGV General Protection Fault at eip=00001798 eax=73791332 ebx=00000000 ecx=00000060 edx=4e490213 esi=000100f4 edi=0000b73c ebp=000008de esp=00000fc8 program=F:\DJGPP\PROGRA~1\TESTE.EXE cs: sel=01a7 base=02980000 limit=0009ffff ds: sel=0000 es: sel=0000 fs: sel=0000 gs: sel=0000 ss: sel=016f base=02970000 limit=00000fff App stack: [0008fb90..0000fb90] Exceptn stack: [0000faf0..0000dbb0] Call frame traceback EIPs: 0x00001798 F:\DJGPP\PROGRA~1> ******************************* The problems occurs because of a sucessive calls to printf... If I take off the printf of the loop of while this works without problems...... I don't have idea what's happen.