Jump to content

View more

Image of the Day

Inventory ! Va falloir trouver une autre couleur pour le cadre D: #AzTroScreenshot #screenshotsaturday https://t.co/PvxhGL7cOH
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Immediate values come from the ALU?

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
6 replies to this topic

#1 gasto   Members   

303
Like
-1Likes
Like

Posted 24 February 2014 - 03:29 PM

Are immediate values extracted from the ALU(Arithmetic logic unit)?

 

More code seems to be created (and hence program file size) when using many immediate values, but I assume it is stored in the program duration memory stack.


Intel Core 2 Quad CPU Q6600, 2.4 GHz. 3GB RAM. ATI Radeon HD 3400.

#2 Paradigm Shifter   Members   

5832
Like
6Likes
Like

Posted 24 February 2014 - 03:41 PM

*
POPULAR

They are embedded in the machine code opcodes. On a CISC architecture they follow the opcode whereas on a RISC processor where all instructions are the same size some of the bits in the opcode are used for parts of the immediate value (so in 32 bit RISC architecture loading a 32 bit immediate value needs 2 instructions, one to load 16 bits and zero the other half of a 32 but register and another to logical-OR in the other 16 bits to the register). Static memory locations are immediate values too (kind of), but accessing values from registers (e.g. the stack pointer) uses indexed addressing (something like: load reg, contents of (sp+8)), so are usually shorter since the offset is usually restricted in range (-128 to +127, perhaps).


"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

#3 Álvaro   Members   

20926
Like
3Likes
Like

Posted 24 February 2014 - 04:16 PM

Why is this thread tagged "C Language" and "C++"? I am pretty sure in the context of those languages there is no such thing as an ALU, and even "immediate value" is a foreign concept (although there are constants, which are related).



#4 gasto   Members   

303
Like
-2Likes
Like

Posted 24 February 2014 - 04:42 PM

It's assembly. Some people use assembly in C and C++.


Intel Core 2 Quad CPU Q6600, 2.4 GHz. 3GB RAM. ATI Radeon HD 3400.

#5 Paradigm Shifter   Members   

5832
Like
0Likes
Like

Posted 24 February 2014 - 04:57 PM

ALU is electronics though?


"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

#6 frob   Moderators   

44041
Like
4Likes
Like

Posted 24 February 2014 - 07:37 PM

This is an implementation detail that doesn't matter.

As far as the assembly programmer is concerned the data resides in a register or a memory address. When something is processed inside the CPU the black box does its magic, and the result is again stored in a register or memory address.

If you are an expert writing the optimizer inside a major compiler, and if you have studied the exact micro-architecture details, including a detailed study of the processor's internal timings, then it is possible that those details might help you with some extreme pigeonhole reordering optimizations in order to save one or two total CPU cycles, so perhaps it might save a few nanoseconds.

It has nothing to do with either C or C++ languages, and really almost has nothing to do with assembly programming.

Check out my book, Game Development with Unity, aimed at beginners who want to build fun games fast.

Also check out my personal website at bryanwagstaff.com, where I occasionally write about assorted stuff.


#7 King Mir   Members   

2490
Like
1Likes
Like

Posted 25 February 2014 - 01:10 AM

Immediate values in assembly are stored as part of the encoding of an instruction. For variable length instruction architectures, it may be that an instruction containing an immediate value has a longer encoding, than it's register or memory counterparts.




Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.