[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.8

Need help on converting assembler to inline assembly

Asked by gonx in C++ Programming Language

Tags: inline

Im sort of a newbie on this.. need help on having this code in inline assembler for Visual C++ 6.0.. ive been trying to understand why the msdev hangs when it reaches INT 21h after i some of the 16 bit registers to 32 e.g eax,ebx,edi etc..

C++ code is as follows:

#include <stdio.h>
#include "drivesex.h"

main()
{
    int i;

    Drives_Exist();
    for (i = 0; i < 26; i++)
    {
        if (drives[i<<2] == DRIVEXISTS)
        {
            printf("%c: ",i+65);
            printf("%s ",drives[(i<<2)+1] == 0 ? "Removable" : "Fixed    ");

            switch (drives[(i<<2)+2])
            {
                case LOCALDRV :printf("Local  ");
                               break;
                case REMOTEDRV:printf("Remote ");
                               break;
                case SHAREDRV :printf("Shared ");
                               break;
            }

            switch (drives[(i<<2)+3])
            {
                case FLOPPY:printf("Floppy");
                            break;
                case HARD  :printf("Hard");
                            break;
                case RAM   :printf("RAM");
                            break;
                case SUBST :printf("Subst");
                            break;
                case CDROM :printf("CD-ROM");
                            break;
            }

            printf("\n");
        }
    }
}

the asm code is included separately as an ASM file:

; DRIVESEX.ASM - Drive existence detection      July 6th, 1994
; Code by       : Lee Hamel (hamell@cs.pdx.edu)
; Partial credit: Paul Schlyter
;
; Goes through drives A-Z and determines if they:
; 1) Exist
; 2) Are removable or fixed
; 3) Are local, remote, or shared
; 4) Are a floppy, hard, RAM, subst, or CD-ROM drive
;
; Callable from C as: void Drives_Exist(void);

.model small
.286

DRIVEEXIST      EQU     1

REMOVEDRV       EQU     0
FIXEDDRV        EQU     1

LOCALDRV        EQU     0
REMOTEDRV       EQU     1
SHAREDRV        EQU     2

FLOPPY          EQU     0
HARD            EQU     1
RAM             EQU     2
SUBST           EQU     3
CDROM           EQU     4

.data
PUBLIC  _drives
        _drives         db      26 dup(0,1,0,1)
        ; default to not exist, fixed, local, hard drive

.code

                        PUBLIC  _Drives_Exist
_Drives_Exist           PROC    NEAR
                pusha
                push    es

                mov     ah,19h
                int     21h             ; get start drive
                push    ax              ; save start drive

                mov     ax,40h
                mov     es,ax
                mov     bh,es:[10h]     ; 40:10h is # of floppies-1
                shr     bh,6
                inc     bh              ; # of actual floppy drives
                mov     bl,1
                mov     di,offset _drives
nextchkfloppy:  mov     ax,4409h        ; check if drive exists
                int     21h
                jc      nextsetfloppy
                test    dh,10000000b    ; check if SUBST drive
                jz      chkfloppy
                dec     bh              ; dec actual drive count
                mov     byte ptr [di+3],SUBST
setfloppyexist: mov     byte ptr [di],DRIVEEXIST
                jmp     nextsetfloppy
chkfloppy:      dec     bh              ; dec actual drive count
                js      nextsetfloppy
                mov     byte ptr [di+1],REMOVEDRV
                mov     byte ptr [di+3],FLOPPY
                jmp     setfloppyexist
nextsetfloppy:  add     di,4
                inc     bl
                cmp     bl,2            ; if B then jump back
                je      nextchkfloppy

                mov     ch,24           ; loop 24 times (drives C - Z)
                mov     cl,3            ; start at C:
drivechkloop:   mov     ax,4409h        ; check if drive exists
                mov     bl,cl           ; set drive letter
                int     21h             ; 0 = default, 1 = A:, etc.
                jc      nextsetdrv
                mov     byte ptr [di],DRIVEEXIST
                mov     ax,4408h        ; check if removable
                int     21h
                mov     byte ptr [di+1],al      ; set REMOVABLE or FIXED
                mov     bx,dx
                mov     dl,dh
                shr     dl,7
                and     dh,00010000b
                shr     dh,4
                mov     byte ptr [di+2],dh      ; set REMOTE or LOCAL
                or      dl,dl                   ; if not SUBST, then jump
                jz      chkremote
                mov     byte ptr [di+3],SUBST
                jmp     nextsetdrv

chkremote:      cmp     dh,REMOTEDRV    ; if REMOTE, then check for CD ROM
                je      chkcdrom

                test    bh,00000010b    ; sharable?
                jz      drivenoshare
                mov     byte ptr [di+2],SHAREDRV
drivenoshare:   test    bl,00000010b    ; RAM drive?
                jnz     nextsetdrv
                mov     byte ptr [di+3],RAM
                jmp     nextsetdrv

chkcdrom:       push    cx
                mov     ax,1500h
                xor     bx,bx
                int     2fh
                pop     cx
                or      bx,bx           ; MSCDEX driver found?
                jz      nextsetdrv      ; if not, jump to next drive setup
                mov     ax,150bh
                dec     cl              ; 0=A:, etc.
                int     2fh
                inc     cl
                or      ax,ax
                jz      nextsetdrv      ; drive supported by MSCDEX?
                mov     byte ptr [di+3],CDROM

nextsetdrv:     add     di,4
                inc     cl
                dec     ch
                jnz     drivechkloop

                pop     dx
                mov     ah,0eh
                int     21h             ; reset start drive

                pop     es
                popa
                ret
_Drives_Exist           ENDP

                        END

Thanks.. i would be grateful to anyone who can answer..
[+][-]02/27/03 04:14 AM, ID: 8032906Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02/27/03 06:12 AM, ID: 8033667Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02/27/03 07:16 AM, ID: 8034200Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02/27/03 08:22 AM, ID: 8034694Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02/27/03 08:24 AM, ID: 8034712Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02/27/03 08:41 AM, ID: 8034838Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02/27/03 09:12 AM, ID: 8035083Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02/27/03 09:33 AM, ID: 8035268Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02/27/03 03:19 PM, ID: 8037790Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02/27/03 03:56 PM, ID: 8037975Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02/27/03 07:08 PM, ID: 8038965Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02/27/03 07:09 PM, ID: 8038973Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02/27/03 11:14 PM, ID: 8039995Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02/28/03 03:57 AM, ID: 8041007Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02/28/03 06:35 AM, ID: 8041977Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02/28/03 06:43 AM, ID: 8042029Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02/28/03 06:49 AM, ID: 8042091Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: C++ Programming Language
Tags: inline
Sign Up Now!
Solution Provided By: nietod
Participating Experts: 3
Solution Grade: A
 
[+][-]02/28/03 09:01 AM, ID: 8043119Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02/28/03 05:19 PM, ID: 8045776Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-89