BBC BASIC for Windows
« hello, world »

Welcome Guest. Please Login or Register.
Apr 5th, 2018, 10:02pm



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

If you require a dump of the post on your message board, please come to the support board and request it.


Thank you Conforums members.

BBC BASIC for Windows Resources
Online BBC BASIC for Windows documentation
BBC BASIC for Windows Beginners' Tutorial
BBC BASIC Home Page
BBC BASIC on Rosetta Code
BBC BASIC discussion group
BBC BASIC for Windows Programmers' Reference

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: hello, world  (Read 803 times)
David Williams
Developer

member is offline

Avatar

meh


PM

Gender: Male
Posts: 452
xx hello, world
« Thread started on: Aug 15th, 2008, 2:48pm »

PRINT "hello, world"
User IP Logged

Michael Hutton
Developer

member is offline

Avatar




PM

Gender: Male
Posts: 248
xx 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
 
« Last Edit: Aug 20th, 2008, 09:02am by Michael Hutton » User IP Logged

David Williams
Developer

member is offline

Avatar

meh


PM

Gender: Male
Posts: 452
xx Re: hello, world
« Reply #2 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.
« Last Edit: Aug 21st, 2008, 06:08am by David Williams » User IP Logged

David Williams
Developer

member is offline

Avatar

meh


PM

Gender: Male
Posts: 452
xx 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.
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls