Article View: comp.os.msdos.programmer
Article #3628Re: 386 Assembler Question - Easy one...
From: Keith L. Petry
Date: Thu, 12 Nov 1992 14:53
Date: Thu, 12 Nov 1992 14:53
41 lines
1865 bytes
1865 bytes
In article <1992Nov11.114831.6643@ufhx1.ufh.ac.za>, cssjs2@ufhx1.ufh.ac.za (Mr I Scheepers) writes:
|> In <1992Nov9.162931.1@camins.camosun.bc.ca> morley@camins.camosun.bc.ca writes:
|> >In 386 assembler I need to fill an extended register with 4 copies
|> >of the same byte. Right now I'm using the following:
|>
|> > mov al,VALUE
|> > mov ah,VALUE
|> > shl eax,16
|> > mov al,VALUE
|> > mov ah,VALUE
|>
|> >I'm curious... is there a better/faster way to stuff the register?
|>
|> How about:
|> mov al,VALUE
|> mov ah,al
|> mov eax,ax
^
----------- This last statement does nothing eax and ax
are the same register.
How about :
mov bl, VALUE
mov al, bl
mov ah, bl
shl eax, ax
mov al, bl
mov ah, bl
This will be faster because you have your data in the bl register.
Instead of doing a memory fetch 4 times, you only memory fetch once.
And all the actions occur internal to the x86 chip.
Let me just say one other thing though. If you have a 486 then the first
answer is as good as mine, because the 486 has an internal cache and this
is as good as using a internal register. If you are running on a 386 my
answer is faster.
Keith
Technical Details
Message-ID:
<1992Nov12.145342.17642@merlin.dev.cdx.mot.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!panther!mothost!merlin.dev.cdx.mot.com!keithpReferences:
<1992Nov9.162931.1@camins.camosun.bc.ca> <1992Nov11.114831.6643@ufhx1.ufh.ac.za>Show Full Headers
Complete Article Headers
Newsgroups: comp.os.msdos.programmer Path: arc1-ca.pugleaf.net!sparky!uunet!panther!mothost!merlin.dev.cdx.mot.com!keithp From: keithp@merlin.dev.cdx.mot.com (Keith L. Petry) Subject: Re: 386 Assembler Question - Easy one... Message-ID: <1992Nov12.145342.17642@merlin.dev.cdx.mot.com> Originator: keithp@melkur.dev.cdx.mot.com Sender: news@merlin.dev.cdx.mot.com (USENET News System) Nntp-Posting-Host: melkur.dev.cdx.mot.com Organization: Motorola Codex, Canton, MA References: <1992Nov9.162931.1@camins.camosun.bc.ca> <1992Nov11.114831.6643@ufhx1.ufh.ac.za> Date: Thu, 12 Nov 1992 14:53:42 GMT Lines: 42