Re: Disk I/O, BIOS, dosemu, FreeDOS, linux host with Virtual Machines



Pop Tart wrote:
Hello,

I've come to a point in my study of MASM where I can't work the examples for
disk I/O unless I have Windows 98 or less.

Is that a signed "less" or an unsigned "less"? :)

I'm also wondering if I'll be
able to work the BIOS interrupt examples because I run WinXp as a
VirtualBox guest VM on a Linux host - I'm not sure how VirtualBox will
respond to BIOS interrupts.

I don't know. I've run dosemu... not enough to really know what it does, but enough to know that it isn't "exactly like dos".

At some point I want to attempt to write a defrag program in assembly, so
I'd really like to learn more about Disk I/O.

Okay... There's more to "defrag" than disk I/O, and there's disk I/O outside of bios interrupts. Not running dos doesn't rule it out entirely.

What are my best options? FreeDos as a guest with VirtualBox, FreeDos and
dosemu on linux? Download an illegal copy of win98 and use that as a VM
guest? (though I'm still not sure about win98/DOS BIOS interrupt in
VirtualBox).

I'm not sure why you'd want Win98. I know it comes with "real dos", but in a "dos box", the bios interrupts are "fake" (I mean "emulated"). I think you'd want "real bios interrupts", if you're going to study them. I hope you've got a (working) floppy drive. That'll make it easy to boot to "real dos", or to your own boot sector, if you want to get even "lower level" than dos. It'll also give you a drive to "practice" on. Writing to a hard drive can get you into a world of pain if you screw up! You'll want to have a "rescue disk" on hand - a "live CD" would probably be okay, or a floppy, or a spare hard drive that's *not* in the machine while you're experimenting/learning.

I'm slowly moving away from windows - I've caught the linux bug!

Windows is winning the "popularity contest" by a wide margin, but I find Linux quite "interesting" to work with. (when you get to the "defrag" level, though, there are a lot of file systems to deal with, which won't make it easy). You're a little farther from the hardware, but you *can* get to it, with some mumbo-jumbo.

So, I'm
wondering if I should just start learning NASM and linux interrupts - I
know "next to nothing" about linux programming now.

We all start out equal in that regard. There's Linux Programming, and there's Assembly Linux Programming. The latter is an oxymoron - Linux is portable, asm is not. You're not "supposed" to do it in asm, and there are good reasons for this. But we *can*, and it's "educational", if nothing else. If you should come up with something "useful", it will be useful to a large number of people, even if not "all Linux users". A majority of a minority, if you will...

If you wanted to make this transition "stepwise", you could start using Nasm for some dos projects that you've already got working in Masmese, and make the transition to Linux when you're comfortable with Nasm. But the jump from dos in Masm to Linux in Nasm isn't *that* great. Linux is *not* "dos on steroids", but at a beginner level, it's a lot like dos (or can be). As you get into something more "advanced" (which I haven't, much) it gets more complicated - but this would also be true of Windows, or even dos...

If this is the best
route to go, can I find NASM include files and libraries for linux and/or
windows (like masm32 provides for masm/windows api).

Sure... or even if it isn't the "best" route... The MASM32 project is a bit more mature than anything for Nasm - kudos to Hutch and helpers for keeping that up! You may not find the Nasm stuff quite as "complete" (I'm not too familiar with either). But it'll include stuff like "invoke" and "proc" (maybe "if" and all), which Nasm doesn't have "built in". The "equates" are the most important part (?), and that should be pretty much the same. For Windows:

http://www.asmcommunity.net/projects/nasmx/

The Nasmx Project - formerly called NASM32 - is the "latest and greatest"... I ASSume they include all the "good stuff" from other Nasm include files - "nagoa+.inc", and all. If not... I'm sure they welcome contributions, and/or you can "mix and match" the "good parts" according to your taste. (but beware the "Tower of Babel"!).

There's a Linux section to Nasmx, too (and Xbox!), but the Linux section is not (yet) as extensive (the Xwindows .inc is better) as the include files available as the "asmutils" package. Part of http://linuxassembly.org a.k.a. http://asm.sf.net - the asmutils package is for more than Linux - BSD and other *nixish systems are included. This makes the package a bit of a PITA to use - "system.inc" includes other files, depending on what OS (etc.) is defined. So you need "-d__LINUX__ -d__ELF__ ..." defined - on the command line, or in an environment variable, or in the source (if you don't mind locking yourself out of the flexibility), or in a Makefile. Easily done, but if it isn't, perfectly good source will refuse to assemble... This has got a good selection of "equates" (and structure definitions) - any missing ones can be found in the appropriate C header file(s) (somewhat scattered around). There's a utility available to convert .h files to Nasm-syntax .inc files (with pretty good success). Great thanks to Johannes Kroll for that one! Works for Windows, too:

