Author Topic: MS-DOS int 21 functions should work under XP!!  (Read 4801 times)

laskar01

  • Guest
MS-DOS int 21 functions should work under XP!!
« on: July 10, 2012, 05:48:13 AM »
Hi again, y´all, excuse a beginner, but I just found out reading the excellent book
"Assembly Language for Intel-based computers" 4th Ed, by Kip R. Irvine  that these are also availible under XP, is this really correct? :greenclp:
Questions:
1. Are these functions availible under Vista and Windows 7 ?
2. Why does this program with DOS-call give me the assembly error: error A2006:undefined symbol :DGROUP


TITLE Hello World Program         (Hello2.asm)

.MODEL small
.STACK 100h
.386

.data
message BYTE "Hello, world!",0dh,0ah

.code
main PROC
   .STARTUP
   mov   ah,40h         ; write to file/device
   mov   bx,1            ; output handle
   mov   cx,SIZEOF message   ; number of bytes
   mov   dx,OFFSET message   ; addr of buffer
   int   21h

    .EXIT
main ENDP
END

Next chapter is disk fundamentals, and the one after is BIOS -level programming :eusa_dance:

qWord

  • Member
  • *****
  • Posts: 1098
  • The base type of a type is the type itself
    • View Profile
    • SmplMath macros
Re: MS-DOS int 21 functions should work under XP!!
« Reply #1 on: July 10, 2012, 06:04:21 AM »
Do not waste your time and throw that book away - 16Bit stuff and DOS is something for the museum.
Search for a x86-32Bit assembler tutorial or book.
FPU in a trice: SmplMath
It's that simple!
MREAL macros - when you need floating point arithmetic while assembling!

Vortex

  • Member
  • *****
  • Posts: 1138
    • View Profile
Re: MS-DOS int 21 functions should work under XP!!
« Reply #2 on: July 10, 2012, 07:02:11 AM »
I agree with qWord. After x86-32bit, there is x86-64 bit assembly. Why to insist on 16-bit coding?

laskar01

  • Guest
Re: MS-DOS int 21 functions should work under XP!!
« Reply #3 on: July 10, 2012, 07:06:41 AM »
No, the book is excellent and contain both 16-bit and 32-bit. It starts with a thorough review of most instructions, buildning  MACRO's Win32 Console programming, Win32 Window-programming, MS-DOS both basic and memory resident, Disk system and BIOS-level programming.

This book is the shit!!!

qWord

  • Member
  • *****
  • Posts: 1098
  • The base type of a type is the type itself
    • View Profile
    • SmplMath macros
Re: MS-DOS int 21 functions should work under XP!!
« Reply #4 on: July 10, 2012, 07:16:17 AM »
No, the book is excellent and contain both 16-bit and 32-bit.
[...]
This book is the shit!!!
contradictory statements   :icon_eek:
FPU in a trice: SmplMath
It's that simple!
MREAL macros - when you need floating point arithmetic while assembling!

Gunther

  • Member
  • *****
  • Posts: 2514
  • Forgive your enemies, but never forget their names
    • View Profile
Re: MS-DOS int 21 functions should work under XP!!
« Reply #5 on: July 10, 2012, 07:39:03 AM »
Hi laskar01,

in general, qWord and Vortex are right.

But here is the answer for your questions:
Quote
that these are also availible under XP, is this really correct?

Not really. You may use your INT 21h stuff under XP, but your application runs inside a virtual machine and all interrupts are virtualized. That means: the Windows DPMI Host switches your program for a little while back to the Real Mode, let it do it's interrupt work, and switches back into Protected Mode. That is in a rough overview the used technique,

Quote
1. Are these functions availible under Vista and Windows 7 ?

No, that's impossible and has to do with the new Long Mode.

Quote
2. Why does this program with DOS-call give me the assembly error: error A2006:undefined symbol :DGROUP

Did you use the right 16 bit linker?

Gunther




Get your facts first, and then you can distort them.

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 1687
  • Mnemonic Driven API Grinder
    • View Profile
    • The MASM32 SDK
Re: MS-DOS int 21 functions should work under XP!!
« Reply #6 on: July 10, 2012, 09:00:31 AM »
The problem with using MS-DOS programming techniques is the 16 bit system was redundant back in the early 1990s. It was replaced first by 16 bit Windows, then from Win95 onwards it was replaced by 32 bit Windows and as of 64 bit Windows, it is not even supported by Windows Virtual Machines. MS-DOS is an antique architecture that depends on a modified 16 bit addressing system that uses segment/offset architecture which is completely incompatible with later protected mode addressing.

64k versus 4 gigabyte address range is one of the main reasons why MS-DOS was left behind long ago.

As far as the Irvine book, do yourself a favour and find another use for it, perhaps a doorstop, packaging for parcels if you tear out the pages and crumple them but do not waste you time or ours on out of date junk. Even the 32 bit code in it is non Intel / Microsoft complaint and uses an unreliable architecture to produce poor quality binaries.

If you bother to learn the modern stuff you use the Windows API functions instead of antique DOS interrupts, you select instructions based on privilege and you use the Intel ABI (Application Binary Interface) so that your register usage is properly compatible with the Windows operating system. If you do this you will be able to write genuine high speed software that runs correctly on all 32 and 64 bit versions of Windows up to Win7 64 bit and your applications will be far more powerful than out of date junk or incompatible architecture can deliver.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin:

dedndave

  • Member
  • *****
  • Posts: 6434
  • Still using Abacus 2.0
    • View Profile
