Solved

Using DOS assembly sources in Win9x & NT

Posted on 2000-05-17
13
203 Views
Last Modified: 2010-04-15
Hi, all,

I am an old programmer so I have a lot of good assemby routines from the old DOS ages. Now, however, I have to develop in Windows environments (95, 98, NT) and I actually do it. My old routines would even be welcome while I write programs to these new platforms. My question would be what the conditions are to translate old assembly sources to DLL-s which could be used by Windows EXE-s.

If possibile please suggest a good development environment for this task.

Thanks

Charles


0
Comment
Question by:csabay
  • 6
  • 5
  • 2
13 Comments
 
LVL 12

Expert Comment

by:pjknibbs
Comment Utility
Provided the assembly sources don't directly access DOS interrupts or stuff like that, which is generally a no-no under Windows, you should be able to compile them into DLLs using the in-built assembler in a C compiler. This would allow the compiler to do all the messy stuff of actually setting up function calls and export tables, while your assembly code remains pretty much unchanged.

Any C compiler with a built-in assembler should do. The one I use is Microsoft Visual Studio, but you could use some other if you have a preference.

One thing to bear in mind: you might want to convert your old assembly routines to full 32-bit, to make the link between Win32 and the DLL smoother.
0
 

Author Comment

by:csabay
Comment Utility
pjknibbs,

I say thank you for your comment. I need more help if you can give me.

I never used interrupts belonging to the BIOS level. I frequented to use, however, the DOS level interrupts, mainly the int 21h to deal with data in the memory or with files. What is your opinion about it?

What do you think of when you are speaking about full 32-bit? Manipilations target bytes, I have to say. Bytes are 8-bit units, what to do in these cases with 32-bits? My addresses are in <segment>:<offset> syntax, you can behold them as 32-bit addresses, I know of course they aren't that. My registers are AX, BX,... CS, DS,... SI, DI &c. Do you suggest me to change them to EAX, EBX,... and so on? When yes, why?

And at the end: Does it yield some handicap when assembly routines remain in 16-bit form?

I say thank you again and I'm waiting for your next comment.

Charles
0
 
LVL 12

Expert Comment

by:pjknibbs
Comment Utility
Calling INT21 directly from a Windows application is not a good idea, particularly if the function you're using requires a pointer to a structure. The reason is that INT21 assumes it will be called from a real-mode program which is limited to 640K in scope, whereas Windows runs in protected mode with a flat 32-bit address space, so none of the pointers will be compatible. The problem is even worse under Windows NT/2000--these systems will not permit direct access to DOS interrupts and your program will be terminated by the OS as soon as it issues the INT21 call.

As for full 32 bits: a Win32 application runs in a flat 32-bit address space, so segments and offsets will not work properly. You *have* to use full 32-bit offsets to access data within this address space. This is why I said you had to translate your assembly routines to 32-bit.

Out of interest, what do these assembly routines actually do? It's entirely possible there are more suitable Windows equivalents for their functionality. The only time I ever use raw assembler in a Windows program is for maximum performance in tight, CPU-intensive loops; for things like file access you're far better off using Windows calls.
0
 

Author Comment

by:csabay
Comment Utility
Thank you again for your rapid reaction.

I try to answer in the sequence of yours:

Yes, I used to use int 21h and I have got the idea there might exist some "Windowsed" assembler which performs assembling according to Windows' needs. So when I say "int 21h" then it substitutes this command by some Windows-compatibile thing that yields the same result but on some Windows-friendly way. Am I wrong?

I was thinking of the addressing methods similarly.

There are several packs written in assembler, it would be too long to list all features served by them. I can, however, point out some characteristic groups.

There is a big pack which manages database handling. We both with one of my collegagues have developed a complete pack dealing with a welldefined database structure. These routines support the whole management from the open on till the close; accross the semaphoring.

Another large pack deals with strings: translations among character sets, weighting aiming to sorting, encripting to handle with passwords and similar "hidden" strings. These routines can e.g. convert roman numrals to arabic and so on.

There are areas of my routines which are not necessary in the Windows environment, I think. Such are the routines that grab and release conventional memory, routines that perform several screen phainomena (shadowing, framing, scrolling and so forth).

We have an assemly routine that sorts 16-byte strings extremly fast in the memory; there are a lot of cases when this rutine serves very well and we don't want to lose its speed.

In our data retrieval system we interpret hit sets as bit streams. (When you have got a database containing e.g. 500.000 records, so we deal with it as a 500.000 bit i.e. 62.500 byte string. Each bit refers to a record. When the record is an element of the hit set then the bit is 1 else the bit is 0.) This data interpretation makes us able to perform an improved engine counting with the wellknown Boolean AND, OR &c operators. How to transport it into the new Windows world? Are there technics which could substitute such operations?

Thank you reading my long "crying"...

Your next comment will be surely accepted as an answer.

Charles

P.S.: What will be the chosen C-compiler - is it egal or not?

0
 

Author Comment

by:csabay
Comment Utility
Oops, I misspelled: phenomena instead of "phaino..." - when I know it well.
0
 
LVL 12

Expert Comment

by:pjknibbs
Comment Utility
I've never come across a Windows assembler which does a translation like you say, probably because most "portable" code is written in C or C++. On the whole, any of your assembly code which accesses stuff already loaded into memory can be converted by just changing the SEGMENT:OFFSET pointers to ones which just use a 32-bit OFFSET. The 16-byte string sort probably comes into this category. The bigger problems come when accessing files: using INT21 to do this is extremely non-portable, and wouldn't work with an NTFS-formatted drive under NT (for instance), even if the OS allowed you to make the call. What I'd do is handle file access through the Windows API. It's possible to call this from assembler, but it would probably be easier to just rewrite those parts in C.

As for the chosen C compiler, I'm not sure what you mean by the question. Could you clarify, please?
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

Author Comment

by:csabay
Comment Utility
About the C compiler:

I wonder if you could suggest a certain purchaser, Borland, e.g. or somebody else.

Thank you

Charles
0
 
LVL 12

Expert Comment

by:pjknibbs
Comment Utility
As I said, personally I use Microsoft Visual Studio (which includes VC++ 6.0). However, I believe Borland actually provide the command line version of their latest compiler as a free download, so if you can live without an IDE that might be the way to go.
0
 

Author Comment

by:csabay
Comment Utility
Can you give me a URL?

Charles
0
 
LVL 12

Accepted Solution

by:
pjknibbs earned 200 total points
Comment Utility
0
 

Expert Comment

by:Mukthar
Comment Utility


looks like a hard brain storm session goes on here while the whole world is talking abt palm PC's and wireless apps. ok there's a lot of difference between Windows'9x and Win NT OS models. there's no such tool which can convert the address mapping. But alternatively you can achive the direct address access. probably the existing code of urs wont help much.

but i've seen a lot of assembler code printed with C code. Most of them i come across is related to hacking windows. So may be if you could go to hacker community sites and see the code you can know how you can make use of you interrupts.

mukthar.
0
 

Author Comment

by:csabay
Comment Utility
I have had troubles with the download but I'll try it later.

Mukthar: I don't understand you... Perhaps you should like to be something unpolite? Why?

Charles
0
 

Expert Comment

by:Mukthar
Comment Utility
i didnt mean anything. like i used to make a study about windows NT security system loop holes , where in i came across those info. so they were using interrupts to acheive that. am trying to fix up those. am sorry if u feel so charles.

thanks for the comments.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now