http://home.comcast.net/~fbkotler/h2incn-0.5.tar.gz

So include files can be improved/updated as needed...

Regarding NASM, what book or online source can help bring me up to speed
quickly - to where I am presently with masm assembly... ie, skip all the
explanations of adc,mul,sbb,mov,movzx,lea, register/memory explanations,
etc?

Well... the Nasm manual has conveniently removed the "adc" section for ya. :) That, and a few examples, should get you through the Masm-Nasm transition.

Getting up to speed with Linux is a longer-term proposition. As I said, it's "easy as dos" at first... "The" book on Unix programming, I understand (haven't read it), is W. Richard Stevens' "Advanced Programming in the Unix Environment". This is C, not asm. Another C one - available online - "Advanced Linux Programming" by Mark Mitchell, Jeffrey Oldham, and Alex Samuel, of CodeSourcery LLC:

http://www.advancedlinuxprogramming.com/

Despite C, they're relevant, I think. Getting to assembly, Richard Blum's "Professional Assembly Language":

<http://www.wrox.com/WileyCDA/WroxTitle/productCd-0764579010,descCd-tableOfContents.html>

Or Bob Neveln's "Linux Assembly Language Programming":

<http://books.google.com/books?hl=en&id=pbB8Z1ewwEgC&dq=neveln&printsec=frontcover&source=web&ots=pqVw4xiug7&sig=QTxCp1UFnnH3wxebElKrfvxqVDE#PPR7,M1>

Exist... I haven't read any of 'em. I've looked at (and liked) Jonathan Bartlett's "Programming From the Ground Up" - asm for Linux, but Gas rather than Nasm (a greater transition than Masm<->Nasm, I think, but not impossible):

http://www.cafepress.com/bartlettpublish.8640017

Or the "free, as in freeloader" version:

http://savannah.nongnu.org/projects/pgubook/

The examples from that book have been translated to Nasm syntax, and are available here:

http://mysite.verizon.net/fbkotler/nasm-pgu-examples.tar.bz2

if you'd care to attempt to read the book about Gas and use Nasm...

Paul Carter's tut is for Windows or Linux or BSD (achieved by using a lot of C):

http://www.drpaulcarter.com/pcasm/

Might be too much on the "adc, registers and memory" side for you - I wouldn't write that stuff off completely yet - there may be subtleties you haven't mastered - but the Intel/AMD manuals are probably the best source for that...

Here's another Linux assembly tutorial I haven't looked at for a while - looks pretty good:

http://docs.cs.up.ac.za/programming/asm/derick_tut/

I should mention Jeff Owens' AsmIde:

http://members.save-net.com/jko%40save-net.com/asm/

I'm a "command line guy", and don't use the IDE, but the "AsmRef" section is *great* - rare Linux documentation aimed at asm!

That's probably enough to get you started... if you want to pursue this, we can probably come up with examples... something reading "infile" and writing to "outfile" to start with, and maybe get to some "lower level" disk I/O... there are a couple of things I've been meaning to try... Bios ints in Linux *are* possible - there's a "Linux Real Mode Interface" library - http://lrmi.sf.net - but definitely not a beginner project!

Best,
Frank

.



Relevant Pages

  • Re: Install Firefox questions
    ... > I would recommend to you that you wait for your harddisk and install SuSE ... I downloaded using Windows ... LINUX was in 1996 when I had a triple boot system (DOS, LINUX, and ... I never crashed DOS except once intentionally, ...
    (alt.os.linux.suse)
  • Re: Linux? Void my warantee? Make tech support impossible?
    ... from basic DOS to DesqViewX ... though Windows XP is an improvement ... >techniques Linux attacks at most wipe out the compromised account. ... to be ripping off his customers. ...
    (comp.os.linux.misc)
  • Re: Linux? Void my warantee? Make tech support impossible?
    ... from basic DOS to DesqViewX ... though Windows XP is an improvement ... >techniques Linux attacks at most wipe out the compromised account. ... to be ripping off his customers. ...
    (alt.os.linux.suse)
  • Re: Why complicated directory structure in Linux
    ... the internal calls of DOS. ... Then came Windows and it was a kludge not a wrapper on DOS. ... The one that got me to linux was the regular disk crashes where I had to ...
    (comp.os.linux.setup)
  • Re: New to Debian Linux - I have NASM experience under DOS 6.22
    ... > simple NASM program under Linux. ... > whether there is a more official or reliable way to make a NASM ... Windows automatically including the "current directory" in the ... directory" is NOT part of that PATH as it is with DOS... ...
    (alt.lang.asm)