Archives
 
 
 
  Special
 
 
 
  About Us
 
 
 

Newsletter
Free E-mail Newsletter from BYTE.com

 
    
           
Visit the home page Browse the four-year online archive Download platform-neutral CPU/FPU benchmarks Find information for advertisers, authors, vendors, subscribers Request free information on products written about or advertised in BYTE Submit a press release, or scan recent announcements Talk with BYTE's staff and readers about products and technologies

ArticlesProgramming for MMX


September 1996 / Inbox / Programming for MMX

Tom Halfhill's "x86 Enters the Multimedia Era" (July CPU column) was very informative. However, a problem he describes might not be real. On page 60 he says that "Programmers can use MMX and FP (floating-point) instructions in the same program, but they'd better not mix them because both kinds of instructions need the same registers"; and that multimedia developers "should segregate MMX instructions in a subroutine or library that's called only after probing the chip's CPU_ID to verify that it supports MMX." The first statement must have been directed to programmers writing compilers or x86-specific assembly-language (or machine-language) library routines. Programmers using a compiler or smart assembler that can generate code properly for an MMX-equipped CPU would not have to be aware of this: The tool would save and restore regis ter contents properly to reuse the registers. Possibly, the programmer would only have to know to use the proper tool option for the target CPU. At run time, the library routines would do the CPU probing. I don't think one should assume a priori that a programmer would never want to execute a mixture of MMX and FP instructions on the same register data. Computing hardware-control-register mask bits might require it.

John Michael Williams, Ph.D.
Redwood City, CA

Unfortunately, no compilers currently available have high-level language support for MMX. To use MMX, programmers must embed in-line assembly code into their C or C++ source code. It's the programmer's responsibility to manage the x86 registers shared by MMX and FP instructions. If the programmer doesn't clear the MMX registers (by using the Empty MMX State instruction) before executing an FP operation, the results could be disastrous. Even if compilers do eventually provide high-l evel support for MMX, it would have to be an awfully smart compiler to reschedule FP instructions that a programmer carelessly mixed into an MMX routine. It's unlikely that MMX and FP instructions would need to operate on the same register data; they use the registers in different ways. FP instructions see a push-pull stack of 80-bit FP values; MMX instructions see a random-access file of 64-bit integer values. However, x86 programmers are infamous for their crazy coding, so I suppose anything's possible. -- Tom R. Halfhill, senior editor


Up to the Inbox section contentsGo to previous article: E-Cash Ain't Nothin' But Trash?Go to next article: What, No FoxPro?SearchSend a comment on this articleSubscribe to BYTE or BYTE on CD-ROM  
Flexible C++
Matthew Wilson
My approach to software engineering is far more pragmatic than it is theoretical--and no language better exemplifies this than C++.

more...

BYTE Digest

BYTE Digest editors every month analyze and evaluate the best articles from Information Week, EE Times, Dr. Dobb's Journal, Network Computing, Sys Admin, and dozens of other CMP publications—bringing you critical news and information about wireless communication, computer security, software development, embedded systems, and more!

Find out more

BYTE.com Store

BYTE CD-ROM
NOW, on one CD-ROM, you can instantly access more than 8 years of BYTE.
 
The Best of BYTE Volume 1: Programming Languages
The Best of BYTE
Volume 1: Programming Languages
In this issue of Best of BYTE, we bring together some of the leading programming language designers and implementors...

Copyright © 2005 CMP Media LLC, Privacy Policy, Your California Privacy rights, Terms of Service
Site comments: webmaster@byte.com
SDMG Web Sites: BYTE.com, C/C++ Users Journal, Dr. Dobb's Journal, MSDN Magazine, New Architect, SD Expo, SD Magazine, Sys Admin, The Perl Journal, UnixReview.com, Windows Developer Network