1 IKI10230 Pengantar Organisasi Komputer Kuliah no. 05.a: Data Transfer Instructions Sumber: 1. Paul Carter, PC Assembly Language 2. Hamacher. Computer.

Slides:



Advertisements
Similar presentations
Numbers Treasure Hunt Following each question, click on the answer. If correct, the next page will load with a graphic first – these can be used to check.
Advertisements

Scenario: EOT/EOT-R/COT Resident admitted March 10th Admitted for PT and OT following knee replacement for patient with CHF, COPD, shortness of breath.
Variations of the Turing Machine
Angstrom Care 培苗社 Quadratic Equation II
AP STUDY SESSION 2.
1
Copyright © 2003 Pearson Education, Inc. Slide 1 Computer Systems Organization & Architecture Chapters 8-12 John D. Carpinelli.
Copyright © 2011, Elsevier Inc. All rights reserved. Chapter 6 Author: Julia Richards and R. Scott Hawley.
Author: Julia Richards and R. Scott Hawley
Properties Use, share, or modify this drill on mathematic properties. There is too much material for a single class, so you’ll have to select for your.
David Burdett May 11, 2004 Package Binding for WS CDL.
1 RA I Sub-Regional Training Seminar on CLIMAT&CLIMAT TEMP Reporting Casablanca, Morocco, 20 – 22 December 2005 Status of observing programmes in RA I.
Properties of Real Numbers CommutativeAssociativeDistributive Identity + × Inverse + ×
Local Customization Chapter 2. Local Customization 2-2 Objectives Customization Considerations Types of Data Elements Location for Locally Defined Data.
Custom Statutory Programs Chapter 3. Customary Statutory Programs and Titles 3-2 Objectives Add Local Statutory Programs Create Customer Application For.
Custom Services and Training Provider Details Chapter 4.
CALENDAR.
1 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt BlendsDigraphsShort.
1 Click here to End Presentation Software: Installation and Updates Internet Download CD release NACIS Updates.
Break Time Remaining 10:00.
Turing Machines.
Table 12.1: Cash Flows to a Cash and Carry Trading Strategy.
PP Test Review Sections 6-1 to 6-6
1 The Blue Café by Chris Rea My world is miles of endless roads.
Bright Futures Guidelines Priorities and Screening Tables
EIS Bridge Tool and Staging Tables September 1, 2009 Instructor: Way Poteat Slide: 1.
Bellwork Do the following problem on a ½ sheet of paper and turn in.
CS 6143 COMPUTER ARCHITECTURE II SPRING 2014 ACM Principles and Practice of Parallel Programming, PPoPP, 2006 Panel Presentations Parallel Processing is.
Addressing Mode Wannachai Wannasawade Department of Computer Education
Exarte Bezoek aan de Mediacampus Bachelor in de grafische en digitale media April 2014.
Copyright © 2013, 2009, 2006 Pearson Education, Inc. 1 Section 5.5 Dividing Polynomials Copyright © 2013, 2009, 2006 Pearson Education, Inc. 1.
Copyright © 2012, Elsevier Inc. All rights Reserved. 1 Chapter 7 Modeling Structure with Blocks.
1 RA III - Regional Training Seminar on CLIMAT&CLIMAT TEMP Reporting Buenos Aires, Argentina, 25 – 27 October 2006 Status of observing programmes in RA.
Basel-ICU-Journal Challenge18/20/ Basel-ICU-Journal Challenge8/20/2014.
1..
CONTROL VISION Set-up. Step 1 Step 2 Step 3 Step 5 Step 4.
Adding Up In Chunks.
MaK_Full ahead loaded 1 Alarm Page Directory (F11)
Instruction Set of 8086 Engr. M.Zakir Shaikh
1 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt Synthetic.
Subtraction: Adding UP
: 3 00.
5 minutes.
1 hi at no doifpi me be go we of at be do go hi if me no of pi we Inorder Traversal Inorder traversal. n Visit the left subtree. n Visit the node. n Visit.
Analyzing Genes and Genomes
1 Let’s Recapitulate. 2 Regular Languages DFAs NFAs Regular Expressions Regular Grammars.
Types of selection structures
Essential Cell Biology
Converting a Fraction to %
Clock will move after 1 minute
PSSA Preparation.
Essential Cell Biology
Immunobiology: The Immune System in Health & Disease Sixth Edition
Physics for Scientists & Engineers, 3rd Edition
Energy Generation in Mitochondria and Chlorplasts
Select a time to count down from the clock above
Murach’s OS/390 and z/OS JCLChapter 16, Slide 1 © 2002, Mike Murach & Associates, Inc.
How to create Magic Squares
1 Decidability continued…. 2 Theorem: For a recursively enumerable language it is undecidable to determine whether is finite Proof: We will reduce the.
1 IKI10230 Pengantar Organisasi Komputer Kuliah no. 05.c: Logical Operations Sumber: 1. Paul Carter, PC Assembly Language 2. Hamacher. Computer Organization,
1 IKI10230 Pengantar Organisasi Komputer Kuliah no. 08: Multi-module Programs Sumber: 1. Paul Carter, PC Assembly Language 2. Hamacher. Computer Organization,
Department of Computer Science and Software Engineering
Computer Organization And Assembly Language
CEG 320/520: Computer Organization and Assembly Language ProgrammingIntel Assembly 1 Intel IA-32 vs Motorola
Computer Architecture and Operating Systems CS 3230 :Assembly Section Lecture 4 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
1 IKI10230 Pengantar Organisasi Komputer Kuliah no. 05.b: Arithmetic Operations Sumber: 1. Paul Carter, PC Assembly Language 2. Hamacher. Computer Organization,
Microprocessor & Assembly Language Arithmetic and logical Instructions.
Assembly Language Data Movement Instructions. MOV Instruction Move source operand to destination mov destination, source The source and destination are.
Chapter 4 Data Movement Instructions
Presentation transcript:

