flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > Methods to reduce source code characters? |
Author |
|
bitRAKE 23 Nov 2010, 08:53
Many contests ask for smallest source code characters as a winning metric. I know assembly language has a snowball's chance in hell of competing with scripting languages in this regard. Anyhow, I'd like to address the problem: Which methods can be used to compact the source code?
! fix EQU ; because many are needed M ! MOV ; for common instructions Is there a way to create a recursive macro to put multiple instructions on one line? Code: ; note: extra white space for readability macro A [B] {common match C|D,B \{ C A D \} } Any other ideas? Might create a tool to analyze source code and produce smallest compaction. And you thought assembly was hard to read already. Here I'll collect a list of example contests: http://stackoverflow.com/questions/2527477/code-golf-connecting-the-dots/ ...to be continued... _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup Last edited by bitRAKE on 23 Nov 2010, 09:52; edited 2 times in total |
|||
23 Nov 2010, 08:53 |
|
Frank 23 Nov 2010, 09:04
UNTESTED: Compress the source (zip, rar, whatever), convert the result into a single 'db' line, and decompress it with a macro at assemble-time.
|
|||
23 Nov 2010, 09:04 |
|
bitRAKE 23 Nov 2010, 09:26
This is for coding contests.
I know it's not practical. Need to send code directly to FASM. It might be possible to write a very small decompression algorithm in FASM syntax: Code: dq $XXXXXXXXXXXXXXXX,... i=$ rb ? j=$ while i>0 if ? i=i-1 load b byte from i end if ... j=j-1 store byte c at j end while Edit: that wouldn't work. the compressed code needs to be assembled and the assembler can't do that with a single execution. Decompression would just generate the source code and not assembler it. |
|||
23 Nov 2010, 09:26 |
|
Tomasz Grysztar 23 Nov 2010, 10:39
bitRAKE wrote: Is there a way to create a recursive macro to put multiple instructions on one line? There is also this tweak of fasm's core to allow multiple instructions in a row, but I guess you aim at standard fasm syntax here... |
|||
23 Nov 2010, 10:39 |
|
bitRAKE 23 Nov 2010, 10:58
Very nice,
Code: macro A { macro B [C] \{ common match D|E,C \\{ A D B E \\} \} } A B cdq|xchg eax,ecx|| |
|||
23 Nov 2010, 10:58 |
|
baldr 24 Nov 2010, 19:54
bitRAKE,
m equ mov can give you another idea. Measuring program by its source size is like measuring seam by length of needle used to sew it. |
|||
24 Nov 2010, 19:54 |
|
rugxulo 30 Nov 2010, 22:38
Never tried Octasm?
|
|||
30 Nov 2010, 22:38 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.