dim as integer i
dim as string q=chr(34),c(2)={chr(44)+chr(95),chr(125)},Array(11)={_
"dim as integer i",_
"dim as string q=chr(34),c(2)={chr(44)+chr(95),chr(125)},Array(11)={_",_
"for i=0 to 1",_
" print Array(i)",_
"next i",_
"for i=0 to 10",_
" print q+Array(i)+q+c(iif(i=10,1,0))",_
"next i",_
"for i=2 to 10",_
" print Array(i)",_
"next i"}
for i=0 to 1
print Array(i)
next i
for i=0 to 10
print q+Array(i)+q+c(iif(i=10,1,0))
next i
for i=2 to 10
print Array(i)
next i
I'm no ASM expert. Most of my knowledge I got from a script from Prof. Wüst, Fachhochschule Gießen-Friedberg (sorry, I've no link). You may follow the links on the wikipedia sites.
This line calculates the length of the file (= STRING). The '.' is the current pointer, '__code__start' is the pointer before the 'incbin' statement and the difference is the length.
BTW: it still works if you edit the source code (ie add some comments).
Even though I don't know assembly, from looking at this and guessing, it looks like you're extracting the source from memory. I find these types of quines less interesting because the source isn't being copied from within it's own source code. These are considered cheats, like this Basic version:
10 LIST
TJF wrote:Even though I don't know assembly, from looking at this and guessing, it looks like you're extracting the source from memory. I find these types of quines less interesting because the source isn't being copied from within it's own source code. These are considered cheats, like this Basic version:
10 LIST
The version
10 LIST
only works in interpreters that support the LIST statement -- not in a compiler like FB.
But you're right, my solution is a fake. It reads the source code file in to the data section of the binary and prints it on run-time. Sorry, IMHO writing code that reproduces itself makes not realy sense ; )