1 / 9

Assembly For X86

Assembly For X86. Chapter 5 Inline Assembly. C & Assembly. ניתן לשלב קוד C וקוד אסמבלי בתוכנית אחת באמצעות מספר קבצים (כל קובץ בשפה מסויימת) באמצעות הוראות למהדר: asm mov ax,bx asm{ mov ax,bx inc cx }. int add(int a,int b) { asm { mov ax,a add ax,b } }.

Télécharger la présentation

Assembly For X86

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Assembly For X86 Chapter 5 Inline Assembly

  2. C & Assembly • ניתן לשלב קוד C וקוד אסמבלי בתוכנית אחת • באמצעות מספר קבצים (כל קובץ בשפה מסויימת) • באמצעות הוראות למהדר: • asm mov ax,bx • asm{ mov ax,bx inc cx }

  3. int add(int a,int b) { asm { mov ax,a add ax,b } }

  4. int max(int a,int b) { asm{ mov ax,a cmp ax,b jg end mov ax,b } end: }

  5. int sum(int num[],int size) { asm { mov si,num mov cx,size mov ax,0 } cnt: asm { add ax,[si] add si,2 loop cnt } }

  6. void swap(int *x,int *y) { asm { mov si,x mov di,y mov al,[si] mov ah,[di] mov [si],ah mov [di],al } }

  7. void mem_set(char *str,char c,int size) { asm{ mov al,c mov bx,str mov cx,size } LP1: asm{ mov [bx],al inc bx dec cx jnz LP1 } }

  8. int count_char(char *str,char c,int size) { asm { mov al,0 mov bx,str mov cx,size } check: asm { mov ah,[bx] cmp ah,c jne cont inc al } cont: asm { inc bx loop check mov ah,0 } }

  9. int check_sort(int n[],int size) { asm { mov si,n mov cx,size dec cx } chk: asm { mov dx,[si] cmp dx,[si+2] jg bad add si,2 loop chk jmp good } bad: asm { mov ax,0 jmp end } good: asm mov ax,0ffh end: }

More Related