ASSEMBLY 1 - PowerPoint PPT Presentation

1 / 4
About This Presentation
Title:

ASSEMBLY 1

Description:

ASSEMBLY 1 EXAMPLE 1 C ASSEMBLY ( c_source.c ) #include #include int main(int ... – PowerPoint PPT presentation

Number of Views:31
Avg rating:3.0/5.0
Slides: 5
Provided by: Adel132
Category:
Tags: assembly

less

Transcript and Presenter's Notes

Title: ASSEMBLY 1


1
??? ????? ??
  • ASSEMBLY 1

2
EXAMPLE 1
  • C ??? ASSEMBLY ??? ?? ??

( c_source.c ) include ltstdio.hgt include
ltstdlib.hgt int main(int argc, char
argv) int num, exp, res num
atoi(argv1) exp atoi(argv2) num
myfunc(num, exp) printf(d exp d d\n,
num, exp, res) return 0 int print(int num,
int exp, int res) printf(d exp d d\n,
num, exp, res) return 0
3
EXAMPLE 1
( asm_source.s ) .globl myfunc myfunc movl 4(e
sp), eax movl 8(esp), ebx movl 1, ecx movl
1, edx L1 cmpl edx, ebx je L2 imull eax,
ecx pushl ecx pushl edx pushl eax call pri
nt popl eax popl edx popl ecx incl edx jm
p L1 L2 imull eax, ecx movl ecx, eax ret
??? ?? gcc o ex1 c_sources.c asm_source.s
4
EXAMPLE 2
  • INLINE ASSEMBLY

( c_source.c ) int iasm_test_func(int arg) void
print(char str, int num) printf(STRING s
NUMBER d\n, str, num) static void
__iasm_func_dummy(void) __asm__
__volatile__( .globl iasm_test_func \n\t i
asm_test_func \n\t pushl 4(esp) \n\t
pushl 0 \n\t call print \n\t addl 8,
esp \n\t movl 4(esp), eax \n\t ret
I (hello world..) )
int main() int ret ret iasm_test_func(10)
printf(RETURN d\n, ret) return 0
Write a Comment
User Comments (0)
About PowerShow.com