Page 1 of 1

Drive Letter Confusion Past 'K:\'

Posted: Sun Aug 16, 2009 12:08 pm
by ClarionCoder51
Ok. I designed a block of code that displays what drive the os was booted from as the prompt. (ya know, the 'A' and the little arrow thing?) Everything's going nice, until I hit the code for drive K. I kneed to know what the next drive number is supposed to be. Heres some of the code:

Code: Select all


; ==========

; check drive letter

cmp        dl, 0        ; if drive = a
je           driveA

; skip b - i

cmp        dl, 9        ; if drive = j
je           driveJ

; ==========

; prompt crap...

driveA:

lea        si, Acmd
call       print_string
jmp       detect_drive_tail

; yada, yada, yada....

Acmd    db "A:>", 0

Can anyone tell me? [-o<

Re: Drive Letter Confusion Past 'K:\'

Posted: Sun Aug 16, 2009 12:13 pm
by NickJohnson
What exactly about the letters L-Z makes this harder? It seems like you could just keep going the way you are.

Also, it would take much less space and code to just add dl to the ASCII value for A and print that, instead of creating strings for each possible drive letter prompt. Or at least make an array of strings to print and use dl as an offset - that's also constant time, and more portable.

Edit: Wait, are you looking for "cmp dl, 10"?

Re: Drive Letter Confusion Past 'K:\'

Posted: Sun Aug 16, 2009 12:18 pm
by ClarionCoder51
so i would just say

dl, 10
dl, 11
dl, 12

and keep going?

*Edit: wait...I had know idea at the time that I could do that. It seems that every time I try to do something like this, I end up doing it the hardest way possible. But atleast it still works in the virtual machine. :D

Re: Drive Letter Confusion Past 'K:\'

Posted: Sun Aug 16, 2009 1:01 pm
by NickJohnson
ClarionCoder51 wrote:so i would just say

dl, 10
dl, 11
dl, 12

and keep going?

*Edit: wait...I had know idea at the time that I could do that. It seems that every time I try to do something like this, I end up doing it the hardest way possible. But atleast it still works in the virtual machine. :D
Yeah, that should work.

Imho the easiest way would be this, which just generates the prompt string on the fly:

Code: Select all

lea di, prompt
mov al, [di]
add al, dl
mov [di], al

lea si, prompt
call print_string
jmp detect_drive_tail

prompt: dd "A:>", 0x00

Re: Drive Letter Confusion Past 'K:\'

Posted: Sun Aug 16, 2009 1:06 pm
by ClarionCoder51
Thanks!! It's so simple, yet so difficult to design when you're writing the original code down in a fat notebook on a roadtrip to South Carolina!