News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Assume gs: ????

Started by katvis, March 09, 2011, 02:13:42 PM

Previous topic - Next topic

katvis

I am trying to assemble an application but the compiler return a error. I have read and searched this forum but the ASSUME threads I could find does not really apply to my piece of code, can anybody please give me advise and tell me how to use the ASSUME instruction correctly in the below code?

;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;GET PORT STATUS SUBROUTINE
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
GetPortStatus:  ;       Address reading ...

                ;       40:00       COM1 address
                ;       40:02       COM2
                ;       ...
                ;       40:0E       LPT4     

                xor     eax,eax
                xor     edx,edx
                xor     esi,esi

ASSUME GS:  what should I place here ???
               mov     bx,40h
                mov     gs,bx
                mov     si,00h
                mov     edx,offset Addr1
                mov     edi,offset E040
                mov     ecx,8
ScanAddress:   ;mov     ax,word ptr gs:[si]  ;If I comment this line out the code assemble and I can open the app, if I do not comment this line the program assemble but the program does not open then.
                mov     [edx],ax                 
                cmp     ax,0
                je      JumpIt
                push    ecx
                push    edx   
                INVOKE  wsprintfA,offset NumBuffer,offset Format2,eax
                add     esp,0Ch
                pop     edx
                pop     ecx
                mov     eax,[edi]
                push    edx
                push    ecx
                push    gs
                INVOKE    SendMessageA,eax,000Ch,0,offset NumBuffer
                pop     gs
                pop     ecx     
                pop     edx 
JumpIt:         add     edx,2
                add     edi,4
                add     esi,2
                xor     eax,eax
                loop    ScanAddress   

ASSUME GS:NOTHING

rest of subroutine follow here.....


dedndave

you shouldn't have to use ASSUME in this case
because you are not directly accessing an address in that segment

i am not sure how well newer versions of masm handle those kinds of references
but, the older versions did not always allow it if you specified SEGMENT AT 40h

what i sometimes did was just make a data segment with labels in it

_BIOS   SEGMENT WORD PUBLIC DATA 'BIOS'

        ORG     6Ah
SomeLabel label word

        ORG     6Ch
MoreLabel label word

_BIOS   ENDS


then, you may use ASSUME...

        ASSUME  ES:_BIOS

        mov     ax,40h
        mov     es,ax
        mov     ax,SomeLabel
;
;
;
        ASUME  ES:Nothing

clive

You are certainly not going to be able to access the BIOS data area from within Win32 in this fashion.

If you want to enumerate serial ports go to the registry.

In protected mode you are using selectors not segments. This might work in Win16 using the __0040H import.
It could be a random act of randomness. Those happen a lot as well.

katvis

Thank you very much for the answers, will try a different way. This was a sample program which I tried to compile but I will change it accordingly.
Cheers

clive

Quote from: katvis on March 09, 2011, 03:38:20 PM
This was a sample program which I tried to compile but I will change it accordingly.

It looks like you're trying to port a 16-bit DOS application. Unless you are doing some systems programming you generally won't need to be concerned with segment registers on a Win32 application. FS is used by the TLS (Thread Local Storage) and SEH (Structured Exception Handler), not sure I've had to use GS in quite some time.

You should probably look over the 16-bit code and ponder how to port the desired functionality 15-20 years into the future, in most cases a 1-to-1 translation is not the way to go. If you want to play with 16-bit DOS code you could try the DOS box, or just boot the PC into DOS. XP for instance can format DOS boot floppies.
It could be a random act of randomness. Those happen a lot as well.

vanjast

Where do you go fishing, Vaal... Hartebeespoort ?  :wink

katvis

hahaha nice one..;) not one of those dams. I am immune to fishing..;)




btw, the software I was trying to compile is not 16bit software, it is the FLUXPORT sample program found on Izelions sample source code page.

But now that I understand what the routine is for I have removed the routine and replace with another one to suite, thank you for the advise anyway, much appreciated.