CHP 4 Sample

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

Chapter 4: A Sample Assembly Language Program

The Parts Of A Program


Defining Sections
Defining The Starting Point
Creating A Simple Program
The CPUID Instruction
The Sample Program
Building The Executable
Running The Executable
Assembling Using A Compiler
Debugging The Program
Using gdb
Using C Library Functions In Assembly
Using printf
Linking With C Library Functions
Summary

Detailed Notes

The Parts Of A Program


Defining Sections
Defining The Starting Point
Creating A Simple Program

#cpuid.s Sample program to extract the processor Vendor ID


.section .data
output:
.ascii "The processor Vendor ID is 'xxxxxxxxxxxx'\n"
.section .text
.globl _start
_start:
movl $0, %eax
cpuid
movl $output, %edi
movl %ebx, 28(%edi)
movl %edx, 32(%edi)
movl %ecx, 36(%edi)
movl $4, %eax
movl $1, %ebx
movl $output, %ecx
movl $42, %edx
int $0x80
movl $1, %eax
movl $0, %ebx
int $0x80

Debugging The Program


Using gdb
Using C Library Functions In Assembly
Using printf
Linking With C Library Functions
Summary

You might also like