TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Todd Cohen
from: Patrick Haller
date: 1995-05-25 16:14:10
subject: ASM

Hi Todd!

[..]
 TC> Can someone please post me an example on how to write a program in
 TC> assembly under os/2 that will print "Hello" in a full
screen session.

; A very simple OS/2 program to print hello world for OS/2.
; To build HELLOOS2.EXE:
;    TASM HELLOOS2.ASM
;    TLINK HELLOOS2,,,OS2.LIB;
;

ideal
p386

model flat

codeseg
extrn DOSEXIT:near,DOSWRITE:near

stack 800h

dataseg

; Handle for printing to the console
HANDLE_CON    = 1

; The message to print, and it's length
message       db 13,10,'Hello World!',13,10,0
messagelength = $-message-1

; Storage for number of characters written
written dd 0

codeseg
start:
        ; To do output, we must use the file handle to the console,
        ; and do our output to that.
        ; Note that for OS/2 flat model, we do not need to do anything
        ; with segment registers. Just push the offset of the items.
        ; Also note the OS/2 2.0 system calls are C style. That means
        ; the caller must cleanup that stack after the call.
        ; DOSWRITE(FileHandle,pBufferArea,ulBufferlength,pBytesWritten)
        call    DOSWRITE C,       \
                      HANDLE_CON,     \ ; Handle is a doubleword!
                      offset message, \ ; Location of message to print
                      messagelength,  \ ; Doubleword length of message
                      offset written    ; Storage for how many characters are
                                        ; written.

        ; Exit the program now
        call    DOSEXIT C,0,1
end start
     __
     |_)
cu/2 |atrick

--- FleetStreet 1.03 #301
* Origin: OS/2 Bodensee ! (2:246/2315.18)
SEEN-BY: 105/42 620/243 711/401 409 410 413 430 807 808 809 934 955 712/407
SEEN-BY: 712/515 628 704 713/888 800/1 7877/2809
@PATH: 246/2315 2300 2340 24/901 240/5500 396/1 270/101 105/103 42 712/515
@PATH: 711/808 809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.