Useless instructions: Difference between revisions

Added Algol 68
(Added C)
(Added Algol 68)
Line 23:
=={{header|8086 Assembly}}==
<code>xor ax,ax</code> (or any other data register) takes fewer bytes to encode than <code>mov ax,0</code> and achieves the same result. The only difference is that <code>mov ax,0</code> doesn't set the flags, which can be used to the programmer's advantage when sequencing operations.
 
=={{header|ALGOL 68}}==
{{works with|ALGOL 68G|Any - tested with release 2.8.3.win32}}
As well as being able to write <code>IF TRUE THEN SKIP ELSE some code that will never be executed FI</code> and <code>WHILE FALSE DO some code that will never be executed OD</code>, as in other languages shown here, Algol 68 has a feature that was presumably intended to aid portability (though whether it does in practice is another matter...):<br>
Algol 68 has a notionally infinite number of integer, real and comples types. THe standard types INT, REAL and COMPL, can have an arbitrary number of LONG or SHORT prefixes to indicate larger or smaller types. Whether these are actually larger or smaller depends on the implementation - no warning is issued (at least, not in Algol 68G) to indicate that e.g. LONG LONG LONG REAL is not longer than LONG LONG REAL. In addition, there are "environment enquiries" that will reveal how big the types are, so e.g. max int is the largest INT value, long max int is the largest LONG INT value, etc. An arbitrary number of long and short prefixes can be applied.<br>
As this sample shows, Algol 68G has only three sies of integer. The precission of LONG LONG INT can be specified by a pragmatic comment. The value shown here is the default.<br>
(Interestingly, I always assumed Algol 68G's LONG INT was 64 bits but I see this isn't so...)
<lang algol68>print( ( long long long max int, newline ) );
print( ( long long max int, newline ) );
print( ( long max int, newline ) );
print( ( max int, newline ) );
print( ( short max int, newline ) );
print( ( short short max int, newline ) );
print( ( short short short max int, newline ) );
print( ( short short short short short short short short short short
short short short short short short short short short short
short short short short short short short short short short
short short short short short short short short short short
short short short short short short short short short short max int, newline ) )</lang>
{{out}}
<pre>
+9999999999999999999999999999999999999999999999999999999999999999999999
+9999999999999999999999999999999999999999999999999999999999999999999999
+99999999999999999999999999999999999
+2147483647
+2147483647
+2147483647
+2147483647
+2147483647
</pre>
 
=={{header|C}}==
3,044

edits