Code Golf: Code Golf: Difference between revisions

Add Uxntal
(Add Uxntal)
Line 698:
By using just a format specifier (56 characters):
<syntaxhighlight lang="sh">printf $(printf \\\\%o 67 111 100 101 32 71 111 108 102)</syntaxhighlight>
 
=={{header|Uxntal}}==
Using a "string literal" / raw ASCII rune (59 characters):
<syntaxhighlight lang="Uxntal">|0100 #0110 2194 06 #18 1720 fff7 #800f 1700 "Code 20 "Golf</syntaxhighlight>
Without raw ASCII runes (67 characters):
<syntaxhighlight lang="Uxntal">|0100 #0110 2194 06 #18 1720 fff7 #800f 1700 436f 6465 2047 6f6c 66</syntaxhighlight>
 
Both programs assemble to the same 26 byte ROM:
<pre>a001 1021 9406 8018 1720 fff7 a080 0f17
0043 6f64 6520 476f 6c66</pre>
 
The 9 byte string accounts for almost 35% of the final ROM.
 
The golfed code works very similarly to the following code:
<syntaxhighlight lang="Uxntal">|00 @System &vector $2 &expansion $2 &wst $1 &rst $1 &metadata $2 &r $2 &g $2 &b $2 &debug $1 &state $1
|10 @Console &vector $2 &read $1 &pad $4 &type $1 &write $1 &error $1
 
|0100
( get pointer to byte before str )
;str #0001 SUB2
@loop
( load a byte, pre-increment, and write it )
INC2 LDAk DUP .Console/write DEO
( loop again if the byte was non-null )
?loop
( exit )
#80 .System/state DEO
BRK
 
@str
"Code 20 "Golf 00</syntaxhighlight>
 
The main trick used in golfing of this program was to encode the raw instruction bytes in hex in the source code.
 
=={{header|Verilog}}==
57

edits