0 Replies - 1495 Views - Last Post: 14 April 2009 - 10:49 PM

#1 no2pencil   User is offline

  • Professor Snuggly Pants
  • member icon

Reputation: 6839
  • View blog
  • Posts: 31,513
  • Joined: 10-May 07

CPU ID

Posted 14 April 2009 - 10:49 PM

Description: Read the CPU ID bit and output to the display
; nasm -f elf -o cpu.o cpu.asm
; ld -s -o cpu cpu.o
section .data
var:  DB 0              ; declare var with value 0
msg:  DB "CPU ID: "		; declare message
len:  equ $-msg         ; the length of msg

section .bss
vendor_id	resd	12	; reserver length of 12

section .text
global _start

_start:
	mov  eax, 0
	cpuid				; call cpu
	mov  [vendor_id],ebx
	mov  [vendor_id+4], ebx
	mov  [vendor_id+8],ecx

	mov  edx, len			; pass message length
	mov  ecx, msg 			; pass message
	mov  ebx, 1			; write to stdout
	mov  eax, 4			; call syswrite

	int 0x80			; call the kernel

	mov edx, 12			; pass length of 12
	mov ecx, vendor_id		; pass vendor id
	mov ebx, 1			; write to stdout
	mov eax, 4			; call syswrite

	int 0x80			; call the kernel

	mov eax, 1			; call sys_exit
	mov ebx, 0			; return zero
	int  0x80			; call the kernel



Is This A Good Question/Topic? 0
  • +

Page 1 of 1