Autor Beitrag
Pr0g
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 220


D7 Pers
BeitragVerfasst: So 06.03.05 03:21 
Hallo,

ich habe einen kleinen BrainFuck Compiler geschrieben. Was soll ich noch groß dazu sagen, ein paar Beispielcodes liegen auch bei: Download (26.7Kb - .zip)

Einfach Programm starten, dann die Codedatei angeben und einen Namen für die .com Datei, das wars.

Wer nicht weiß was BrainFuck ist kann sich bei Wikipedia schlau machen: Link.


MfG Pr0g
Harry Hunt
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 50



BeitragVerfasst: So 06.03.05 13:54 
Hehe, selten einen passenderen Namen für eine Programmiersprache gehört.

Gute arbeit an dem compiler!
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: So 06.03.05 14:01 
könntest hier ma ein hallo welt prog für brainfuck posten ?
kann mir ned vorstellen wie man mit 8 befehlen ein komplexes programm erstellen kann...

_________________
es gibt leute, die sind genetisch nicht zum programmieren geschaffen.
in der regel haben diese leute die regel...
Pr0g Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 220


D7 Pers
BeitragVerfasst: So 06.03.05 14:04 
retnyg hat folgendes geschrieben:
könntest hier ma ein hallo welt prog für brainfuck posten ?
kann mir ned vorstellen wie man mit 8 befehlen ein komplexes programm erstellen kann...

Lad dir das Archiv doch runter, es liegen drei Beispielcodes (u.a. "Hallo Welt") bei. Zusätzlich aber auch noch zwei wohl komplexere Codes, auch wenn die "Beer"-Sache nicht so wirklich sinvoll erscheint :lol:

ausblenden Quelltext
1:
2:
Text "Hello World!" ausgeben:
++>++++++++++[-<+++++++>]<.+>+++++++[-<++++>]<.++>+++++[-<+>]<..+++.------->+++++++++[-<-------->]<.+>+++++++++[-<++++++>]<.+++>+++++++[-<+++>]<.+++.-->++++[-<->]<.>++++[-<-->]<.--->++++++++[-<-------->]<.,
delfiphan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2684
Erhaltene Danke: 32



BeitragVerfasst: So 06.03.05 14:24 
retnyg hat folgendes geschrieben:
kann mir ned vorstellen wie man mit 8 befehlen ein komplexes programm erstellen kann...


Brainfuck ist die kleinstmögliche Turingmaschine (abgesehen vom endlichen Speicher) oder einer der kleinsten. Damit lässt sich alles berechnen. Du kannst damit einen Sinus programmieren, Pi berechnen, und solche Sachen :)
Pr0g Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 220


D7 Pers
BeitragVerfasst: So 06.03.05 14:30 
Hier habe ich nochmal nen anderen Source rausgekram, welcher Primzahlen berechnet und vorher abfragt bis zu welcher Zahl dies gemacht werden soll, man kann also schon komplexe Dinge machen:
ausblenden volle Höhe Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
===================================================================
======================== OUTPUT STRING ============================
===================================================================
>++++++++[<++++++++>-]<++++++++++++++++.[-]
>++++++++++[<++++++++++>-]<++++++++++++++.[-]
>++++++++++[<++++++++++>-]<+++++.[-]
>++++++++++[<++++++++++>-]<+++++++++.[-]
>++++++++++[<++++++++++>-]<+.[-]
>++++++++++[<++++++++++>-]<+++++++++++++++.[-]
>+++++[<+++++>-]<+++++++.[-]
>++++++++++[<++++++++++>-]<+++++++++++++++++.[-]
>++++++++++[<++++++++++>-]<++++++++++++.[-]
>+++++[<+++++>-]<+++++++.[-]
>++++++++++[<++++++++++>-]<++++++++++++++++.[-]
>++++++++++[<++++++++++>-]<+++++++++++.[-]
>+++++++[<+++++++>-]<+++++++++.[-]
>+++++[<+++++>-]<+++++++.[-]

===================================================================
======================== INPUT NUMBER  ============================
===================================================================
+                          cont=1
[
 -                         cont=0
 >,
 ======SUB10======
 ----------
 
 [                         not 10
  <+>                      cont=1
  =====SUB38======
  ----------
  ----------
  ----------
  --------

  >
  =====MUL10=======
  [>+>+<<-]>>[<<+>>-]<     dup

  >>>+++++++++
  [
   <<<
   [>+>+<<-]>>[<<+>>-]<    dup
   [<<+>>-]
   >>-
  ]
  <<<[-]<
  ======RMOVE1======
  <
  [>+<-]
 ]
 <
]
>>[<<+>>-]<<

===================================================================
======================= PROCESS NUMBER  ===========================
===================================================================

==== ==== ==== ====
numd numu teid teiu
==== ==== ==== ====

