Author |
Topic: hello, world (Read 803 times) |
|
David Williams
Developer
member is offline

meh

Gender: 
Posts: 452
|
 |
hello, world
« Thread started on: Aug 15th, 2008, 2:48pm » |
|
PRINT "hello, world"
|
|
Logged
|
|
|
|
Michael Hutton
Developer
member is offline


Gender: 
Posts: 248
|
 |
Re: hello, world
« Reply #1 on: Aug 20th, 2008, 08:55am » |
|
OR
Code:
REM
REM A Machine Code "Hello World"
REM
DIM code% 47
FOR pass%=0 TO 2 STEP 2
P%=code%
[
OPT pass%
.helloworld
call WriteInlineString
db "Hello World"
db 0
ret
;REM by Jon Ripley
.WriteInlineString
xchg eax,[esp]
push edx
mov edx,eax
.Writeloop
mov al, [edx]
inc edx
cmp al,0
jz Writeend
call "oswrch"
jmp Writeloop
.Writeend
mov eax,edx
pop edx
xchg eax,[esp]
ret
]
NEXT pass%
CALL helloworld
|
|
|
|
David Williams
Developer
member is offline

meh

Gender: 
Posts: 452
|
 |
Re: hello, world
« Reply #2 on: Aug 21st, 2008, 05:32am » |
|
on Aug 20th, 2008, 08:55am, Michael Hutton wrote:

Well, thank goodness for high level languages, eh!
Apart from displaying the famous message, it also displays Jon's talent for elegant code (my attempt at the same thing wouldn't be anywhere near as pretty as that).
Regards,
David.
|
|
|
|
David Williams
Developer
member is offline

meh

Gender: 
Posts: 452
|
 |
Re: hello, world
« Reply #3 on: Aug 21st, 2008, 06:19am » |
|
Code: S%=RND(-13565653) : FOR I%=0 TO 4 : PRINT CHR$(64+RND(26)); : NEXT
PRINT " ";
S%=RND(-1353613) : FOR I%=0 TO 4 : PRINT CHR$(64+RND(26)); : NEXT
PRINT
I know that's cheating a bit. I somehow doubt there's a single 32 bit seed value which (when used with BB4W's native RNG) would produce the full "HELLO WORLD" (assuming that random ASCII values from 32 to 91 were tried for all 11 characters of the string).
Jon Ripley's 2^64-1 sequence length RNG might offer the possibility, though.
One thing to consider if anyone wishes to try for the full string: the life expectancy of the Universe ;)
Regards,
David.
|
|
Logged
|
|
|
|
|