Drive Letter Confusion Past 'K:\'

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
ClarionCoder51
Member
Member
Posts: 28
Joined: Sun Aug 16, 2009 11:52 am
Location: Georgia, USA

Drive Letter Confusion Past 'K:\'

Post 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<
"The n00b zone is for loading and unloading newbies only."
User avatar
NickJohnson
Member
Member
Posts: 1249
Joined: Tue Mar 24, 2009 8:11 pm
Location: Sunnyvale, California

Re: Drive Letter Confusion Past 'K:\'

Post 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"?
User avatar
ClarionCoder51
Member
Member
Posts: 28
Joined: Sun Aug 16, 2009 11:52 am
Location: Georgia, USA

Re: Drive Letter Confusion Past 'K:\'

Post 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
"The n00b zone is for loading and unloading newbies only."
User avatar
NickJohnson
Member
Member
Posts: 1249
Joined: Tue Mar 24, 2009 8:11 pm
Location: Sunnyvale, California

Re: Drive Letter Confusion Past 'K:\'

Post 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
User avatar
ClarionCoder51
Member
Member
Posts: 28
Joined: Sun Aug 16, 2009 11:52 am
Location: Georgia, USA

Re: Drive Letter Confusion Past 'K:\'

Post 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!
"The n00b zone is for loading and unloading newbies only."
Post Reply