BBC BASIC for Windows
General >> General Board >> hello, world
http://bb4w.conforums.com/index.cgi?board=general&action=display&num=1218811718

hello, world
Post by David Williams on Aug 15th, 2008, 2:48pm

PRINT "hello, world"
Re: hello, world
Post by Michael Hutton 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
 

Re: hello, world
Post by David Williams on Aug 21st, 2008, 05:32am

on Aug 20th, 2008, 08:55am, Michael Hutton wrote:
OR ...


grin

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.
Re: hello, world
Post by David Williams 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.