ftp.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/02/23/19:48:48

Date: Thu, 23 Feb 1995 18:58:25 -0500 (EST)
From: Long Doan <ldoan1 AT osf1 DOT gmu DOT edu>
To: Michael Phelps <morphine AT whatever DOT cs DOT jhu DOT edu>
Cc: djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: Re: Inline asm and structs

On Thu, 23 Feb 1995, Michael Phelps wrote:

> 	long	x;
> 
> 	asm(
> 	"movl	$0, _x\n"
> 	::);
> 
> (provided x is global/static), but how can I do the equivalent of C
> 
> typedef struct
> {
> 	long	first;
> 	long	second;
> } vector;
> 
> vector	data[10];
> 
> for (x=0; x < 10; x++)
> {
> 	data[x].first = 0;
> }

I'm not sure if this works, but give it a try:

  asm ("\n\
        push %eax               \n\
        push %ebx               \n\
        push %ecx               \n\
        movl _data, %ebx        \n\
        xorl %eax, %eax         \n\
        xorl %ecx, %ecx         \n\
L_jump_label:                   \n\
        movl $0x0, (%ebx, %eax,)\n\
        addl $0x8, %eax         \n\
        addl $0x1, %ecx         \n\
        cmp  $0xa, %ecx         \n\
        jnz  L_jump_label       \n\
        pop  %ecx               \n\
        pop  %ebx               \n\
        pop  %eax               \n\
       ");

Hope that helps,
Long.
         

+--------------------------------------------------------+
| Long Doan                          ldoan1 AT osf1 DOT gmu DOT edu |
|                                          ld AT netrix DOT com |
+--------------------------------------------------------+


- Raw text -


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