OpenVMS Source-Code Demos

helloworld

	.TITLE  helloworld
	.IDENT  /V1.1/
;-------------------------------------------------------------------------
; title : helloworld.mar
; author: Steve Hoffman
; notes : This is a VAX Macro32 Hello, World program. (also works as-is on
;	  OpenVMS on Alpha (provided you have located and installed the
;	  public domain license) and OpenVMS on Itanium
;-------------------------------------------------------------------------
;   Copyright (c) 2009 - 2014 HoffmanLabs LLC
;
;   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.
;
;   Except as contained in this notice, the name(s) of the above
;   copyright holders shall not be used in advertising or otherwise
;   to promote the sale, use or other dealings in this Software
;   without prior written authorization.
;
;   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.
;
; build:	$ macro helloworld.mar
;		$ link helloworld.obj
; run:		$ run helloworld.exe
; output:	Hello, World!
;		$
;------------------------------------------------------------------

	.PSECT RDATA,NOWRT,SHR,NOPIC,NOEXE,RD,QUAD
	; this program section (psect) contains data that is
	; non-writeable, shareable, position independent,
	; non-executable, readable, and quadword aligned.
	; In other words, a whole lot of detail around a
	; string descriptor pointing to a string constant.
	;
HI:     .ASCID /Hello, World!/

	.PSECT CODE,NOWRT,SHR,PIC,EXE,RD,QUAD
	; this program section contains the executable code.
	;
START:: .CALL_ENTRY PRESERVE=<>,MAX_ARGS=0,HOME_ARGS=TRUE
	; the start of the main program code.

	; push the address of the descriptor onto the stack,
	; and call the RTL routine to display string output
	; with (as it expects) #1 one argument.  Branch to
	; label 10$ on any error from lib$put_output.
	;
	PUSHAQ  HI
	CALLS   #1,G^LIB$PUT_OUTPUT
	BLBC    R0,10$

	; set up a normal exit status.
	;
	MOVL    #SS$_NORMAL,R0
10$:    RET

	; The directive that makes this module a top-level
	; (or in C terminology "main") program, and declares
	; the name of the main entry point for the program.
	;
	.END    START

Back to OpenVMS
Back to OpenVMS Demo Index
Back to Home
Neil Rieck
Kitchener - Waterloo - Cambridge, Ontario, Canada.