As Spin does not define any I/O functionality except for pin reading/writing and video I guess the thing to do is write a serial port transmitter in Spin and have it output the text.
If assembler is allowed then a video output would be more impressive.
There is a much bigger collection of hello world programs on en.wikibooks.org to which I added an XC version (for the chip that shall remain nameless here) last year. That implements a serial transmitter to output the text.
@heater - reading through some of the examples on the first wiki link - the header files are treated like black boxes so I would think a fine example in Spin would include a Serial Terminal object or such as a "Black Box" in the case of a hello world program. After all, isn't the purpose of the hello world to ensure the IDE is configured and working properly?
I do agree that using the TV object to output "Hello World" would be impressive. Here's my attempt using a parred down version of Chips Graphics Demo. Perhaps TV.terminal embedded as an object for simplified code would be a better example.
'' TV_Hello_world.spin
'' Paul A. Willoughby, DVM 2/4/2012
''***************************************
''* adapted from original code by: *
''* *
''* Graphics Demo *
''* Author: Chip Gracey *
''* Copyright (c) 2005 Parallax, Inc. *
''* See end of file for terms of use. *
''***************************************
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
_stack = ($3000 + $3000 + 100) >> 2 'accomodate display memory and stack
x_tiles = 16
y_tiles = 12
paramcount = 14
bitmap_base = $2000
display_base = $5000
VAR
long tv_status '0/1/2 = off/visible/invisible read-only
long tv_enable '0/? = off/on write-only
long tv_pins '%ppmmm = pins write-only
long tv_mode '%ccinp = chroma,interlace,ntsc/pal,swap write-only
long tv_screen 'pointer to screen (words) write-only
long tv_colors 'pointer to colors (longs) write-only
long tv_hc 'horizontal cells write-only
long tv_vc 'vertical cells write-only
long tv_hx 'horizontal cell expansion write-only
long tv_vx 'vertical cell expansion write-only
long tv_ho 'horizontal offset write-only
long tv_vo 'vertical offset write-only
long tv_broadcast 'broadcast frequency (Hz) write-only
long tv_auralcog 'aural fm cog write-only
word screen[x_tiles * y_tiles]
long colors[64]
OBJ
tv : "tv"
gr : "graphics"
PUB start
init ' initalize TV and Graphics objects, set up colors and tile screen
gr.clear
gr.textmode(2,2,6,5)
gr.colorwidth(1,2)
gr.text(0,0,@theText)
gr.copy(display_base)
PRI init | i, dx, dy
'start tv
longmove(@tv_status, @tvparams, paramcount)
tv_screen := @screen
tv_colors := @colors
tv.start(@tv_status)
'init colors
repeat i from 0 to 63
colors[i] := $00001010 * (i+4) & $F + $2B060C02
'init tile screen
repeat dx from 0 to tv_hc - 1
repeat dy from 0 to tv_vc - 1
screen[dy * tv_hc + dx] := display_base >> 6 + dy + dx * tv_vc + ((dy & $3F) << 10)
'start and setup graphics
gr.start
gr.setup(16, 12, 128, 96, bitmap_base)
DAT
theText byte "Hello World",0
tvparams long 0 'status
long 1 'enable
long %001_0101 'pins
long %0000 'mode
long 0 'screen
long 0 'colors
long x_tiles 'hc
long y_tiles 'vc
long 10 'hx
long 1 'vx
long 0 'ho
long 0 'vo
long 0 'broadcast
long 0 'auralcog
{{
┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ TERMS OF USE: MIT License │
├──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation │
│files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, │
│modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software│
│is furnished to do so, subject to the following conditions: │
│ │
│The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.│
│ │
│THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE │
│WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR │
│COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, │
│ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
}}
The intent of a "Hello World" program is to be a quick and simple program to try out a new language or platform. Most of them rely on libraries provided by the development environment. I would think that a Spin Hello World program would use one of the standard serial drivers and just call the start and str methods.
CON
_clkmode = xtal1+pll16x
_xinfreq = 5_000_000
OBJ
ser : "FullDuplexSerial"
PUB main
ser.start(31, 30, 0, 115_200)
ser.str(string("Hello World", 13))
g3cwi if you enter the program that Dave Hein posted into the Propeller tool then hit F10 or F11 to load the program to the Propeller and as soon as the loading message disappears hit F12 to open the serial terminal to see "Hello World" printed to the screen.
Edit: Make sure the serial terminal is set to 115200 buad per Dave's program and the com port# for it is set the same as your Propeller Board. These settings are at the bottom of the serial terminal screen.
The intent of a "Hello World" program is to be a quick and simple program to try out a new language or platform. Most of them rely on libraries provided by the development environment. I would think that a Spin Hello World program would use one of the standard serial drivers and just call the start and str methods.
CON
_clkmode = xtal1+pll16x
_xinfreq = 5_000_000
OBJ
ser : "FullDuplexSerial"
PUB main
ser.start(31, 30, 0, 115_200)
ser.str(string("Hello World", 13))
Yeah, that works a lot better than what I did. A LOT BETTER.
Comments
If assembler is allowed then a video output would be more impressive.
I do agree that using the TV object to output "Hello World" would be impressive. Here's my attempt using a parred down version of Chips Graphics Demo. Perhaps TV.terminal embedded as an object for simplified code would be a better example.
Edit: Make sure the serial terminal is set to 115200 buad per Dave's program and the com port# for it is set the same as your Propeller Board. These settings are at the bottom of the serial terminal screen.
Yeah, that works a lot better than what I did.