News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Solutions to save 1/2 CPU registers inside a procedure

Started by RuiLoureiro, June 04, 2018, 01:58:26 AM

Previous topic - Next topic

jj2007

Quote from: RuiLoureiro on June 05, 2018, 12:56:26 AMzedd151 say that it doesnt identify the frequency of his CPU
The PrintCpu macro shows the brand string supplied by the CPU through cpuid. The real frequency may differ from that (although it shouldn't...).

zedd151

Quote from: RuiLoureiro
but zedd151 say that it doesnt identify the frequency of his CPU (AMD ?)


Yup, if you notice what it does say about my cpu, notice how long the description is...

Quote
AMD A6-9220e RADEON R4, 5 COMPUTE CORES 2C+3G   (SSE4)


A little "over-the-top" description if I say so myself.
They could have done without the "5 COMPUTE CORES 2C+3G" part. My cpu has 2 cores, no matter how they try to inflate the description to make it sound better, even magical.   8)

Quote from: jj2007
The PrintCpu macro shows the brand string supplied by the CPU through cpuid. The real frequency may differ from that (although it shouldn't...).

The specs list my cpu speed as 1.60 Ghz. It fluctuates a little, but nothing to write home about. It IS a little netbook after all.

RuiLoureiro

Hi zedd151,
                 As you are seeing i am trying to solve the CPU identification  problem and i am sure that Jochen may solve it, he is the author of the that code and i trust him.
Thanks for your work.         

zedd151

#18
Quote from: RuiLoureiro
As you are seeing i am trying to solve the CPU identification  problem and i am sure that Jochen may solve it

Quote from: JJ
The PrintCpu macro shows the brand string supplied by the CPU through cupid

Therefore he may not be able to solve my case. The string for my cpu apparently is longer than anticipated by cupid. Still there may be a work around for these special cases. I'm always a special case it seems.   :P

This is what is displayed in 'System' info...

felipe

I know there's an option in the bios configurations regarding a max number used with the cpuid instruction, but i don't know now (i don't want to reboot now  :biggrin:) if it has something to do with the "big string identification" issue... :idea:

RuiLoureiro

 :biggrin:
zedd151,
          If you say "he may not be able to solve my case" the case seems to be solved.
          What can we do ?
Regards
:icon14:

zedd151

 :biggrin:

Rui

LOL


:P

Next time I'll trade this one in for one with a cpu with a short name.   (i286)  lol

jj2007

Quote from: zedd151 on June 05, 2018, 07:38:22 AMThe string for my cpu apparently is longer than anticipated by cupid.

The PrintCpu macro has a 124 byte buffer, your string is only about 50 bytes long. I'd love to see in a debugger what's actually happening there...

From the manuals: The brand string is architecturally defined to be 48 byte long: the first 47 bytes contain ASCII characters and the 48th byte is defined to be null (0).

zedd151

#23
Aha! Maybe.

"AMD A6-9220e RADEON R4, 5 COMPUTE CORES 2C+3G   (SSE4)" is 54 bytes long.
Possibly the cpu speed is overwritten by "(SSE4)" ???

anyway I'll run the testbed through xdbg to see what's happening there, when I get a few minutes to spare.

***** a little while later ******


I used a testbed with smaller code and found that "AMD A6-9220e RADEON R4, 5 COMPUTE CORES 2C+3G   " is written first. Did not find 1.60 Ghz get written anywhere. The (SSE4) was appended later in the console window. the reason I did not use the testbed from this thread is because it takes an eternity to run in a debugger.

JJ could you write a small piece that only displays my cpu info, as in the testbed in this thread?

Would make debugging a lot easier with less code to wade through.  I will post those results from x32dbg as well as screen shots of the debugging.


jj2007

Quote from: zedd151 on June 05, 2018, 09:05:38 AMJJ could you write a small piece that only displays my cpu info, as in the testbed in this thread?

I suspect that your CPU doesn't follow the specs saying the brand string is up to 48 bytes long, including the zero delimiter. In fact, the PrintCpu macro is designed to yield 48 characters. The attached variant allows up to 112 bytes, but I wonder if it works with old CPUs.

Here is the relevant part: sub esp, 124 ; create a buffer for the brand string
mov edi, esp ; point edi to it
xor ebp, ebp
.Repeat
lea eax, [ebp+80000002h]
db 0Fh, 0A2h ; cpuid 80000002h-80000004h
stosd
mov eax, ebx
stosd
mov eax, ecx
stosd
mov eax, edx
stosd
inc ebp
.Until ebp>=3+pcup


pcup is for testing your case. The first string (pcup=0) is obtained with 3x4xstosd, i.e. 48 bytes, the second (pcup=2) with 5*4*stosd, 80 bytes. We'll see how that changes the output. Note that when I wrote "from the manual" above, it was probably an Intel manual 8)

sinsi

From the AMD manual
QuoteThe three extended functions from Fn8000_0002 to Fn8000_0004 are initialized to and return a null terminated
ASCII string up to 48 characters in length corresponding to the processor name. (The 48 character maximum
includes the null character.)

QuoteThe processor name string must be programmed by the BIOS during system initialization.

Anyway, how can you get more than 48 bytes from 3 CPUID calls returning 16 bytes each?

zedd151

Thanks jochen.

Here is my results with the test piece you posted:


AMD A6-9220e RADEON R4, 5 COMPUTE CORES 2C+3G   (MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, AVX)
AMD A6-9220e RADEON R4, 5 COMPUTE CORES 2C+3G   (MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, AVX)
AMD A6-9220e RADEON R4, 5 COMPUTE CORES 2C+3G


Then the program hangs until a key is pressed (enter) then disappears.
Is that what was supposed to happen, or was there more if I waited?

*---------------------------

I will look into this a little more later. I am getting ready for work at the moment.
I'll give another crack to try and determine if there's anything I can do on my end.

ps. sorry for the hijack, Rui

jj2007

Quote from: zedd151 on June 05, 2018, 09:05:38 AM
"AMD A6-9220e RADEON R4, 5 COMPUTE CORES 2C+3G   (SSE4)" is 54 bytes long.
Possibly the cpu speed is overwritten by "(SSE4)" ???

OK, now I understand the problem: Your brand string is actually 45 bytes long. You didn't find the frequency, and the reason is simply that your cpu doesn't list it in the brand string. Some do, others don't 8)

The SSExx stuff is added later and has nothing to do with the brand string.

@sinsi: See above, .Until ebp>=3+pcup was just a test if the AMD has additional bits & pieces. It doesn't.

zedd151

I just looked at the source snippet


  Inkey Str$("\n\nYour puter has run %3f hours since the last boot, give it a break!", Timer/3600000


LMAO! I can't wait for that at the present time.   :biggrin:

zedd151

Quote from: jj2007
... your cpu doesn't list it in the brand string. Some do, others don't 8)

Wtf. I'm always coming up short in one way or another.   :P
Well for the price I paid for this humble box, I can't complain too much.  8)

I have a notion to write a strongly worded letter to Dell Computers.   :badgrin:


edit to add:
Quote from: jochen
The SSExx stuff is added later and has nothing to do with the brand string.

as verified by my initial debugging