Go Back   Project64 Forums > General Discussion > Open Discussion

Reply
 
Thread Tools Display Modes
  #51  
Old 21st June 2013, 02:38 PM
MarathonMan's Avatar
MarathonMan MarathonMan is offline
Alpha Tester
Project Supporter
Senior Member
 
Join Date: Jan 2013
Posts: 454
Default

Quote:
Originally Posted by FatCat View Post
He seems to have applied:

x = (a - b);
x -= (a - b)/4;

so in other words,

x = (a - b)>>2 * 3,
which would have done an LEA like you mentioned by adding twice its current value to itself.

I don't know the answer to this myself but I'm guessing this is equally as satisfactory for the job?

If not, it will most likely compile into what we wrote instead, as it seems more than similar enough.
leal can be used to compute any form of x+k*y where k = {1,2,4,8}.

So in that case, you'd just do:
temp = (a - b) >> 2
lea (temp, temp, 2), result

EDIT: If my order of operations is correct, which it may not be.
Reply With Quote
  #52  
Old 21st June 2013, 02:41 PM
HatCat's Avatar
HatCat HatCat is offline
Alpha Tester
Project Supporter
Senior Member
 
Join Date: Feb 2007
Location: In my hat.
Posts: 16,256
Default

Heh, why would you write "leal"?

Isn't that just the GNU suffix for word-size explicit operation mark syntax?

I don't mind that GNU impl of AT&T assembly syntax has its own style, but I hate the idea of having an extra letter added at the end of the opcodes lol.
It just seems more readable to me to use documented opcode names.
Reply With Quote
  #53  
Old 21st June 2013, 06:49 PM
MarathonMan's Avatar
MarathonMan MarathonMan is offline
Alpha Tester
Project Supporter
Senior Member
 
Join Date: Jan 2013
Posts: 454
Default

Quote:
Originally Posted by FatCat View Post
Heh, why would you write "leal"?

Isn't that just the GNU suffix for word-size explicit operation mark syntax?

I don't mind that GNU impl of AT&T assembly syntax has its own style, but I hate the idea of having an extra letter added at the end of the opcodes lol.
It just seems more readable to me to use documented opcode names.
It's the superior AT&T syntax (not GNU). Each instruction has a suffix {b,w,l,q} to denote the size of the operands so that you don't have to stare at the actual registers to figure out the operand size.

Hence why I say movzbl instead of movz.
Reply With Quote
  #54  
Old 21st June 2013, 06:57 PM
HatCat's Avatar
HatCat HatCat is offline
Alpha Tester
Project Supporter
Senior Member
 
Join Date: Feb 2007
Location: In my hat.
Posts: 16,256
Default

I didn't know it reached that standardization level.

I can't help but think, it would be easier to read if it was like, movzbL or MOVZBl, but both of those look ugly anyway.

I thought it was easy to tell just by looking at the registers though.
Basically if it's %r-something, it's 64-bit. %e-something is 32-bit, %*h or %*l are 8-bit and...those are usually the ones we'd typically see in compiler output I think.
Reply With Quote
  #55  
Old 21st June 2013, 07:11 PM
MarathonMan's Avatar
MarathonMan MarathonMan is offline
Alpha Tester
Project Supporter
Senior Member
 
Join Date: Jan 2013
Posts: 454
Default

Quote:
Originally Posted by FatCat View Post
I didn't know it reached that standardization level.

I can't help but think, it would be easier to read if it was like, movzbL or MOVZBl, but both of those look ugly anyway.

I thought it was easy to tell just by looking at the registers though.
Basically if it's %r-something, it's 64-bit. %e-something is 32-bit, %*h or %*l are 8-bit and...those are usually the ones we'd typically see in compiler output I think.
That logic falls apart when you start to use memory operands. Then you have to start sticking WORD and whatnot in your instructions and it looks awful.

I find it much easier on the eyes and brain to look at the end of the instruction and just see a single character denoting the operand size.
Reply With Quote
  #56  
Old 21st June 2013, 07:43 PM
HatCat's Avatar
HatCat HatCat is offline
Alpha Tester
Project Supporter
Senior Member
 
Join Date: Feb 2007
Location: In my hat.
Posts: 16,256
Default

Well the real thing I don't like about doing that, is that the types are misleading after IA-16.

On 32-bit and 64-bit Intel they're all still the same thing.

WORD is 16 bits, not 64.
DWORD is 32 bits, not 128.

Granted there are undoubtedly Intel-syntax assemblers that don't use those constructs, but I haven't put a lot of practice into the issue myself.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT. The time now is 05:46 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.