1 IKI10230 Pengantar Organisasi Komputer Kuliah no. 05.a: Data Transfer Instructions Sumber: 1. Paul Carter, PC Assembly Language 2. Hamacher. Computer Organization, ed-5 3. Materi kuliah CS61C/2000 & CS152/1997, UCB 4. Intel Architecture Software Developer’s Manual 17 Maret 2004 L. Yohanes Stefanus Bobby Nazief bahan kuliah:

2 KONVENSI

3 Set Instruksi Intel x86 °OP-CODEDEST,SRC; DEST  [SRC] OP [DEST] °Hanya salah satu dari SRC atau DEST dapat berupa memory-operand °ACC: representasi untuk AL/AX/EAX °Sebagian instruksi menyebabkan perubahan nilai FLAGS, khususnya instruksi-instruksi Aritmatika & Logika

4 DATA TRANSFER INSTRUCTIONS

5 Data Transfer Instructions °General-purpose data movement Move Conditional Move °Exchange °Stack manipulation °Type-conversion

6 Data Transfer Instructions: Summary (1/2) 1.MOV Move 2.CMOVE/CMOVZ Conditional move if equal/Conditional move if zero 3.CMOVNE/CMOVNZ Conditional move if not equal/Conditional move if not zero 4.CMOVA/CMOVNBE Conditional move if above/Conditional move if not below or equal 5.CMOVAE/CMOVNB Conditional move if above or equal/Conditional move if not below 6.CMOVB/CMOVNAE Conditional move if below/Conditional move if not above or equal 7.CMOVBE/CMOVNA Conditional move if below or equal/Conditional move if not above 8.CMOVG/CMOVNLE Conditional move if greater/Conditional move if not less or equal 9.CMOVGE/CMOVNL Conditional move if greater or equal/Conditional move if not less 10.CMOVL/CMOVNGE Conditional move if less/Conditional move if not greater or equal 11.CMOVLE/CMOVNG Conditional move if less or equal/Conditional move if not greater 12.CMOVC Conditional move if carry 13.CMOVNC Conditional move if not carry 14.CMOVO Conditional move if overflow 15.CMOVNO Conditional move if not overflow 16.CMOVS Conditional move if sign (negative) 17.CMOVNS Conditional move if not sign (non-negative) 18.CMOVP/CMOVPE Conditional move if parity/Conditional move if parity even 19.CMOVNP/CMOVPO Conditional move if not parity/Conditional move if parity odd

7 Data Transfer Instructions: Summary (2/2) 20.XCHG Exchange 21.BSWAP Byte swap 22.XADD Exchange and add 23.CMPXCHG Compare and exchange 24.CMPXCHG8B Compare and exchange 8 bytes 25.PUSH Push onto stack 26.POP Pop off of stack 27.PUSHA/PUSHAD Push general-purpose registers onto stack 28.POPA/POPAD Pop general-purpose registers from stack 29.CWD/CDQ Convert word to doubleword/Convert doubleword to quadword 30.CBW/CWDE Convert byte to word/Convert word to doubleword in EAX register 31.MOVSX Move and sign extend 32.MOVZX Move and zero extend

8 Data Transfer Instructions: Move °MOV DEST,SRC; DEST  [SRC] cannot be used to load the CS register cannot be used to do memory-to-memory transfer

