Shop OBEX P1 Docs P2 Docs Learn Events
What's missing from this list? — Parallax Forums

What's missing from this list?

Martin HodgeMartin Hodge Posts: 1,246
edited 2011-02-28 03:44 in Propeller 1
What do you see missing from this LIST?

I found it interesting to note the widely variable program lengths.

Also notice versions in Malbolge, Esoteric Perl, and Shakespeare. lol

Comments

  • Dr_AculaDr_Acula Posts: 5,484
    edited 2011-02-24 18:18
    Spin?

    It might be a bit of a challenge to write this, because you would have to add the code for a TV or VGA driver or a serial port driver.

    BCX basic is not there, but it is the same as most other Basic languages, ie PRINT "Hello World"
    jabaco is not there, but it is the same as vb6, ie Msgbox("Hello World")

    For the old-skool gang, nice to see Z80 is there.
  • Martin HodgeMartin Hodge Posts: 1,246
    edited 2011-02-24 20:59
    It might be a bit of a challenge to write this, because you would have to add the code for a TV or VGA driver or a serial port driver.

    PBASIC is in there, and one of the examples blinks an LED.
  • RossHRossH Posts: 5,519
    edited 2011-02-24 22:02
    PBASIC is in there, and one of the examples blinks an LED.

    That PBASIC program that just flashes a LED is a bit of a cheat, since it is not doing anything analogous to communicating the message "Hello, world!".

    But how about one that flashes out "Hello, World!" using morse code? Anyone want to program that up in SPIN and lodge it?

    Ross.
  • Martin HodgeMartin Hodge Posts: 1,246
    edited 2011-02-24 22:53
    That PBASIC program that just flashes a LED is a bit of a cheat, since it is not doing anything analogous to communicating the message "Hello, world!".

    I disagree. When using a micro-controller for the first time, a blinking LED says "hey there. I'm working." very nicely.
  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2011-02-24 23:32
    You don't need a full fledged serial driver to send serial, it's pretty easy to bit bang.
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2011-02-24 23:49
    Interesting to code this. On a traditional micro, a display driver is a separate chip. On the propeller, the video display driver is software. I think that is a feature worth highlighting, not hiding.

    I'm looking at kyedos thinking what you could strip out.
    1) attach a vga monitor to pins 16 to 23
    2) Main code
    OBJ
      VT100: "VGA_1024_VT100"       ' VGA VT100 Terminal Driver   
    
    3) include all that code, including the sub object vga : "vga_80x40"
    4) Strip out all the code not used for printing "Hello World"
    5) some housekeeping
    VT100.start(16)                                       ' start the vga driver VGA starts on pin 16
    VT100.startcursor                                     ' start the cursor
    VT100.color(%00001000_11111100)                       ' Blue_White  blue =3/4 power 10, white =full                                  
    VT100.cursorset(5)                                    ' cursor type 5
    
    6) print it out
          vt100.str("Hello World")                                 ' send to vga screen  
    


    Rather than trying to hide any of this complexity, I would highlight it. eg - here is a software vga driver. Here are the fonts for this text. Here is how to change the text color.

    I think that really shows the flexibility of the propeller in being able to emulate things that once upon a time would have required extra support chips.

    I'd also emphasise that this is a chip with a monitor/tv directly connected to some of the pins. Coz I think that is a really cool feature of the propeller!
  • Heater.Heater. Posts: 21,230
    edited 2011-02-25 00:54
    Dr_A,

    I disagree. The spirit of the hello world program is:

    1) To print the message "Hello World!" on whatever device the user can read it.
    2) To do so with the least amount of code.
    3) Basically it the simplest thing required to show that the compiler, tool chain and system on which it runs does actually work.

    To that end no regard is paid to any operating system required to run the thing, or device drivers, or libraries it may have to be linked with.

    Look at the C version (The mother of them all) it pulls is stdio.h with no worries about how big and complicated that may be or what else it may pull in or what libraries and OS support is required to make printf work.

    So I propose that in the spirit of the thing hello world in Spin looks like this:
    CON
        _clkmode = xtal1 + pll16x
        _xinfreq = 5_00_000
        baud     = 115_200
    
    OBJ
        console : "FullDuplexSerial"
    
    PUB start
        console.start(31, 30, 0, baud)
        console.str(string("Hello, world!", 13))
    

    The CON section is required to get a stable good clock frequency running.
    The OBJ section is require to pull in the serial driver. FullDuplexSerial is supplied with the Parallax Propeller Tool so I'm going to consider it equivalent to stdio in C for example.
    The serial console needs starting and the the string can be printed.
    That's it.
  • Heater.Heater. Posts: 21,230
    edited 2011-02-25 01:34
    Just to kick things off I have added a Spin version of Hello World to the wikibooks page.
    Of course anyone can "fix" it if they like.
  • Heater.Heater. Posts: 21,230
    edited 2011-02-25 01:37
    Anyone up for a PASM version?

    I suggest it should just contain the tx side of a UART driver and enough code to print the message. It will need to be wrapped in Spin to get it started though.
  • Cluso99Cluso99 Posts: 18,069
    edited 2011-02-25 03:21
    How about my 1pin TV text? NTSC 64x25 monochrome.

    All that is required is a composite monitor and 1 pin and a resistor anywhere between 240R and 1K.

    Shows off how easy the software and hardware is :)

    I have not tested as no composite monitor available at the moment. I just stripped out most of the demo code for this. It is set for 64x25 NTSC.
    CON                                                   
      _XINFREQ = 5_000_000 + 0000
      _CLKMODE = XTAL1 + PLL16X                            
      tvPin  = 14                   'TV pin (1-pin version)  (best pin to use if trying on existing circuit)
     
    OBJ
      TV   :  "Debug_1pinTV"                                ' TV (Composite Video, monochrome) driver using 1 pin and 1 resistor
     
    PUB main  
      TV.start(tvPin)                                       'start the 1pinTV driver
      TV.chr(0)                                             'clear screen
      TV.str(string("Hello World",13))
    

    Postedit: Just realised, this is the only code required to be posted.
    Heater: Since you have an a/c would you loke to post this too?
    Comment: Using 1 pin and a resistor of 100R-1K ohms and an external monitor, you can print "Hello World" to your screen and the 1pinTV software driver.
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2011-02-27 02:56
    1) To print the message "Hello World!" on whatever device the user can read it.
    2) To do so with the least amount of code.
    3) Basically it the simplest thing required to show that the compiler, tool chain and system on which it runs does actually work.


    Hmm heater, yes, the more I think about it, the more you may be right there.

    You used the example of C on the PC.
    printf("Hello World\n");

    and one might then say that you need STDIO. Well, that kind of goes without saying. And an operating system? Well, *of course* you need an operating system. And video drivers for you particular monitor? Well, yes, that too.

    So...
    If all of that is allowed to be added on a PC, then by the same logic, I propose this single line of code for Spin:
    TV.str(string("Hello World",13))
    
  • Heater.Heater. Posts: 21,230
    edited 2011-02-27 04:12
    Dr_A,

    No, a single line like that will not do. That ignores requirement 3) that we have complete program that will compile and run so as to verify that the tool chain and execution environment works.

    I'm just assuming that FullDuplexSerial is available in the same way as helloworld in C assumes the presence of stdio.h and the required libraries to make it work.

    Difference is that in C the IO is part of the standard for the language but in Spin it is not. But FDX is sort of standard for Spin as it comes with the Prop Tool.
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2011-02-27 04:52
    Ok, so the rule is that you can use included libraries? Take the C example from that website
     #include <stdio.h>
     
     int main( void )
     {
        printf("Hello, world!\n");
        return 0;
     }
    

    You need to include stdio, but you don't need to list the code in stdio.

    So does that mean one can include libraries that came with the standard download of the prop tool?

    In which case, I vote for the code in post #8, but I don't think you need to add any more code as alluded to in post #10. I see that is on the website now. Nice work.
  • Heater.Heater. Posts: 21,230
    edited 2011-02-27 05:41
    Yep, I'm assuming that whatever comes with the Prop tool is equivalent to the standard header files and libs of C.

    The spirit of helloworld is that it is the minimum a user has to write to checkout that everything works. I think we have that now.

    However I think there should also be single COG PASM verxsion on that list as well.
  • Martin HodgeMartin Hodge Posts: 1,246
    edited 2011-02-27 09:44
    Should it also be mentioned that indentation is mandatory? Also there's a typo in the _xinfreq line. (500,000 Hz)
  • Heater.Heater. Posts: 21,230
    edited 2011-02-27 09:57
    Well spotted, fixed now.
    I did not mention the indenting. Language features are not much referred to on that page.
  • $WMc%$WMc% Posts: 1,884
    edited 2011-02-27 11:22
    I didn't see PropBasic, FemtoBasic, EmbeddedBasic, or PowerBasic. Just to name a few.
    '
    The list is impartial and biased.
  • Martin HodgeMartin Hodge Posts: 1,246
    edited 2011-02-27 13:06
    Heater. wrote: »
    Well spotted, fixed now.
    I did not mention the indenting. Language features are not much referred to on that page.

    Just as well, that snippet will compile without indenting anyway.
  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2011-02-27 19:48
    Heater,

    For a cut-paste and execute approach here is a PASM ... Hello World that works up to 250k baud. No other drivers or libraries required.
    CON
      _CLKMODE = XTAL1 + PLL16X
      _CLKFREQ = 80_000_000
    
      Baud = 250000
      TX   = 30
    
    PUB start
    
        cognew(@PASM, string(" PASM Hello World! "))
        
        repeat
    
    DAT
    
    PASM          org
                  or        dira,   PinMask       'Make min an Output
                  or        outa,   PinMask       'Set pin HIGH
    Clear         mov       Index,  par
                  add       Index,  #2
    NextChar      rdbyte    Buff,   Index wz
             if_z jmp       #Clear
                  add       Index,  #1      
            
                  add       Buff,   #$100         'Add Start Bit
                  shl       Buff,   #1            'Add Stop Bit
                  mov       BitCount, #10         'Start Bit + Stop Bit + Byte = 10 bits
    
    Bits          ror       Buff,   #1   wc       'Send Bit LSB first
                  muxc      outa,   PinMask
            
                  mov       delay,  BaudDelay     'Pause based on Baud 
                  djnz      delay,  #$
    
                  djnz      BitCount, #Bits       'More Bits to send?      
            
                  jmp       #NextChar             'Send Next Character  
    
    PinMask       long      |<TX
    BaudDelay     long      ((_CLKFREQ / Baud)>>2)-5
    delay         long      0
    Index         long      0
    Buff          long      0
    BitCount      long      0
    
  • kuronekokuroneko Posts: 3,623
    edited 2011-02-27 20:20
    For a cut-paste and execute approach here is a PASM.
    The string is misaligned (4n+2). So you better put in a (controlled) DAT location.
    Serves me right! It is in fact adjusted within the program but that feels wrong. Thanks for pointing out my oversight Beau :) I need my coffee consume sorted out.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-02-27 22:34
    Here's a version that, I believe, uses the least amount of external resources -- just a resistor and an LED (or a beeper). It sends "HELLO, WORLD!" in Morse code.
    CON
    
       _clkmode       = xtal1 + pll16x
       _xinfreq       = 5_000_000
    
       LED            = 23
    
    PUB  Start | i
    
      dira[LED]~~
    
      repeat
        repeat i from 0 to 5
          repeat 32
            outa[LED] := (Hello[i] <-= 1) < 0
            waitcnt(clkfreq / 5 + cnt)         
    
    DAT
    
    Hello         long      $aa22ea2e->1,$a3bb8eea->1,$ee02ee3b->1,$b8ba2ea3->1,$a8ebaee0->1,0
    
    -Phil
  • Andrey DemenevAndrey Demenev Posts: 377
    edited 2011-02-28 03:44
    Phil, tha's nice ! Here is a modification that actually beeps via a piezo buzzer connected between 2 pins:
    CON
    
        _clkmode       = xtal1 + pll16x
        _xinfreq       = 5_000_000
    
        BUZZER1 = 0
        BUZZER2 = 1
        TONE = 1000
    
    PUB  Start : i
        FRQA :=  (|<30) /  (clkfreq / TONE) * 4
        dira[BUZZER1]~~
        dira[BUZZER2]~~
        CTRA := %00101 << 26 | BUZZER1 << 9 | BUZZER2 << 0
    
        repeat
            repeat i from 0 to 5
                repeat 32
                    if (Hello[i] <-= 1) < 0
                        CTRA := %00101 << 26 | BUZZER1 << 9 | BUZZER2 << 0
                    else 
                        CTRA := 0
                    waitcnt(clkfreq / 20 + cnt)         
    
    DAT
    
    Hello         long      $aa22ea2e->1,$a3bb8eea->1,$ee02ee3b->1,$b8ba2ea3->1,$a8ebaee0->1,0
    
Sign In or Register to comment.