flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > Quines : Progams that copy themselves

Author
Thread Post new topic Reply to topic
bitRAKE



Joined: 21 Jul 2003
Posts: 4359
Location: vpcmpistri
bitRAKE 22 Jan 2026, 07:25
In fasmg not only does an empty file copy itself, but "file __FILE__" also copies itself. Moving beyond these trivial examples (305 bytes):
Code:
virtual
A::db 'virtual|A::db ~|end virtual|repeat sizeof A|load a:1 from A:%-1|if a=7Eh|load a:%% from A:0|db 27h,a,27h|else if a=7Ch|db 10|else|db a|end if|end repeat'
end virtual
repeat sizeof A
load a:1 from A:%-1
if a=7Eh
load a:%% from A:0
db 27h,a,27h
else if a=7Ch
db 10
else
db a
end if
end repeat    
... you'll need to use Unix (10) line endings. Basically, a tag character is used to self-copy within the string of bytes, and a few exceptions are handled. Greater explanation is probably best done by another's video (he also explains how trojans can be hidden in compilers).

(Of course, a smaller version is possible - down to 291.)

_________________
¯\(°_o)/¯ AI may [not] have aided with the above reply.
Post 22 Jan 2026, 07:25
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8501
Location: Kraków, Poland
Tomasz Grysztar 22 Jan 2026, 10:10
How about something more unique to fasmg?
Code:
a
macro a
calminstruction ?!n&
match,n
jyes x
take m,m
arrange m,n
stringify m
emit lengthof m,m
emit 1,10
jno x
assemble n
x:
end calminstruction
a
end macro    
Post 22 Jan 2026, 10:10
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4359
Location: vpcmpistri
bitRAKE 22 Jan 2026, 12:11
That's bonkers - yet, insightful.

Three distinctly different corner cases.
Post 22 Jan 2026, 12:11
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2026, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.