HexToString

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Cleptography
Posts: 287
Joined: 16 Mar 2011 19:17
Location: scriptingpros.com
Contact:

HexToString

#1 Post by Cleptography » 26 Jun 2011 08:30

So I added function HexToString for AutoCom which does exactly what it states. For instance if I do AutoCom HexToString 0x07 it makes a beep sound. Anyone know what the hex value to open the CD tray is?
I figure this function will probably be used to convert colors for the text.

Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: HexToString

#2 Post by Ed Dyreen » 06 Jul 2011 05:14

Code: Select all

; this utilitie opens/closes the CD door.  It doesn't print anything
; to the screen so that it can be 'cleanly' used in a batch file.
;
; util to open/close the CD door.
; CDDOOR +D  (or -D)
;  where + denotes open and - denotes close
;  where D is the drive letter (A - Z) (upper case)

; assembled with NBASM
; http://www.frontiernet.net/~fys/newbasic.htm

.model tiny
.code
           mov  al,[0082h]              ; get first char on command line
           cmp  al,'+'                  ; + opens the door
           jne  short NotOpenIt
           mov  byte Job,00h            ; open the door
           jmp  short GetDrive
NotOpenIt: cmp  al,'-'                  ; - closes the door
           jne  short NotBuzyo          ; invalid job
           mov  byte Job,05h            ; close the door
           jmp  short GetDrive

GetDrive:  mov  al,[0083h]              ; get second char on command line
           cmp  al,'A'                  ; if it is 'D' or less then
           jb   short JustDoIt          ;  just assume 'D'
           cmp  al,'Z'                  ; if it is 'Z' or more then
           ja   short JustDoIt          ;  just assume 'D'
           sub  al,'A'                  ; D = 3, E = 4, ...
           xor  ah,ah                   ;
           mov  device,ax               ; put in device

JustDoIt:  mov  bx,offset ioctlo        ; Do the I/O
           mov  [bx+16],ds              ; data seg
           mov  cx,device               ;
           mov  ax,1510h                ;
           int  2Fh                     ;
           mov  bx,offset ioctlo        ;
           mov  dx,[bx+3]               ; status
           xor  ax,ax                   ; assume no error
           test dx,8000h                ;
           jz   short NoRetErr          ;
           mov  al,02h                  ; other error
NoRetErr:  test dx,20h                  ;
           jz   short NotBuzyo          ;
           mov  al,01h                  ; busy error

NotBuzyo:  mov  ah,4Ch                  ; Exit program, close files
           int  21h                     ; and return to DOS

device     dw  03h                      ; 3 = D:, 4 = E:, etc.
Job        db  0                        ; cc   (00 = Open it, 05 = close it)
ioctlo     db  13,0,12                  ; rhlen,subu,comc
           dw  00h                      ; status
           dup 8,0                      ; reserved
           db  0                        ; mdb
           dw  offset Job               ; *trandad (off)
           dw  00h                      ; *trandad (seg)
           dw  01h,00h                  ; tranct,ssn
           dw  00h,00h                  ; *volid
.end

Cleptography
Posts: 287
Joined: 16 Mar 2011 19:17
Location: scriptingpros.com
Contact:

Re: HexToString

#3 Post by Cleptography » 06 Jul 2011 06:37

Sorry Ed it was a question which had no correct answer as the characters were nothing more than ASCII control characters, and open CD tray is not one of them. You would have to use a combination of 0x11-0x14. This is a bad thread. :cry:

Post Reply