X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f Date: Tue, 01 Nov 2005 12:46:01 -0500 From: Diego Cueva Subject: Why the call instruction points 2 bytes before to the real start sub-routine ? To: djgpp AT delorie DOT com Message-id: <003201c5df0c$20f5abe0$2432a8c0@dcueva> MIME-version: 1.0 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 X-Mailer: Microsoft Outlook, Build 10.0.4024 Content-type: text/plain; charset=US-ASCII Importance: Normal X-Priority: 3 (Normal) X-MSMail-priority: Normal Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from QUOTED-PRINTABLE to 8bit by delorie.com id jA1HmCqt005241 Reply-To: djgpp AT delorie DOT com Hi: Please help me with the next issue: In the next assembler program: ====================== ipl.s ================ .code32 .text .global start start: nop # Clear screen call clrscr # Print Hello world movw $m1, %si call impstr # End int $0x20 # Clear screen code using assembler clrscr: pushw %ax pushw %bx pushw %cx pushw %dx movb $6, %ah movb $0, %al movb $0, %ch movb $0, %cl movb $24, %dh movb $79, %dl movb $7, %bh int $0x10 popw %dx popw %cx popw %bx popw %ax ret # Putchar using assembler ( ...more code here...) ============================================= I am using the compiler in this way (to generate a ipl.com file or pure code machine file): ..\..\tools\as -o ipl.o ipl.s ..\..\tools\ld -m i386go32 -Ttext 0x0100 -s --oformat binary -o ipl.com ipl.o When I compile using ".code16" at the top of the code, the ipl.com file works very fine, that I expected (clear the screen, print "Hello world\n" and end). But if I omit, or put explicit ".code32", at the top of the file, the ipl.com file has the next problem: 1579:0100 90 NOP 1579:0101 E80B00 CALL 010F 1579:0104 0000 ADD [BX+SI],AL 1579:0106 66 DB 66 1579:0107 BE5C01 MOV SI,015C 1579:010A E83400 CALL 0141 1579:010D 0000 ADD [BX+SI],AL 1579:010F CD20 INT 20 NOTE!!! CALL 010F: Must point to the "clrscr" subroutine, but this subroutine start at 0111. CALL 0141: Must point to the "impstr" subroutine, but this subroutine start at 0143. Note 2 bytes of displacement in the CALL instruction. Obviously the ipl.com file compiled with .code32 does not work fine. 010F points directly to INT 0x20 :( :'( Thanks a lot for your help and time. Att. Diego Cueva. PD: I can accept a RTFM as a response, but say me the section or page. TODO1 SERVICES, INC. -TODO1- es la propietaria de la información contenida en este mensaje y sus anexos, que puede tener carácter confidencial y ha sido enviada para uso exclusivo del destinatario intencional. Si usted ha recibido este mensaje por error, por favor informe de ello al remitente a la mayor brevedad y elimine este mensaje y sus anexos. Está prohibido su uso, distribución, divulgación o almacenamiento, salvo autorización escrita de TODO1. Todo mensaje enviado y/o recibido por TODO1 es monitoreado por motivos operativos y actuando de acuerdo con prácticas de negocio y de seguridad legítimas. TODO1 SERVICES, INC. -TODO1- is the proprietary of the information contained herein and its attachments, that may have confidential character and has been sent to the intended recipient only. If you are not the intended recipient, please contact the sender immediately by replying to this e-mail and delete the message and its attachments. The use, forward, disclosure, record or retention of this message for any purpose whatsoever, is strictly prohibited, unless prior written authorization from TODO1. E-mails to and from TODO1 are monitored for operational reasons and in accordance with lawful business and security practices.