>+<-
[
 >+
 ======DUP======
 [>+>+<<-]>>[<<+>>-]<

 >+<--

 >>>>>>>>+<<<<<<<<   isprime=1

 [
  >+

  <-

  =====DUP3=====
  <[>>>+>+<<<<-]>>>>[<<<<+>>>>-]<<<

  =====DUP2=====
  >[>>+>+<<<-]>>>[<<<+>>>-]<<< <


  >>>


  ====DIVIDES=======
  [>+>+<<-]>>[<<+>>-]<   DUP i=div
  
  <<
  [
    >>>>>+               bool=1
    <<<
    [>+>+<<-]>>[<<+>>-]< DUP
    [>>[-]<<-]           IF i THEN bool=0
    >>
    [                    IF i=0
      <<<<
      [>+>+<<-]>>[<<+>>-]< i=div
      >>>
      -                  bool=0
    ]
    <<<
    -                    DEC i
    <<
    -
  ]
  
  +>>[<<[-]>>-]<<          
  >[-]<                  CLR div
  =====END DIVIDES====


  [>>>>>>[-]<<<<<<-]     if divides then isprime=0


  <<

  >>[-]>[-]<<<
 ]

 >>>>>>>>
 [
  -
  <<<<<<<[-]<<

  [>>+>+<<<-]>>>[<<<+>>>-]<<<

  >>




  ===================================================================
  ======================== OUTPUT NUMBER  ===========================
  ===================================================================
  [>+<-]>
 
  [
   ======DUP======
   [>+>+<<-]>>[<<+>>-]<
  
  
   ======MOD10====
   >+++++++++<
   [
    >>>+<<              bool= 1
    [>+>[-]<<-]         bool= ten==0
    >[<+>-]             ten = tmp
    >[<<++++++++++>>-]  if ten=0 ten=10
    <<-                 dec ten     
    <-                  dec num
   ]
   +++++++++            num=9
   >[<->-]<             dec num by ten
  
   =======RROT======
      [>+<-]
   <  [>+<-]
   <  [>+<-]
   >>>[<<<+>>>-]
   <
  
   =======DIV10========
   >+++++++++<
   [
    >>>+<<                bool= 1
    [>+>[-]<<-]           bool= ten==0
    >[<+>-]               ten = tmp
    >[<<++++++++++>>>+<-] if ten=0 ten=10  inc div
    <<-                   dec ten     
    <-                    dec num
   ]
   >>>>[<<<<+>>>>-]<<<<   copy div to num
   >[-]<                  clear ten
  
   =======INC1=========
   <+>
  ]
  
  <
  [
   =======MOVER=========
   [>+<-]
  
   =======ADD48========
   +++++++[<+++++++>-]<->
  
   =======PUTC=======
   <.[-]>
  
   ======MOVEL2========
   >[<<+>>-]<
  
   <-
  ]
 
  >++++[<++++++++>-]<.[-]
 
  ===================================================================
  =========================== END FOR ===============================
  ===================================================================


  >>>>>>>
 ]
 <<<<<<<<



 >[-]<
  [-]
 <<-
]
 
======LF========
 
++++++++++.[-],
delfiphan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2684
Erhaltene Danke: 32



BeitragVerfasst: So 06.03.05 14:42 
Pr0g hat folgendes geschrieben:
man kann also schon komplexe Dinge machen

Ich denk mal man kann beweisen, dass man damit "alles" berechnen kann. Aber interessant ist das Programm allemal :) Interessant wäre ein "C2BF" oder "Pascal2BF" (Für Leute, die nichts Gescheiteres zu tun haben ;))
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: So 06.03.05 19:04 
delfiphan hat folgendes geschrieben:
Brainfuck ist die kleinstmögliche Turingmaschine

sehr interessant, diese maschine kannte ich bislang gar nicht.
Hier wirds aber gut erklärt (sogar mit selbstprogrammierbarer turingmaschine als java-aplett)

_________________
es gibt leute, die sind genetisch nicht zum programmieren geschaffen.
in der regel haben diese leute die regel...
Kernel32.dll
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: So 06.03.05 20:50 
Sehr hübsch...

Jetzt fehlt nur noch eine IDE und das eine Exe als Endprodukt herauskommt.... Und dann schreibe ich meinen nächsten MP3-Player in Brainfuck!! Der wird verdammt klein (von der Dateigröße her)... 8)
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: So 06.03.05 20:52 
naja... aber 572 byte für ein hello world programm ist relativ viel, mit assembler hats nur 21.
da schreib ich dann lieber den mp3 player in asm...

_________________
es gibt leute, die sind genetisch nicht zum programmieren geschaffen.
in der regel haben diese leute die regel...
stefan2005
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 29

Win XP, Win Vista
Delphi 6 Personal
BeitragVerfasst: Mo 07.03.05 09:33 
hi,
21 Bytes ?
da ist aber dann ohne Dateiheader !
wenn du nen MP3 Player mit Win-Fenster machen willst brauchst du einen Win32-Dateiheader und der braucht mindestens 1-2 KB (nur der Dateiheader!) !

cu,
stefan2005
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Mo 07.03.05 11:25 
natürlich ohne header, hier geht es um .com dateien.

_________________
es gibt leute, die sind genetisch nicht zum programmieren geschaffen.
in der regel haben diese leute die regel...
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Mo 07.03.05 13:13 
habe das ganze mal schnell nachgestellt... leider komme ich nur auf 22 bytes...
vielleicht habe ich damals das hallo welt mit einem L geschrieben...
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
E:\personal\ASM>debug hello.com
Datei nicht gefunden

-a
15BF:0100 mov ah,09
15BF:0102 mov dx,010b
15BF:0105 int 21h
15BF:0107 mov ah,4c
15BF:0109 int 21h
15BF:010B db 'h4ll0 w3lt$'
15BF:0116
-r cx
CX 0000
:16
-w
00016 Bytes werden geschrieben.
-q

E:\personal\ASM>hello
h4ll0 w3lt
E:\personal\ASM>dir hello.com
 Datenträger in Laufwerk E: ist data
 Volumeseriennummer: 4C48-808B

 Verzeichnis von E:\personal\ASM

07.03.2005  13:12                22 HELLO.COM
               1 Datei(en)             22 Bytes
               0 Verzeichnis(se), 150.951.464.960 Bytes frei

_________________
es gibt leute, die sind genetisch nicht zum programmieren geschaffen.
in der regel haben diese leute die regel...