Examples of assembly language programs

Source: Internet
Author: User

The main function of this program is to display the CPU vendor's vendor ID

The source code is as follows:
. Section. Data#x是占位符Output:. ASCII"The processor Vendor ID is: ' xxxxxxxxxx ' \ n"#_start和output都是标签. section. Text#如果用gcc编译的话, _start will change to main. Global _START_START:MOVL $,%eaxCpuid#相当于把字符串output的地址传入到寄存器edi中.Movl$output,%edi#将调用cpuid命令的内容放入指定的内存Movl%EBX, -(%edi) MOVL%edx, +(%edi) MOVL%ecx, $(%edi)#4表示系统调用的值, 1 represents the file descriptor, and output is the input characterMovl$4,%eaxMovl $,%EBXMovl$output,%ecxMovl$42,%edx# "int $0x80" is a system call interruptint  $x80Movl $,%eaxMovl $,%EBXint  $x80
Compile

As-o CPUID.O ASSEMBLY_TEMPLATE.S
Ld-o CPUID CPUID.O

Perform

./cpuid

Output

The processor Vendor ID Is:genuineintel

Examples of assembly language programs

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.