Author Topic: Need helps on Floppy VSN  (Read 23437 times)

bug

  • Guest
Need helps on Floppy VSN
« on: April 29, 2005, 06:56:08 AM »
To all the experts in here I really need helps how to get the volume serial number from floppy disk and convert to display it in the dos screen using Nasm.  I'm a newbie in assembly language I just started to learn assembly in less than 3 weeks ago.  Complete simple codes to get and display VSN of floppy on the dos screen would be very appreciate.  Thanks

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: Need helps on Floppy VSN
« Reply #1 on: April 29, 2005, 08:17:14 AM »
Hi bugbyte,

I *know* I've got code around to get/set VSN... my "C" drive has a serial number of "0BAD-F00D" (forgot to save the "right" number before I changed it!)... but I can't find that particular code at the moment.

At first, I read your question as "volume label", which can be found with a simple "findfirst" with the attribute set to 8. But that won't get you the serial number. I guess you use get/set diskinfo - int 21h/69h - to get that...

Here's something I found that may help...

Best,
Frank

org 100h
segment .data
    drmsg db ' Which Drive (a,b,c...)? $'
    vlmsg db " Volume Label: $"
    fsmsg db " File System Type: $"
    snmsg db ' Serial Number: $'
    crlf db 0Dh,0Ah,'$'
segment .bss
    diskinfobuf resb 19h
segment .text
    mov ah,9h
    mov dx,drmsg
    int 21h
    xor ax,ax
    int 16h
    sub al,'a'-1
    mov bl,al
    mov ah,9h
    mov dx,crlf
    int 21h

sub al,al           ; al=0 get, al=1 set serial # (and vl?)
    mov ah,69h         ; get disk info
    mov dx,diskinfobuf  ; ds:dx points to buffer to rec'v info
                        ; (ds should be all set in a COM file)
    xor bh,bh           ; bl=drive 0=default,1=A: ,etc.
                        ; bh="info level" ??? - 0 for dos
    int 21h
    jc exit
    mov ah,9h          ; spew "volume label"
    mov dx,vlmsg
    int 21h
    mov si,diskinfobuf+6  ; offset 6 into the buffer
    mov cx,11             ; 11 bytes of volume label
showvl:
    lodsb
    int 29h
    loop showvl
    mov ah,9h          ; spew a carriage return
    mov dx,crlf
    int 21h
    mov dx,snmsg
    int 21h
    mov ax,[diskinfobuf+4]
    call word2hex
    mov al,'-'
    int 29h
    mov ax,[diskinfobuf+2]
    call word2hex

mov ah,9h
    mov dx,crlf
    int 21h
    mov dx,fsmsg        ; and "file system"
    int 21h
    mov si,diskinfobuf+011h  ; 17 bytes into buffer
    mov cx,8            ; 8 bytes of file system
showfs:
    lodsb
    int 29h
    loop showfs
exit:
    mov ah,4Ch         ; later...
    int 21h

;------------------------------------------------------
; From: qscgz@aol.com (QSCGZ)
; word2hex - call with word in ax
; buffer in di,if you like - rets unterminated string!
; trashes ax,bx
;------------------------------------------------------

word2hex
    mov bx,ax
    shr ax,12
    call nyb2hex
    mov ax,bx
    shr ax,8
    call nyb2hex
    mov ax,bx
    shr ax,4
    call nyb2hex
    mov ax,bx
nyb2hex
    and al,Fh
    cmp al,10
    sbb al,105
    das
    int 29h
;    stosb   ; if buffered
    ret
;---------------------------------------------------------