I just don't get what this is doing. All of these lines with semi-colons generate no difference in the final code. And now I have discovered `splint`, which is a type of lint checker for C and it does protest the use of "variable;" as being useless and generating no code. It seems a good deal, but has some problems with headers that I use commonly. `sudo apt-get install splint`. I can work around that and I have a new method to let the program analyze the quality and effectiveness of the code.
int main() {
char *genesis;
genesis;
main;
apoptosis;
slinky:
goto slinky;
return 0;
}
I did not realize that suicide was a word in my code and it refers to apoptosis, which is a cellular mechanism and it was not intended to be morbid. It was just a reference to programmed cell death. In the example below, I can't figure out what "variable;" means generically and in this case "genesis;".
int main() {
char *genesis=NULL;
slinky:
goto slinky;
genesis;
return 0;
}
This is the section of the source creator which compiles the putative[1] code. In this example I mangled the lists of possible names and forced it to include several things, so it would be more understandable. The code generated can be very odd at times. This is likely to be the generic format of a baseline code and the rest of the procedures will be flexible, while keeping this general form as the starting point. I have already started enforcing style constraints and that was actually very easy.
char libs[]=" -lGL -lglut -lm -ldl ";
char cflags[]=" -Wall -W -pedantic -g -rdynamic -ansi -D_GNU_SOURCE ";
sprintf(sysCmd,"gcc %s HelloWorld.c HelloWorld_sighandler.o %s -o HelloWorld 2>&1",cflags,libs);
This is the most recent code and its shasum and reference in the file of all error free compiles. The shasum is stored with the code, and the code is represented as a string of integers which define an order of application of rules, words, options, methods, and inclusions.
61d6ffd5ce9d6d99ccde694b0edddaec4b078a0f HelloWorld
-rwxr-xr-x 1 moteyhardy plugdev 22239 2009-12-24 18:06 HelloWorld
#include "HelloWorld.h"
int apoptosis(char *suicide){
uint8_t impossible;
impossible=(uint8_t)*suicide;
return 0;
}
int main( int argc , char * argv[] ) {
char *suicide=NULL;
char *argvs;
argvs=argv[0];
apoptosis(suicide);
return argc;
}
Below is the interaction between main and apoptosis. I have chosen a very simple sample, but the code is already getting quite complex as it learns what order and association that the parts must take to get a completed compile. It draws from examples and in this case I have initiated the code with apoptosis built in as a pre-requisite and if it does not duplicate before apoptosis, it fades into oblivion. By compiling and identifying and deciphering the first line where an error occurs it can take random code and push it toward a valid compile by substitution of elements from a set of possible elements that is appropriate in that context.
objdump --start-address=0x400e11 --stop-address=0x400e43
-j .text -s -d HelloWorld>>MyPrograms.c
HelloWorld: file format elf64-x86-64
Contents of section .text:
400df8 554889e5 48897de8 488b45e8 0fb60088 UH..H.}.H.E.....
400e08 45ffb800 000000c9 c3554889 e54883ec E........UH..H..
400e18 20897dec 488975e0 48c745f8 00000000 .}.H.u.H.E.....
400e28 488b45e0 488b0048 8945f048 8b7df8e8 H.E.H..H.E.H.}..
400e38 bcffffff 8b45ecc9 c39090 .....E.....
Disassembly of section .text:
0000000000400df8 :
400df8: 55 push %rbp
400df9: 48 89 e5 mov %rsp,%rbp
400dfc: 48 89 7d e8 mov %rdi,-0x18(%rbp)
400e00: 48 8b 45 e8 mov -0x18(%rbp),%rax
400e04: 0f b6 00 movzbl (%rax),%eax
400e07: 88 45 ff mov %al,-0x1(%rbp)
400e0a: b8 00 00 00 00 mov $0x0,%eax
400e0f: c9 leaveq
400e10: c3 retq
0000000000400e11 :
400e11: 55 push %rbp
400e12: 48 89 e5 mov %rsp,%rbp
400e15: 48 83 ec 20 sub $0x20,%rsp
400e19: 89 7d ec mov %edi,-0x14(%rbp)
400e1c: 48 89 75 e0 mov %rsi,-0x20(%rbp)
400e20: 48 c7 45 f8 00 00 00 movq $0x0,-0x8(%rbp)
400e27: 00
400e28: 48 8b 45 e0 mov -0x20(%rbp),%rax
400e2c: 48 8b 00 mov (%rax),%rax
400e2f: 48 89 45 f0 mov %rax,-0x10(%rbp)
400e33: 48 8b 7d f8 mov -0x8(%rbp),%rdi
400e37: e8 bc ff ff ff callq 400df8
400e3c: 8b 45 ec mov -0x14(%rbp),%eax
400e3f: c9 leaveq
400e40: c3 retq
400e41: 90 nop
400e42: 90 nop
It is very similar to the `einstein` puzzle solutions as elements must be taken from a set, they are ordered, and the hints imply a certain correlation between elements. I have not yet gotten the needed parts to allow the code to do Google searches for common usage and try that as options, but I will implement that tonight , I think. The data from Google can provide a general indication of the association in parts of the code, such as variable typing or common structure types to use with library functions.
I am continually changing the methods to find the best starting point and this makes it easy, as I never write any code, I just provide direction and generic tools which can be applied in any order and the products are always interesting, because they have a randomness that develops things and relationships that I would get frustrated trying to test. It can compile 40,000 bad versions to get one good and never gets bored.
And here I added some fluff to speak some things when it generates code which has the same shasum. I know I should have "cased" this , but it started with one and grew from there to increase the entertainment value.
i=(int)(rand()%15);
if ( i == 0 ){sprintf(sysCmd,"espeak 'Boring stuff.'");}
if ( i == 1 ){sprintf(sysCmd,"espeak 'I have Been there. Done that.'");}
if ( i == 2 ){sprintf(sysCmd,"espeak 'Tell me something I do not know.'");}
if ( i == 3 ){sprintf(sysCmd,"espeak 'I have seen that before.'");}
if ( i == 4 ){sprintf(sysCmd,"espeak 'Really boring crap.'");}
if ( i == 6 ){sprintf(sysCmd,"espeak 'I would rather be playing Half Life Two or Portal.'");}
if ( i == 9 ){sprintf(sysCmd,"espeak 'Even I am getting bored now. '");}
if ( i == 7 ){sprintf(sysCmd,"espeak 'Who thinks up this tripe? '");}
if ( i == 8 ){sprintf(sysCmd,"espeak 'Do you have a plan or are you just thrashing around aimlessly? '");}
if ( i == 5 ){sprintf(sysCmd,"espeak 'Can I take a break.'");}
if ( i == 10){sprintf(sysCmd,"espeak 'I already did that before.'");}
if ( i == 11){sprintf(sysCmd,"espeak 'That has been written.'");}
if ( i == 12){sprintf(sysCmd,"espeak 'Really, that is not new.'");}
if ( i == 13){sprintf(sysCmd,"espeak 'Really cool, but repetitive.'");}
if ( i == 14){sprintf(sysCmd,"espeak 'Wow, did you get that on the internet?'");}
system(sysCmd);
Definition of putative Commonly believed to be true on inconclusive grounds.