Author Topic: CPU type & FPU type  (Read 6622 times)

Offline S Mahen

  • Jr. Member
  • *
  • Posts: 21
CPU type & FPU type
« on: June 09, 2014, 11:45:49 AM »
Hi,
First of all thanks to forum for supporting me to develop ALP using nasm.
Last year when I joined the forum I was new to ALP using nasm.

Now I am comfortable with ALP.

I want to develop few more ALPs and one of them is displaying CPU & FPU type.

Please help me to start writing program.

Thanks in advance...

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: CPU type & FPU type
« Reply #1 on: June 09, 2014, 12:51:00 PM »
I like to start with "global _start". :)
Code: [Select]
; nasm -f elf32 cpuname.asm
; ld -o cpuname cpuname.o -m elf_i386

global _start

section .bss
    namestring resb 49

section .text
_start:

    mov eax, 80000000h
    cpuid
    cmp eax, 80000004h
    jb exit
   
    mov edi, namestring

    mov eax, 80000002h
    cpuid
    call savestring

    mov eax, 80000003h
    cpuid
    call savestring

    mov eax, 80000004h
    cpuid
    call savestring
    mov al, 10
    stosb

    mov ecx, namestring
    mov edx, 49
    mov ebx, 1
    mov eax, 4
    int 80h

exit:
    mov eax, 1
    int 80h
;----------------

;----------------
savestring:
    stosd
    mov eax, ebx
    stosd
    mov eax, ecx
    stosd
    mov eax, edx
    stosd
    ret
;----------------

You can do quite a lot more with cpuid, of course.

Best,
Frank


Offline S Mahen

  • Jr. Member
  • *
  • Posts: 21
Re: CPU type & FPU type
« Reply #2 on: June 14, 2014, 06:05:48 AM »
Thanks Frank.

It is showing CPU Type.

What about FPU?

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: CPU type & FPU type
« Reply #3 on: June 14, 2014, 06:54:09 AM »
I don't know. Might be a bit in one of the cpuid functions that will tell you whether you've got one (you do). I don't know how to check capabilities. osdev.org might have info on it.

Best,
Frank

Edit: Here ya go:
http://wiki.osdev.org/FPU#Detecting_an_FPU
« Last Edit: June 14, 2014, 07:02:24 AM by Frank Kotler »

Offline S Mahen

  • Jr. Member
  • *
  • Posts: 21
Re: CPU type & FPU type
« Reply #4 on: June 14, 2014, 07:07:36 AM »
Surely I will try and let you know.

Thanks.