[kml_flashembed movie="http://www.youtube.com/v/OKQEpzJTUio" width="425" height="344" allowfullscreen="true" fvars="fs=1" /]
Author: margusja
Lugu mis külmavärinad tekitab
Tervitus naisperele 🙂
[kml_flashembed movie="http://www.youtube.com/v/b2Lx5GJgMFg" width="425" height="344" allowfullscreen="true" fvars="fs=1" /]
Nüüd on lennukitööstuse ime ka tavainimesele kättesaadav
Pure assembler machine code versus using libc
Võtame ühe lihtsa programmijupi mis kuvab teie protsessori nimi.
[margusja@hacking asm]$ ./cpuid2
The processor Vendor ID is 'GenuineIntel'
Lähtekood juhul kui kasutame ainult “system call” meetodeid
#cpuid.s Sample program to extract the processor Vendor ID.section .dataoutput:
.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)
# Display
movl $4, %eax # sys_write
movl $1, %ebx # file descriptor to write. 1 is stdout
movl $output, %ecx # start of the display string
movl $42, %edx # lenght of the display string
int $0x80
# Exit
movl $1, %eax # sys_exit
movl $0, %ebx # exit status
Lähtekood libc kasutamisest
#cpuid2.s View the CPUID Vendor ID string using C library calls.section .dataoutput:
.asciz "The processor Vendor ID is '%s'\n"
.section .bss
.lcomm buffer, 12
.section .text
.globl _start
_start:
movl $0, %eax
cpuid
movl $buffer, %edi
movl %ebx, (%edi)
movl %edx, 4(%edi)
movl %ecx, 8(%edi)
# Prepare printf
pushl $buffer
pushl $output
call printf # print $output using libc printf
addl $8, %esp # Move stack pointer pack
pushl $0 # Exit status
call exit # Exite the program using libc exit
Palju lihtsam. Paadunud assembleri mehed võivad küll nina kirtsutada kuid minu arust annab selline miksimine hea praktika ka C ja C++ osas ning tekitab huvi ka nende keelte vastu.
Talv maal
Vaatan hommiku, et kass piilub midagi aknast, endal saba käib nagu ei oleks millegiga rahul.
CPUID
Lihtne assembleris kirjutatud programm mis kuvab masina CPU tootja.
Programm on kompileeritud hetkel 2.6.27.5-117.fc10.i686 jaoks.
cpuid
Source
#cpuid.s Sample program to extract the processor Vendor ID.section .dataoutput:
.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)
# Display
movl $4, %eax # sys_write
movl $1, %ebx # file descriptor to write. 1 is stdout
movl $output, %ecx # start of the display string
movl $42, %edx # lenght of the display string
int $0x80
# Exit
movl $1, %eax # sys_exit
movl $0, %ebx # exit status
int $0x80