Re: MS-DOS int 21 functions should work under XP!!
« Reply #7 on: July 10, 2012, 09:00:46 AM »
you can access some things with 16-bit code that is not so easy with 32 or 64-bit code
when running 16-bit code, newer OS's use NTVDM.exe to emulate or perhaps allow some of these accesses

however, if you write 16-bit code, you run the risk of it not being compatible with future OS's
certainly, it is difficult to run 16-bit programs under 64-bit versions of vista or win 7

but - moving to 32-bit code doesn't seem to be the end-all answer, either
particularly with win7 - drivers essentially must be WHQL digitally-signed   ::)

MichaelW

  • Global Moderator
  • Member
  • *****
  • Posts: 969
    • View Profile
Re: MS-DOS int 21 functions should work under XP!!
« Reply #8 on: July 10, 2012, 09:33:43 AM »
NTVDM is intended to support normal, “well behaved” DOS applications. While it does a good job of this, it will not allow you to do the really interesting low-level stuff that you could do under real-mode DOS. IMO knowledge of what it will allow you to do is today of very limited value, and not worth spending much time on.
Well Microsoft, here’s another nice mess you’ve gotten us into.

laskar01

  • Guest
Re: MS-DOS int 21 functions should work under XP!!
« Reply #9 on: July 10, 2012, 10:06:29 AM »
Hi, again, you people!
Yes, you were right Gunther, I had to use LINK16. :t

Hutch, I think that most all of us would prepay a book written by you on similar stuff. As it is now, the Irvine book is the only book that deals with assemblyprogramming under Microsoft platforms. I would like to read a book of you, to understand the stuff you've done. ;)

Couldn't find the Intel ABI in the 7 volume Software developers manual. Does anybody have a link?

I would like to do a boot selector that gives me the choice to choose between WinXP and something stupied printed on the screen.
Maybe I am closing in reading the next chapters on memorysystems and BIOS-programming.

Kindest regards,
Lasse

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 1687
  • Mnemonic Driven API Grinder
    • View Profile
    • The MASM32 SDK
Re: MS-DOS int 21 functions should work under XP!!
« Reply #10 on: July 10, 2012, 10:36:31 AM »
Type "intel abi" into Google. Better info comes from Agner Fog's site. Differentiate between 32 bit and 64 bit, if you write 32 bit, use the 32 bit version, for 64 bit code, use the 64 bit version.

RE: MS-DOS int 21h and int 10h functions, these are kids stuff alongside the Windows API functions and they assume real mode addressing, a tiny 64k world where modern computers break the 4 gig barrier in 64 bit.

Never assume that because something was printed in a book that it is useful, there are no useful 32 b8it assembler books for Windows and the stuff that is available is antique crap. Fine if you want to write legacy 16 bit real mode code for some hardware functions, just set up a box with MS-DOS 6.22 and off you go but you waste your life and time for any other reason.

The best stuff is online and it has been that way for the last 15 years, use the money save from not buying junk books to buy a big screen and read it all online or locally copied to your hard disk.  :bgrin:
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin:

NoCforMe

  • Guest
4DOS (now "Take Command") still available
« Reply #11 on: July 10, 2012, 11:16:36 AM »
I'm not sure if it will run under Windows 8 (due to be released soon) or not, but you can still get JP Software's DOS shell, formerly called 4DOS and now known as Take Command. I couldn't find any specific information about compatibility with different Windows OS flavors, but it looks as if it will run under Windows 7.

I've been using 4DOS for years. (Use it now to create my 32-bit assembly-language programs.) So much nicer than Microsoft's dumbass "command prompt". So perhaps one can write and run 16-bit DOS/INT-21H driven programs under Vista and beyond. (The question "why would anyone want to do that?" is left for the programmer to answer.)

Wait, I just found it:

Quote
Take Command is compatible with any 32 or 64-bit version of Microsoft Windows XP (SP2 or later), 2003, Vista, 2008, Windows 7, and Windows 8. Take Command is available in 32-bit and 64-bit versions.

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 1687
  • Mnemonic Driven API Grinder
    • View Profile
    • The MASM32 SDK
Re: MS-DOS int 21 functions should work under XP!!
« Reply #12 on: July 10, 2012, 11:58:25 AM »
Try using the standard Microsoft CMD.EXE, it works in 32 bit and 64 bit Windows versions just fine.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin:

Zen

  • Member
  • ***
  • Posts: 280
  • slightly red-shifted
    • View Profile
Re: MS-DOS int 21 functions should work under XP!!
« Reply #13 on: July 11, 2012, 05:07:13 AM »
LASKAR 01,
I have a copy of Kip Irvine's book: Assembly Language for Intel-Based Computers, and, what QWORD, VORTEX, GUNTHER, and HUTCH have stated is correct. Large sections of his book are obsolete. Still it makes an excellent reference for a beginning assembly programmer. The descriptions of the most used assembly instructions is valuable as an introduction,...because, you will use that information in every assembly language program you write. Also, the code that accompanies the book is overly simplistic; he never invokes that standard Windows API version that is normally used in Windows 32-bit programs...and, you'd be surprised how many people that are using that book as a guide to assembly programming post questions here. Irvine's code works well only with other routines that Irvine has provided with his library,...and, this is by design.
Zen

dedndave

  • Member
  • *****
  • Posts: 6434
  • Still using Abacus 2.0
    • View Profile
Re: MS-DOS int 21 functions should work under XP!!
« Reply #14 on: July 11, 2012, 05:23:08 AM »
yah...
Kip Irvine and Randy Hyde are both fine authors
their books are a bit outdated, however

while they still provide some good information, it is hard for a beginner to know which parts of the books are usable in win32 and which parts are not