🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.msdos.programmer
Article #5949

Re: I can't get SHR EAX,16 to work in protected mode ...

#5949
From: Robert Hartill
Date: Thu, 25 Apr 1991 13:10
66 lines
2678 bytes
In article <1991Apr22.204217.29963@cm.cf.ac.uk> I wrote..

	STUFF DELETED
>
>After I shift EAX 16 places to the right (to get at the top 16bits) EAX seems
>to contain 0. 
>
>Even if I do..
>	MOV EAX,12345678h
>	SHR EAX,16
>	call print_hex
>
>I still get 0.
>
>N.B print_hex works fine for the lower 16bits.

I have now fixed the problem...

I had two replies which suggested that my assembler was assembling 
a 16-bit segment, and that it was silently 'chopping' the 32-bit number
12345678h into 5678h

This was not so, the problem was that I used the program on page 232
of '80386 Microprocessor Handbook' by Pappas and Murray, as a template for
my own program.

Their program is intended for both '286 and '386 processors, and hence uses
16-bit segments.

I checked with the Intel '386 Micro' Prog' Ref' Manual to ensure that segment
descriptors were set correctly, and all seemed fine.

BUT, I was assembling 32-bit segments, and giving them 16-bit descriptors

All that was necessary was to set 1 bit in the descriptors.

I blame the Intel manual, looking at page 6-3 I was given the impression that
my descriptors were okay,
True, if I had read page 5-12 I would have spotted the problem, but looking at
page 6-3, there's nothing there clearly stating that the descriptors are for
16-bit segments.

Before you flame with RTFM, I did read it, but due to the lack of an index,
I unfortunately referred to page 6-3 rather than 5-12 for the reference. 

>
>-----
>When I tried
>	PUSH EAX
>	POP  AX
>	POP  AX
>

This can also be explained by the 16/32-bit segments..

----------
Thanks to those who replied by e-mail.
			        	-rob.
 
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::     Robert Hartill, Dept Of Computing Mathematics, UWCC, Cardiff, UK.     ::
::          e-mail : rhl@cm.cf.ac.uk         Fax : 0222 666182               ::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
He has Van Ghough's ear for music.
-Orson Welles.
-------------------------------------------------------------------------------
Technical Details
Message-ID: <1991Apr25.131056.28185@cm.cf.ac.uk>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!cs.utexas.edu!uwm.edu!wuarchive!uunet!mcsun!ukc!cf-cm!rhl
References: <1991Apr22.204217.29963@cm.cf.ac.uk>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!cs.utexas.edu!uwm.edu!wuarchive!uunet!mcsun!ukc!cf-cm!rhl
From: rhl@computing-maths.cardiff.ac.uk (Robert Hartill)
Newsgroups: comp.os.msdos.programmer,alt.lang.asm
Subject: Re: I can't get SHR EAX,16 to work in protected mode ...
Message-ID: <1991Apr25.131056.28185@cm.cf.ac.uk>
Date: 25 Apr 91 13:10:56 GMT
References: <1991Apr22.204217.29963@cm.cf.ac.uk>
Sender: news@cm.cf.ac.uk (USENET News System)
Followup-To: alt.lang.asm
Organization: University of Wales College of Cardiff
Lines: 66