News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Help needed to build a library of PROCs

Started by frktons, January 10, 2013, 12:38:32 PM

Previous topic - Next topic

jj2007

Quote from: Ficko on January 12, 2013, 12:30:11 AM
Quote from: jj2007 on January 11, 2013, 11:54:26 PM
Therefore, to be on the safe side I prefer to do the release version with ML 6.15.

So you are assuming that ML 6.15 is a 100%, flawless product.  :eusa_snooty:

No, I assume that the majority of coders here use some flavour of ML.exe and are dependent on its bugs ;-)

frktons

Considering my LIB is going to be an experimental one, for my
own private use, I can afford both the bugs of MASM & Jwasm.

So if anyone want to experiment with the PROCs, feel free to do
it, but post your results or comments in this thread, for the benefit
of all members.

The first routine I put into the LIB is ConsoleSize to allocate a
fixed size console, with choice for number of Rows and columns.
It actually doesn't manage improper input, so be consistent
with the requests you do when INVOKING it.  :lol:
Attached also a Test pgm to see it in action. 
There are only two days a year when you can't do anything: one is called yesterday, the other is called tomorrow, so today is the right day to love, believe, do and, above all, live.

Dalai Lama

dedndave

that looks good but, i would use a method similar to what Hutch does with masm32.lib
very much like what ms does with .H includes and LIB's

he creates a masm32.inc file
that inc file contains all the prototypes for the functions in the lib
i would also put any structures or constants (equates) that are related to those functions in the inc file
to save a little typing, you could make this the first line in the inc
    includelib MyLib.lib
when you update the library, you update the include file to go with it

now, when you want to use functions from the lib in a program source...
    include    MyLib.inc

bang - you have the includelib, prototypes, structures, and constants required to use the library functions

frktons

Quote from: dedndave on January 13, 2013, 01:33:08 PM
that looks good but, i would use a method similar to what Hutch does with masm32.lib

he creates a masm32.inc file
that inc file contains all the prototypes for the functions in the lib
i would also put any structures or constants (equates) that are related to those functions in the inc file
to save a little typing, you could make this the first line in the inc
    includelib MyLib.lib

when you update the library, you update the include file to go with it

now, when you want to use functions from the lib in a program source...
    include    MyLib.inc

bang - you have the includelib, prototypes, structures, and constants required to use the library functions

Yes Dave, you are right, and that will be the way it is going to work.
For the time being I'm setting all the things that are needed, as
BAT files, EXTERNDEF, and so on. And many of these things, including
the syntax of LINK/LIB/MASM for building modules and managing the LIB
are not at all clear. As I finish the first group of PROCs it'll be a pleasure
to comment and correct whatever needed and start building the INC file
as the PROCs require.
There are only two days a year when you can't do anything: one is called yesterday, the other is called tomorrow, so today is the right day to love, believe, do and, above all, live.

Dalai Lama

hutch--

Frank,

Forgive my humour but with the amount of time posting in this topic you could have built many libraries.  :P

frktons

Quote from: hutch-- on January 13, 2013, 02:02:55 PM
Frank,

Forgive my humour but with the amount of time posting in this topic you could have built many libraries.  :P

I enjoy the debate as much as coding, sometime even more  :lol:

And, I'm not in a hurry, if I don't code for 1 week or 3 months, that's
perfectly fine.  :P
There are only two days a year when you can't do anything: one is called yesterday, the other is called tomorrow, so today is the right day to love, believe, do and, above all, live.

Dalai Lama

hutch--

 :biggrin:

Nah, this is a sales pitch, plonk 'em all into a directory, get the batch file right and its SLAP BAM, THANKYA MAAM !

frktons

Quote from: hutch-- on January 13, 2013, 05:19:15 PM
:biggrin:

Nah, this is a sales pitch, plonk 'em all into a directory, get the batch file right and its SLAP BAM, THANKYA MAAM !

Steve, this is an occasion for learning something, so I've to go slowly.
As a matter of fact, I'm quite lost about the data definition.
I'm trying to define data in an include for the main prog, and find a way
to make them visible to the other PROCs using them.

Because MASM complains, I assume something is wrong with PUBLIC, EXTERNDEF,
and the like.

With EXTERNDEF I should solve all my problems apparently, but I didn't find yet
the correct way to use it.

The most difficult thing, for lack of info, is the definition of a STRUCT in the main
include:


    FmtNum16S  STRUCT
       Billions   BYTE    20H
       Millions   DWORD   20202020H
       Thousands  DWORD   20202020H
       Units      DWORD   20202020H
       StrZT      BYTE    00H
       Dummy      WORD    0000H
    FmtNum16S  ENDS


