umbc
play

UMBC L A N R Y D A B M A L F T U M B C I O M 1 - PowerPoint PPT Presentation

Systems Design & Programming 80x86 Assembly IV CMPE 310 Intel Assembly UMBC L A N R Y D A B M A L F T U M B C I O M 1 (Mar. 1, 2002) Y O T R I E S R C E O V U I N N U T Y 1 6 9 6 Systems Design


  1. Systems Design & Programming 80x86 Assembly IV CMPE 310 Intel Assembly UMBC L A N R Y D A B M A L F T U M B C I O M 1 (Mar. 1, 2002) Y O T R I E S R C E O V U I N N U T Y 1 6 9 6

  2. Systems Design & Programming 80x86 Assembly IV CMPE 310 Arithmetic Operations add al , [ARRAY + esi] inc byte [ edi ] ;Adds 1 to any reg/mem except seg adc ecx , ebx ;Adds registers + Carry flag. ;Used for adding 64 bit nums. xadd ecx , ebx ;ecx=ecx+ebx, ebx=original ecx. UMBC L A N R Y D A B M A L F T U M B C I O M 2 (Mar. 1, 2002) Y O T R I E S R C E O V U I N N U T Y 1 6 9 6

  3. Systems Design & Programming 80x86 Assembly IV CMPE 310 Arithmetic Operations sub eax , ebx ;eax=eax-ebx dec edi sbb ecx , ebx ;Subs registers - Carry flag. cmp al , 10H ;Jump if equal or above. jae LABEL1 jbe LABEL2 ;Jump if equal or below. cmpxchg ecx , e dx ;if ecx==eax, eax=edx else eax=ecx UMBC L A N R Y D A B M A L F T U M B C I O M 3 (Mar. 1, 2002) Y O T R I E S R C E O V U I N N U T Y 1 6 9 6

  4. Systems Design & Programming 80x86 Assembly IV CMPE 310 Arithmetic Operations mul bl ;ax=al*bl (unsigned) imul bx ;dx|ax=ax*bx (signed) imul cx , dx, 12H ;Special, cx=dx*12H (signed only) mul ecx ;edx|eax=eax*ecx div cl ;ah|al=ax/cl, unsigned quotient ; in al, remainder in ah idiv cx ;dx|ax=(dx|ax)/cx UMBC L A N R Y D A B M A L F T U M B C I O M 4 (Mar. 1, 2002) Y O T R I E S R C E O V U I N N U T Y 1 6 9 6

  5. Systems Design & Programming 80x86 Assembly IV CMPE 310 Logic Operations XXXX XXXX Operand 0000 1111 Mask and al , bl ;al=al AND bl 0000 XXXX Result XXXX XXXX Operand 0000 1111 Mask or eax , 10 ;eax=eax OR 0000000AH XXXX 1111 Result UMBC L A N R Y D A B M A L F T U M B C I O M 5 (Mar. 1, 2002) Y O T R I E S R C E O V U I N N U T Y 1 6 9 6

  6. Systems Design & Programming 80x86 Assembly IV CMPE 310 Logic Operations XXXX XXXX Operand 0000 1111 Mask xor ah , ch ;ah=ah XOR ch XXXX XXXX Result test al , 4 ;Tests bit 2 in al -- 00000100 jz LABEL ;Jump to LABEL if bit 2 is zero. not ebx neg TEMP UMBC L A N R Y D A B M A L F T U M B C I O M 6 (Mar. 1, 2002) Y O T R I E S R C E O V U I N N U T Y 1 6 9 6

  7. Systems Design & Programming 80x86 Assembly IV CMPE 310 Logic Operations shl eax , 1 ;eax is logically shifted left 1 bit pos. sar esi, cl ;esi is arithmetically shifted right shdr e ax , e bx , 12 ;eax shifted right by 12 and filled ;from the left with the right ;12 bits of ebx. shdl ax , bx , 14 rol si , 14 ;si rotated left by 14 places. rcr bl , cl ;bl rotated right cl places through carry. shl ax , 1 ;Original 48-bit number in dx, bx and ax. ;Shift ax left 1 binary place. rcl bx , 1 ;Rotate carry bit from previous shl into ;low order bit of bx. rcl dx , 1 ;Rotate carry bit from previous rcl in dx. UMBC L A N R Y D A B M A L F T U M B C I O M 7 (Mar. 1, 2002) Y O T R I E S R C E O V U I N N U T Y 1 6 9 6

  8. Systems Design & Programming 80x86 Assembly IV CMPE 310 Bit/String Scan bsl ebx , eax ;eax scanned from the left. bsr bl , cl ;cl scanned from the right. UMBC L A N R Y D A B M A L F T U M B C I O M 8 (Mar. 1, 2002) Y O T R I E S R C E O V U I N N U T Y 1 6 9 6

  9. Systems Design & Programming 80x86 Assembly IV CMPE 310 add ax, bx NEXT: jmp short NEXT ;short keyword is optional. jmp near eax ;Jump to address given by eax. jmp [eax] ;Jump to address given by [ax]. jmp far LABEL ;Jump to address given by LABEL. UMBC L A N R Y D A B M A L F T U M B C I O M 9 (Mar. 1, 2002) Y O T R I E S R C E O V U I N N U T Y 1 6 9 6

  10. Systems Design & Programming 80x86 Assembly IV CMPE 310 Flow-of-Control Instructions ja ;Jump if above (Z=0 and C=0) jbe ;Jump if below or equal (Z=1 or C=1) jl ;Jump if < (S<>O) jge ;Jump if >= (S=O) jne ;Jump if != (Z=0) je or jz ;Jump if ==; or jump if zero (Z=1) jc ;Jump if carry set (C=1) jcxz ;Jump if cx==0 jecxz ;Jump if ecx==0 UMBC L A N R Y D A B M A L F T U M B C I O M 10 (Mar. 1, 2002) Y O T R I E S R C E O V U I N N U T Y 1 6 9 6

  11. Systems Design & Programming 80x86 Assembly IV CMPE 310 Flow-of-Control Instructions setg al ;Set al=1 if >than (test Z==0 AND S==0) ;else set al to 0 loop LABEL ;Jump if ecx != 0 loope ;Jump if (Z = 1 AND ecx != 0) loopne ;Jump if (Z = 0 AND ecx != 0) UMBC L A N R Y D A B M A L F T U M B C I O M 11 (Mar. 1, 2002) Y O T R I E S R C E O V U I N N U T Y 1 6 9 6

Recommend


More recommend