AT&T汇编试讲--获取CPU Vendor ID
纯汇编代码如下:
# a test program to get the processor vendor id # data segment
.section .data
output:
.ascii "The processor Vendor id is 'xxxxxxxxxxxx'\n" # code segment
.section .text
.global _start
_start:
movl $0,%eax
cpuid
movl $output,%edi # 将output位置加载进edi
movl %ebx,28(%edi) # 将结果最低4字节,即ebx中的值放到edi+28内存位置处
movl %edx,32(%edi) # 结果中间4字节
movl %ecx,36(%edi) # 结果最高4字节 # 接下来显示信息
movl $4,%eax # 内核执行的显示函数代号
movl $1,%ebx # 要写入的文件描述符
movl $output,%ecx # 字符串的初始位置
movl $42,%edx # 字符串的长度
int $0x80 # 软件中断,执行系统调用 # 退出程序
movl $1,%eax # 退出代码
movl $0,%ebx
int $0x80
如果要用gcc编译的话,注意程序的起始处标签就不能是_start了,要改为main
反汇编cpuid.o:
在汇编中调用C函数:
.section .data
output:
# printf函数要求以空字符结尾的字符串,所以为asciz
.asciz "The processor vendor id is '%s'\n" .section .bss
# 12字节的缓冲区域
.lcomm buf,12 .section .text
.global _start
_start:
movl $0,%eax
cpuid
movl $buf,%edi
movl %ebx,(%edi)
movl %edx,4(%edi)
movl %ecx,8(%edi)
# 给printf传参数
pushl $buf
pushl $output
call printf addl $8,%esp
# 给exit传递参数
pushl $0
call exit
编译cpuid2.s时,注意下图情况:
-lc:表明要动态链接/lib/libc.so; -dynamic-linker:使用动态加载器查找libc.so
如果用gcc编译,就方便了,因为它能自动链接必需的库
AT&T汇编试讲--获取CPU Vendor ID的更多相关文章
- 汇编实现获取CPU信息
这是文章最后一次更新,加入了TLB与Cache信息等资料前言:论坛上面有人不明白CPUID指令的用法,于是就萌生写这篇文章的想法,若有错误话请大侠指出,谢谢了 ^^论坛的式样貌似有问题,若式样问题导致 ...
- 获取CPU ID ,disk ID, MAC ID (windows ARM linux Mac)
windows 命令行获取CPU ID,可以用ShellExecute wmic cpu get processorid ProcessorId BFEBFBFF000506E3 开源库: 查询CPU ...
- C++ 嵌入汇编 获取CPU信息
#include "windows.h" #include "iostream" #include "string" using names ...
- C#获取CPU等硬件ID(转载)
System.Management命名空间提供对大量管理信息和管理事件集合的访问,这些信息和事件是与根据 Windows 管理规范 (WMI) 结构对系统.设备和应用程序设置检测点有关的.应用程序和服 ...
- C#获取cpu序列号 硬盘ID 网卡硬地址以及操作注册表 .
转:http://blog.csdn.net/smartsmile2012/article/details/8682295 #region 获取cpu序列号 硬盘ID 网卡硬地址 /**/ /// & ...
- C#获取CPU占用率、内存占用、磁盘占用、进程信息
代码: using System; using System.Collections.Generic; using System.Diagnostics; using System.Threading ...
- C# 获取CPU序列号、网卡MAC地址、硬盘序列号封装类,用于软件绑定电脑
using System.Management; namespace GLaLa { /// <summary> /// hardware_mac 的摘要说明. /// </summ ...
- 获取CPU ID--查看CPU数量/核数
Ubuntu 获取CPU序列号或者主板序列号 CPU ID 代码: sudo dmidecode -t 4 | grep ID ID: 54 06 05 00 FF FB 8B 0F 主板序列号 代码 ...
- 获取CPU序列号、网卡MAC地址、硬盘序列号
<pre name="code" class="csharp"> using System; using System.Collections; u ...
随机推荐
- MyBatis 最常见错误,启动时控制台无限输出日志
你是否遇到过下面的情况,控制台无限的输出下面的日志: Logging initialized using ‘class org.apache.ibatis.logging.log4j.Log4jImp ...
- 转载文章:Windows Azure 七月份更新:SQL 数据库、流量管理器、自动伸缩、虚拟机
转载文章:Windows Azure 七月份更新:SQL 数据库.流量管理器.自动伸缩.虚拟机 今天上午,我们发布了一些重大的 Windows Azure 更新.这些新的增强功能包括: · SQL 数 ...
- keep健身计划
下一个月计划 1keep二周计划 2百度第一期学完 3百度前端技术学院提升
- hive集群安装配置
hive 是JAVA写的的一个数据仓库,依赖hadoop.没有安装hadoop的,请参考http://blog.csdn.net/lovemelovemycode/article/details/91 ...
- windows 7 memcached报failed to install service or service already installed的解决方案
今天心血来潮捣鼓一下memcache,由于系统是windows 7,我参考了 Windows下安装Memcache 使用memcached for Win32. 在运行memcached.exe -d ...
- 无废话ubuntu 13.4w文件共享配置
目标:实现windows和linux混合组成的操作 系统中可以共享文件,并可以通过机器名互相访问 安装文件共享服务 0.更改本机主机名,修改 /etc/hostname文件和/etc/hosts文件中 ...
- HTML系列(八):表格
一.基本表格: 表格标记<table>,行标记<tr>,单元格标记<td> 基本语法: <table> <tr> <td>单元格 ...
- 更改DataTable列名方法
1.通过DataAdapter将查询的结果填充到DataSet的表(DataTable)中: 如:dataAdapter.Fill(dataSet),这时dataSet的表名默认为Table 如果使用 ...
- 20141014C#面向对象抽象方法,抽象类,接口
里氏代换原则.可以用子类的对象替代父类的对象. 抽象依赖原则.依赖——形参,关联 一.抽象方法: 在一些父类中,某些行为不是非常明确,因此无法用代码来具体实现,但是类必须具备此方法,因此把这样的方法定 ...
- 浅谈Spring(一)
一.Spring引言 Spring是一款轻量级框架,代码入侵量很小,并且还是众多优秀的设计模式的组合(工厂.代理.模板.策略). 特点: 1.方便解耦,简化开发 通过Spring提供的IoC容器,我们 ...