rhl@computing-maths.cardiff.ac.uk (Robert Hartill) (04/23/91)
Please, Please, Please HELP.. This problem has been driving me mad for days now, I've got a protected mode program for a 80386, I've set up the first 30 interrupts to a routine I have which prints the register contents.. I do this by moving the register into EAX, and print one hex digit at a time from EAX.. 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. ----- When I tried PUSH EAX POP AX POP AX which I would expect to leave the high 16bits of EAX in AX, all hell breaks loose, the ISR appears to be re-entered before it completes.. -sorry I can't explain it better, you have to see it to appreciate it. ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: Robert Hartill, Dept Of Computing Mathematics, UWCC, Cardiff, UK. :: :: e-mail : rhl@cm.cf.ac.uk Fax : 0222 666182 :: ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: Thank heavens, the sun has gone in, and I don't have to go out and enjoy it. -Logan Pearsall Smith. -------------------------------------------------------------------------------
dbenhur@adobe.COM (Devin Ben-Hur) (04/24/91)
In article <1991Apr22.204217.29963@cm.cf.ac.uk> rhl@computing-maths.cardiff.ac.uk (Robert Hartill) writes: > MOV EAX,12345678h > SHR EAX,16 > call print_hex > >I still get 0. I suspect the default base in your assembler is hex and you're actually shifting by 22 bits. 0 is a funny answer (0x48 would be correct) but maybe you're not relating the precise values and this is really your problem... I just tried a test in Turbo Debugger 386 and MOV EAX,12345678 SHR EAX,10 produced 00001234 as expected. -- --- Devin Ben-Hur dbenhur@adobe.com 415/962-6074 drazil@netcom.com "Me, not Adobe"
rhl@computing-maths.cardiff.ac.uk (Robert Hartill) (04/25/91)
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. -------------------------------------------------------------------------------