www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/02/12/05:44:09

From: "Michael Beck" <beck AT dgroup DOT de>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: My inline assembly program won't work.
Date: 11 Feb 1997 17:33:21 GMT
Organization: DResearch
Lines: 82
Message-ID: <01bc1841$ad236490$8942ddc2@franc>
References: <32FF3ECC DOT 36F AT xs4all DOT nl>
NNTP-Posting-Host: master.dgroup.de
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Andrei 'old-boy' Ellman <ellman AT xs4all DOT nl> wrote in article
<32FF3ECC DOT 36F AT xs4all DOT nl>...
> Hi,
> 
> I have been trying to assemble the following .c file with some inline
> assembly, and I can't get it to work. What I am trying to do is to
> compile the following:

[...]

> 	asm (
> 
> 		"pushw %%fs;"
> 		"movw __dos_ds, %%fs;"	// [*1]

_dos_ds is a macro, expanding to
_go32_info_block.selector_for_linear_memory,  but it is NOT expanded in the
inline-asm,
because it's a string!

> 		"movl $15996, %%ecx;"	// $15996 = (320*200/4)-4
> 
> 		"LOOP:"
> 
> 		"movl (%0,%%ecx,4), %%eax;"
> 		"orl (%1,%%ecx,4), %%eax;"
> 		"orl (%2,%%ecx,4), %%eax;"
> 
> 		"movl %%eax, %%fs:$0xa0000(,%%ecx,4);"	// [*2]
prefix is a single instruction in inline-asm!
> 
> 		"decl %%ecx;"
> 		"jns LOOP;"
> 
> 		"popw %%fs;"
> 
> 	:
> 
> 	:
> 
> 		"r" (bmp1_read_address),
> 		"r" (bmp2_read_address),
> 		"r" (bmp3_read_address)
> 	:
> 		"%eax",	// Where the longwords are ored together
> 		"%ecx"	// Counter.
> 	);
> 

Try this:
 	asm (
 
 		"pushw %%fs;"
 		"movw %3, %%fs;"	// [*1]
 		"movl $15996, %%ecx;"	// $15996 = (320*200/4)-4
 
 		"LOOP:"
 
 		"movl (%0,%%ecx,4), %%eax;"
 		"orl (%1,%%ecx,4), %%eax;"
 		"orl (%2,%%ecx,4), %%eax;"
 
 		"fs ; movl %%eax, $0xa0000(,%%ecx,4);"	// [*2]
 
 		"decl %%ecx;"
 		"jns LOOP;"
 
 		"popw %%fs;"
 
 	:
 	:
 		"r" (bmp1_read_address),
 		"r" (bmp2_read_address),
 		"r" (bmp3_read_address),
		"m"(_dos_ds)
 	:
 		"ax",	// Where the longwords are ored together
 		"cx"	// Counter.
 	);
 
--
Michael Beck                        beck AT dgroup DOT de

- Raw text -


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