After I define the STRUCT, I don't know how to make it usable from other
modules.
If I use EXTERNDEF FmtNum16S: it doesn't seem enough.
If I define an actual STRUCT data like:
FmtNum16  FmtNum16S <>
and after I make it PUBLIC with:EXTERNDEF FmtNum16:
the called PROC doesn't see its components:
       Billions   BYTE    20H
       Millions   DWORD   20202020H
       Thousands  DWORD   20202020H
       Units      DWORD   20202020H
       StrZT      BYTE    00H
       Dummy   WORD  0000H


so these simple things, when info are incomplete become
quite difficult to manage.  ::)
There are only two days a year when you can't do anything: one is called yesterday, the other is called tomorrow, so today is the right day to love, believe, do and, above all, live.

Dalai Lama

dedndave

the attachment on this post in the old forum shows how to put data into a lib and access it from the main program
http://www.masmforum.com/board/index.php?topic=15480.msg126841#msg126841

when i started that thread, i was using the old "public/extrn" method
if you read through the thread, you will see that the guys straightened me out and i updated the attachment

frktons

Quote from: dedndave on January 14, 2013, 05:59:49 AM
the attachment on this post in the old forum shows how to put data into a lib and access it from the main program
http://www.masmforum.com/board/index.php?topic=15480.msg126841#msg126841

when i started that thread, i was using the old "public/extrn" method
if you read through the thread, you will see that the guys straightened me out and i updated the attachment

Dave, This is understandable. But I'm having problems with a STRUCT,
what's the correct sintax for declaring a STRUCT with EXTERNDEF?
See my previous updated post.
There are only two days a year when you can't do anything: one is called yesterday, the other is called tomorrow, so today is the right day to love, believe, do and, above all, live.

Dalai Lama

qWord

include file:
S struct
member1 DWORD ?
member2 DWorD ?
S ends

EXTERNDEF foo:S


some lib module:
.data
    foo S <>
MREAL macros - when you need floating point arithmetic while assembling!

MichaelW

Quote from: frktons on January 14, 2013, 05:43:55 AM
The most difficult thing, for lack of info, is the definition of a STRUCT in the main
include:


    FmtNum16S  STRUCT
       Billions   BYTE    20H
       Millions   DWORD   20202020H
       Thousands  DWORD   20202020H
       Units      DWORD   20202020H
       StrZT      BYTE    00H
       Dummy      WORD    0000H
    FmtNum16S  ENDS


After I define the STRUCT, I don't know how to make it usable from other
modules.

I have not been following this thread, but if the "modules" are separately assembled then why not include the structure declaration in the modules, either directly or by way of a common include file.
Well Microsoft, here's another nice mess you've gotten us into.

dedndave

http://masm32.com/board/index.php?topic=1255.msg12571#msg12571

put the structure definition in the INC file !!!

the data definition (that uses the structure definition) goes in the asm source or in the module, as appropriate

frktons

Quote from: MichaelW on January 14, 2013, 06:18:28 AM

I have not been following this thread, but if the "modules" are separately assembled then why not include the structure declaration in the modules, either directly or by way of a common include file.


Yes Michael, the modules are separately assembled.

Do you mean that I should repeat the STRUCT definition for each
module using it? If I only use the name and the EXTERNDEF directive
is it not enough?

Quote from: dedndave on January 14, 2013, 06:25:57 AM
http://masm32.com/board/index.php?topic=1255.msg12571#msg12571

put the structure definition in the INC file !!!

the data definition (that uses the structure definition) goes in the asm source or in the module, as appropriate

Yes Dave I put the STRUCT definition in the include file, and the include
is only included by the main prog. Maybe, because the STRUCT is used
from both main and external PROC, this is not enough.
I declared with EXTERNDEF the STRUCT in the external PROC, but something
is missing.
There are only two days a year when you can't do anything: one is called yesterday, the other is called tomorrow, so today is the right day to love, believe, do and, above all, live.

Dalai Lama

MichaelW

We have somewhat of a terminology problem here. STRUCT is used to declare a structure, so it's a type declaration that can be used in a data definition, or as a template for accessing data, or in this case as a qualifiedtype in an EXTERNDEF statement, but only if at the point of usage the assembler recognizes the type. And AFAIK for the assembler to recognize a type it must be an intrinsic type, or a previously declared structure, union, or record, or a type previously defined with TYPEDEF.
Well Microsoft, here's another nice mess you've gotten us into.