delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2006/01/23/11:31:54

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
Date: Mon, 23 Jan 2006 10:28:11 -0500
From: Diego Cueva <dcueva AT todo1 DOT com>
Subject: RE: Converting Intel code
In-reply-to: <43d4e943_2@x-privat.org>
To: djgpp AT delorie DOT com
Message-id: <002d01c62031$9fc98bb0$2432a8c0@dcueva>
MIME-version: 1.0
X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
X-Mailer: Microsoft Outlook, Build 10.0.4024
Importance: Normal
X-Priority: 3 (Normal)
X-MSMail-priority: Normal
X-MIME-Autoconverted: from QUOTED-PRINTABLE to 8bit by delorie.com id k0NGVSTW023942
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

May be this help you:

int main(){
int val;
asm(
  "cli\n\t"
    "xorb %%al,%%al\n\t"
    "outb %%al,$0x43\n\t"
    "inb  $0x40,%%al\n\t"
    "movb %%al,%%bl\n\t"
    "inb  $0x40,%%al\n\t"
    "movb %%al,%%bh\n\t"
    "sti": "=b"(val): );

return 0;

}

The binary generated is the next:

1DDB:04D7 FA             cli
1DDB:04D8 30 C0          xor          al,al
1DDB:04DA E6 43          out          43,al
1DDB:04DC E4 40          in           al,40
1DDB:04DE 88 C3          mov          bl,al
1DDB:04E0 E4 40          in           al,40
1DDB:04E2 88 C7          mov          bh,al
1DDB:04E4 FB             sti
1DDB:04E5 89 D8          mov          ax,bx
1DDB:04E7 89 45 F8       mov          [di-08],ax
1DDB:04EA B8 00 00       mov          ax,0000
1DDB:04ED 00 00          add          [bx+si],al
1DDB:04EF 8B 5D FC       mov          bx,[di-04]
1DDB:04F2 C9             leave

Please review : 

Brennan's Guide to Inline Assembly
by Brennan "Bas" Underwood.

Att.
Diego.

-----Original Message-----
From: Cristiano [mailto:cristiano DOT pi AT NSquipo DOT it] 
Sent: Monday, January 23, 2006 09:34
To: djgpp AT delorie DOT com
Subject: Converting Intel code

I need to translate this (it should read the same timer used by Win API 
QueryPerformanceCount):

    unsigned short val;
    cli
    xor al,al
    out 43h,al
    in  al,40h
    mov bl,al
    in  al,40h
    mov bh,al
    mov [val],bx
    sti
    return val;

into AT&T syntax (for DJGPP). I wrote this:
asm(
  "cli\n\t"
    "xor %al,%al\n\t"
    "out %al,$0x43\n\t"
    "in  $0x40,%al\n\t"
    "mov %al,%bl\n\t"
    "in  $0x40,%al\n\t"
    "mov %al,%bh\n\t"
    "mov %bx,$val\n\t"
    "sti"
);
but I get: "Assembler messages: 20: Error: suffix or operands invalid
for 
`mov'".
Please, could somebody help me?

Thanks
Cristiano 



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.


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019