9 Format Instruksi MOV (1/2) REG/MEM  [REG] MOV r/m8,r8 Move r8 to r/m8 MOV r/m16,r16 Move r16 to r/m16 MOV r/m32,r32 Move r32 to r/m32 REG  [REG/MEM] MOV r8,r/m8 Move r/m8 to r8 MOV r16,r/m16 Move r/m16 to r16 MOV r32,r/m32 Move r/m32 to r32 REG/MEM  [SEG-REG] MOV r/m16,Sreg Move segment register to r/m16 SEG-REG  [REG/MEM] MOV Sreg,r/m16 Move r/m16 to segment register

10 Format Instruksi MOV (2/2) AL/AX/EAX  [MEM] MOV AL,moffs8Move byte at (seg:offset) to AL MOV AX,moffs16 Move word at (seg:offset) to AX MOV EAX,moffs32 Move doubleword at (seg:offset) to EAX MEM  [AL/AX/EAX] MOV moffs8,AL Move AL to (seg:offset) MOV moffs16,AX Move AX to (seg:offset) MOV moffs32,EAX Move EAX to (seg:offset) REG  IMM MOV r8,imm8 Move imm8 to r8 MOV r16,imm16 Move imm16 to r16 MOV r32,imm32 Move imm32 to r32 [REG/MEM]  IMM MOV r/m8,imm8 Move imm8 to r/m8 MOV r/m16,imm16 Move imm16 to r/m16 MOV r/m32,imm32 Move imm32 to r/m32

11 Data Transfer Instructions: Conditional Move

12 Format Instruksi CMOVcc °CMOVA r16, r/m16 Move if above (CF=0 and ZF=0) °CMOVA r32, r/m32 Move if above (CF=0 and ZF=0) °CMOVAE r16, r/m16 Move if above or equal (CF=0) °CMOVAE r32, r/m32 Move if above or equal (CF=0) °CMOVB r16, r/m16 Move if below (CF=1) °CMOVB r32, r/m32 Move if below (CF=1) °CMOVBE r16, r/m16 Move if below or equal (CF=1 or ZF=1) °CMOVBE r32, r/m32 Move if below or equal (CF=1 or ZF=1) °CMOVC r16, r/m16 Move if carry (CF=1) °CMOVC r32, r/m32 Move if carry (CF=1) °CMOVE r16, r/m16 Move if equal (ZF=1) °CMOVE r32, r/m32 Move if equal (ZF=1)

13 Data Transfer Instructions: Exchange °XCHG DEST,SRC;Exchange [DEST] ↔ [SRC] °BSWAP R32;Byte swap R32[7..0] ↔ R32[31..24] R32[15..8] ↔ R32[23..16] °XADD DEST,SRC;Exchange and add TEMP ← [SRC] + [DEST] SRC ← [DEST] DEST ← [TEMP] °CMPXCHG DEST,SRC;Compare and exchange /* accumulator = AL, AX, or EAX, depending on whether */ IF ([accumulator] == [DEST]) { ZF ← 1; DEST ← [SRC] } ELSE { ZF ← 0; accumulator ← [DEST] } °CMPXCHG8B [DATA];Compare & exchange 8 bytes IF ([EDX:EAX] == [DEST]) { ZF ← 1; DEST ← [ECX:EBX] } ELSE { ZF ← 0; EDX:EAX ← [DEST] }

14 Format Instruksi XCHG °XCHG AX,r16 Exchange r16 with AX °XCHG r16,AX Exchange AX with r16 °XCHG EAX, r32 Exchange r32 with EAX °XCHG r32, EAX Exchange EAX with r32 °XCHG r/m8, r8 Exchange r8 with byte from r/m8 °XCHG r8, r/m8 Exchange byte from r/m8 with r8 °XCHG r/m16, r16 Exchange r16 with word from r/m16 °XCHG r16, r/m16 Exchange word from r/m16 with r16 °XCHG r/m32, r32 Exchange r32 with doubleword from r/m32 °XCHG r32, r/m32 Exchange doubleword from r/m32 with r32

15 Format Instruksi BSWAP & XADD °BSWAP r32 Reverses the byte order of a 32-bit register. °XADD r/m8, r8 Exchange r8 and r/m8; load sum into r/m8. °XADD r/m16, r16 Exchange r16 and r/m16; load sum into r/m16. °XADD r/m32, r32 Exchange r32 and r/m32; load sum into r/m32.

16 Format Instruksi CMPXCHG & CMPXCHG8B °CMPXCHG r/m8,r8 Compare AL with r/m8. If equal, ZF is set and r8 is loaded into r/m8. Else, clear ZF and load r/m8 into AL. °CMPXCHG r/m16,r16 Compare AX with r/m16. If equal, ZF is set and r16 is loaded into r/m16. Else, clear ZF and load r/m16 into AX °CMPXCHG r/m32,r32 Compare EAX with r/m32. If equal, ZF is set and r32 is loaded into r/m32. Else, clear ZF and load r/m32 into EAX °CMPXCHG8B m64 Compare EDX:EAX with m64. If equal, set ZF and load ECX:EBX into m64. Else, clear ZF and load m64 into EDX:EAX.

