Re: what is wrong?



anachronic_individual wrote:
Can you tell me what could be wrong with the following DOS COM program?

I can take a flying wild-asmed guess! :)

Int 21h/19h returns A=0, B=1, etc.

Int 21h/47h expects (in dl), 0=default, 1=A, 2=B, etc.

The only reason you "should" get no output is if the int 21h/47h fails (carry flag). The only reason it "should" fail, is if you hand it a non-existant drive. After the "xlatb", al will be wrong anyway. I'd "mov dl, al" *before* the "xlatb", and "inc dl" before the int 21h/47h. Or, as Herbert suggests, just use zero for "current" drive - probably easier and less error-prone.

With the exception of that possible "gotcha", your code looks perfectly okay to me. There are a few things that could be simplified or "shortened"... You don't really need the "xlatb" and its table - just "add al, 'A' - 1" would do the translation (possibly not for very high drive letters - I'm not sure if the names beyond 'Z' map to ascii or not - unlikely we care). Good example of how to use "xlatb", though! (might need a "dummy" before "A"?). "lea" is a wonderful instruction. Does arithmetic for you! In your case, there really isn't any arithmetic being done, so "lea" is "overkill". Essentially you're asking "what is the address of the variable whose address is xxxx?". Works perfectly well, but "mov bx, cwdir" is shorter - "mov bx, cwdir + 3" works perfectly well, too. I *often* see this in Masm code - to save having to type "offset", I suppose. With Nasm, you don't have to type "offset" anyway, so "mov" is shorter to type, as well as producing shorter code! :)

But that's nit-picking. "First, make it work. You've got the rest of your life to make it elegant." Try zero in dl, and see if that works.

Best,
Frank
.



Relevant Pages

  • Re: Prime Numbers
    ... struct node *next; ... int main ... which testcase it fails which value of i it fails. ... One reason could be ...
    (comp.lang.c)
  • Re: Value type intialization...
    ... which fails for the same reason; you /must/ give it a starting value, ... Marc ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: K&R2 1.6 Arrays, exercise 1-13 (vertical histogram)
    ... | int main ... I thought you always initialised variables on declaration, ... This, of course, could have been done by initialising on declaration ... (If the latter reason is true, learning it would have done no good here, because Reason 1 would still have applied.) ...
    (comp.lang.c)
  • Re: Coding inside the debugger
    ... but why isn't the test written so that the reason it fails is ... If something fails in tests like these, ... public void testCreateWithDefaultthrows Exception { ... Ghostworld world = worldWithClass; ...
    (comp.object)
  • Re: I need help please!
    ... It is documented on some systems I've use a lot as a standard way of exiting at any point. ... Any software written for general consumption should deal with unexpected keystrokes for the simple reason that, in the real world, they are very common. ... So you "REASONABLE man's method" fails on a very common system, ... I would say that a "solution" that does not work on a very common platform is NOT a reasonable solution. ...
    (comp.lang.c)