| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | OS2 & ASM |
Hello Gleason!
26 Feb 95, Gleason Pace writes to All:
GP> I am embarking on an OS2 program written in assembly. I have a couple of
GP> texts detailing the functions available from the OS2 system. My question
GP> is how do I call these? I am using MASM 6.0 which has OS2 support, unlike
GP> the more recent versions.
You call OS/2 functions in exactly the same way as you would call functions
you have written yourself.
GP> Can I use the "call" verb as in: call dosbeep Can I
pass parameters in
GP> parens (var,var,var)? Can I use functions that return a value? In higher
GP> languages this would look like: var=function. Are the DOSDevIOCtl
GP> functions available?
Because OS/2 is really biased towards high-level languages, all parameters are
passed on the stack. To pass these parameters you have two options:
1) Push the parameters on the stack, call the function and then tidy up the
stack afterwards.
2) Use PROTO to declare a prototype for each OS/2 function, and then use
INVOKE to call it. You can pass parameters in a similar way to high level
languages and you don't need to worry about the order they are pushed onto
the stack, or whether you need to tidy up afterwards.
To call DosBeep with the first method, you would do the following:
push 1000 ;1000 milliseconds = beep for 1 second
push 220 ;220Hz approximately middle C (I think)
call DosBeep
add esp,8 ;Remove parameters from stack.
The second method would involve having:
DosBeep proto flat syscall, :ULONG, :ULONG
in an include file. Then your code would contain:
invoke DosBeep,220,1000
Note that in the first case, you must take responsibility for tidying up the
stack (if necessary) and the order in which the parameters are passed.
Personally, I use the first method because I like to have total control
over what is happening.
GP> A few code fragments would be really helpful.
GP> I have the OS2.LIB and the include file of standard variable and function
GP> prototype definitions that came with MASM. Will it be sufficient to
GP> include and includelib these? Or do I need to reference the OS2 dll's?
The library and include files you get with MASM are all you need.
*HOWEVER*, they are only for 16-bit programming. You won't have the
advantage of using a flat memory model (you won't want to go back to
segment/selector:offset notation after using the flat memory model!).
Another advantage of using 32-bit code is that you can use all the extra
386 features (using any register as an index, pushing immediate values onto
the stack etc.) without worrying about whether you are actually running on
a 386.
The examples above are for the 32-bit functions.
Being the masochist I am (and if you're going to program in assembler, you
*have* to be a masochist!), I took the Borland C/C++ .h header files, ran
them through H2INC and then spent a weekend or so tidying them up.
A (possibly) easier method is to get the OS/2 toolkit from IBM. This has
the assembler .INC include files in it. I tried to use the ones in the
beta toolkit on the Warp Beta II CD, but just got a load of errors. Since
I already had the include files that I'd done, I stuck with them.
You'll also need the 32-bit version of OS2.LIB. Finally, you'll need to
use LINK386 rather than the version of LINK you get with MASM 6.00.
Hope this helps to get you started. Let me know if you want any more
information. If you have access to the Internet, you can reach me there a
lot more quickly than Fidonet (address below).
bcnu,
Richard.
(Team OS/2)
cm3bcrph{at}bs47a.staffs.ac.uk
--- GoldED 2.40
* Origin: Floating Point/2 (2:250/109.10)SEEN-BY: 105/42 620/243 624/50 711/401 409 410 413 430 807 808 809 934 955 SEEN-BY: 712/407 515 628 704 713/888 800/1 7877/2809 @PATH: 250/109 25/10 250/107 255/1 440/4 141/209 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™.