17 Data Transfer Instructions: Stack Manipulation °PUSH SRC; Push onto stack ; GP-regs, SEG-regs, MEM, Immd. ESP  [ESP] – 4/2 [ESP]  [SRC]

18 Format Instruksi PUSH °PUSH r/m16 Push r/m16 PUSH WORD [DATA] °PUSH r/m32 Push r/m32 PUSH DWORD [DATA] °PUSH r16 Push r16 °PUSH r32 Push r32 °PUSH imm8 Push imm8 °PUSH imm16 Push imm16 °PUSH imm32 Push imm32 °PUSH CS Push CS °PUSH SS Push SS °PUSH DS Push DS °PUSH ES Push ES °PUSH FS Push FS °PUSH GS Push GS

19 Data Transfer Instructions: Stack Manipulation °POP DEST; Pop off of stack ; GP-regs, SEG-regs (-CS), MEM DEST  [[ESP]] ESP  [ESP] + 4/2

20 Format Instruksi POP °POP r/m16 Pop top of stack into m16; increment stack pointer POP WORD [DATA] °POP r/m32 Pop top of stack into m32; increment stack pointer POP DWORD [DATA] °POP r16 Pop top of stack into r16; increment stack pointer °POP r32 Pop top of stack into r32; increment stack pointer °POP DS Pop top of stack into DS; increment stack pointer °POP ES Pop top of stack into ES; increment stack pointer °POP SS Pop top of stack into SS; increment stack pointer °POP FS Pop top of stack into FS; increment stack pointer °POP GS Pop top of stack into GS; increment stack pointer

21 Data Transfer Instructions: Stack Manipulation °PUSHA/PUSHAD; Push (16-/32-bit) GP-regs onto stack °POPA/POPAD; Pop (16-/32-bit) GP-regs from stack

22 Data Transfer Instructions: Type Conversion °CBW; Convert byte to word AX ← SignExtend[AL] °CWD; Convert word to doubleword DX:AX ← SignExtend[AX] °CWDE; Convert word to doubleword EAX ← SignExtend[AX] °CDQ; Convert doubleword to quadword EDX:EAX ← SignExtend[EAX] °MOVSX DEST,SRC; Move and sign extend DEST ← SignExtend[SRC] °MOVZX DEST,SRC ; Move and zero extend DEST ← ZeroExtend[SRC]

23 Format Instruksi MOVSX & MOVZX °MOVSX r16,r/m8 Move byte to word with sign-extension °MOVSX r32,r/m8 Move byte to doubleword, sign-extension °MOVSX r32,r/m16 Move word to doubleword, sign-extension °MOVZX r16,r/m8 Move byte to word with zero-extension °MOVZX r32,r/m8 Move byte to doubleword, zero-extension °MOVZX r32,r/m16 Move word to doubleword, zero-extension

24 first.asm (1/3) 1.%include "asm_io.inc" 2.segment.data 3.; 4.; These labels refer to strings used for output 5.; 6.prompt1 db "Enter a number: ", 0 ; don't forget nul terminator 7.prompt2 db "Enter another number: ", 0 8.outmsg1 db "You entered ", 0 9.outmsg2 db " and ", 0 10.outmsg3 db ", the sum of these is ", 0 11.segment.bss 12.; 13.; These labels refer to double words used to store the inputs 14.; 15.input1 resd input2 resd 1

25 first.asm (2/3) 17.segment.text 18. global _asm_main 19._asm_main: 20. enter 0,0 ; setup routine 21. pusha 22. mov eax, prompt1 ; print out prompt 23. call print_string 24. call read_int ; read integer 25. mov [input1], eax ; store into input1 26. mov eax, prompt2 ; print out prompt 27. call print_string 28. call read_int ; read integer 29. mov [input2], eax ; store into input

26 first.asm (3/3) 31. moveax, [input1] ; eax = dword at input1 32. addeax, [input2] ; eax += dword at input2 33. movebx, eax ; ebx = eax 34. mov eax, outmsg1 35. call print_string ; print out first message 36. mov eax, [input1] 37. call print_int ; print out input1 38. mov eax, outmsg2 39. call print_string ; print out second message 40. mov eax, [input2] 41. call print_int ; print out input2 42. mov eax, outmsg3 43. call print_string ; print out third message 44. mov eax, ebx 45. call print_int ; print out sum (ebx) 46. call print_nl ; print new-line 47. popa 48. moveax, 0 ; return back to C 49. leave 50. ret

27 first.exe