1 / 25

컴퓨터의 개념과 실습

컴퓨터의 개념과 실습. Assembly Example. Python vs. Assembly. Python. Assembly. f = (g + h) – ( i + j ). ADD R5, R1, R2 ADD R6, R3, R4 SUB R0, R5, R6. f is mapped to R0 g is mapped to R1 h is mapped to R2 i is mapped to R3 j is mapped to R4. Python vs. Assembly. Python.

tanith
Download Presentation

컴퓨터의 개념과 실습

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 Example

  2. Python vs. Assembly Python Assembly f = (g + h) – (i + j) ADD R5, R1, R2 ADD R6, R3, R4 SUB R0, R5, R6 f is mapped to R0 g is mapped to R1 h is mapped to R2 iis mapped to R3 j is mapped to R4

  3. Python vs. Assembly Python Assembly g = h + A[i] ADD R4, R2, R3 LDR R5, [R4] ADD R0, R1, R5 g is mapped to R0 h is mapped to R1 R2 contains the base address of array A[]. iis mapped to R3.

  4. Python vs. Assembly Python Assembly if (i == j): f = g + h else: f = g – h CMP R3, R4 BNE ELSE ADD R0, R1, R2 B EXIT ELSE: SUB R0, R1, R2 EXIT: f is mapped to R0 g is mapped to R1 h is mapped to R2 iis mapped to R3 j is mapped to R4

  5. Python vs. Assembly Python Assembly while (save[i] == k): i = i + j LOOP: ADD R4, R0, R3 LDR R5, [R4] CMP R2, R5 BNE EXIT ADD R0, R0, R1 B LOOP EXIT: iis mapped to R0 j is mapped to R1 k is mapped to R2 R3 contains the base address of array save[].

  6. Example Assembly Code & ISA Register Memory <Python> sum = 0 list = [11, 13, 16] for i in range(0,3): sum = sum + list[i] <Assembly> MOV R0, #0 MOV R2, #6 L: ADD R2, R2, #1 LDR R1, [R2] ADD R0, R0, R1 CMP R2, #9 BNE L MOV R2, #10 STR R0, [R2] <R egister & Memory>

  7. Instruction Set Architecture Register Memory Register Memory MOV R0, #0 • Assumptions • 32bit ISA • # of registers = 8 + PC (Program Counter) + PSR (Program Status Register) • Memory size = 176KB Before Register and Memory After Register and Memory

  8. Instruction Set Architecture Register Memory Register Memory MOV R2, #6 • Assumptions • 32bit ISA • # of registers = 8 + PC (Program Counter) + PSR (Program Status Register) • Memory size = 176KB Before Register and Memory After Register and Memory

  9. Instruction Set Architecture Register Memory Register Memory ADD R2, R2, #1 • Assumptions • 32bit ISA • # of registers = 8 + PC (Program Counter) + PSR (Program Status Register) • Memory size = 176KB Before Register and Memory After Register and Memory

  10. Instruction Set Architecture Register Memory Register Memory LDR R1, [R2] • Assumptions • 32bit ISA • # of registers = 8 + PC (Program Counter) + PSR (Program Status Register) • Memory size = 176KB Before Register and Memory After Register and Memory

  11. Instruction Set Architecture Register Memory Register Memory ADD R0, R0, R1 • Assumptions • 32bit ISA • # of registers = 8 + PC (Program Counter) + PSR (Program Status Register) • Memory size = 176KB Before Register and Memory After Register and Memory

  12. Instruction Set Architecture Register Memory Register Memory CMP R2, #9 • Assumptions • 32bit ISA • # of registers = 8 + PC (Program Counter) + PSR (Program Status Register) • Memory size = 176KB Before Register and Memory After Register and Memory

  13. Instruction Set Architecture Register Memory Register Memory BNE L • Assumptions • 32bit ISA • # of registers = 8 + PC (Program Counter) + PSR (Program Status Register) • Memory size = 176KB Before Register and Memory After Register and Memory

  14. Instruction Set Architecture Register Memory Register Memory ADD R2, R2, #1 • Assumptions • 32bit ISA • # of registers = 8 + PC (Program Counter) + PSR (Program Status Register) • Memory size = 176KB Before Register and Memory After Register and Memory

  15. Instruction Set Architecture Register Memory Register Memory LDR R1, [R2] • Assumptions • 32bit ISA • # of registers = 8 + PC (Program Counter) + PSR (Program Status Register) • Memory size = 176KB Before Register and Memory After Register and Memory

  16. Instruction Set Architecture Register Memory Register Memory ADD R0, R0, R1 • Assumptions • 32bit ISA • # of registers = 8 + PC (Program Counter) + PSR (Program Status Register) • Memory size = 176KB Before Register and Memory After Register and Memory

  17. Instruction Set Architecture Register Memory Register Memory CMP R2, #9 • Assumptions • 32bit ISA • # of registers = 8 + PC (Program Counter) + PSR (Program Status Register) • Memory size = 176KB Before Register and Memory After Register and Memory

  18. Instruction Set Architecture Register Memory Register Memory BNE L • Assumptions • 32bit ISA • # of registers = 8 + PC (Program Counter) + PSR (Program Status Register) • Memory size = 176KB Before Register and Memory After Register and Memory

  19. Instruction Set Architecture Register Memory Register Memory ADD R2, R2, #1 • Assumptions • 32bit ISA • # of registers = 8 + PC (Program Counter) + PSR (Program Status Register) • Memory size = 176KB Before Register and Memory After Register and Memory

  20. Instruction Set Architecture Register Memory Register Memory LDR R1, [R2] • Assumptions • 32bit ISA • # of registers = 8 + PC (Program Counter) + PSR (Program Status Register) • Memory size = 176KB Before Register and Memory After Register and Memory

  21. Instruction Set Architecture Register Memory Register Memory ADD R0, R0, R1 • Assumptions • 32bit ISA • # of registers = 8 + PC (Program Counter) + PSR (Program Status Register) • Memory size = 176KB Before Register and Memory After Register and Memory

  22. Instruction Set Architecture Register Memory Register Memory CMP R2, #9 • Assumptions • 32bit ISA • # of registers = 8 + PC (Program Counter) + PSR (Program Status Register) • Memory size = 176KB Before Register and Memory After Register and Memory

  23. Instruction Set Architecture Register Memory Register Memory BNE L • Assumptions • 32bit ISA • # of registers = 8 + PC (Program Counter) + PSR (Program Status Register) • Memory size = 176KB Before Register and Memory After Register and Memory

  24. Instruction Set Architecture Register Memory Register Memory MOV R2, #10 • Assumptions • 32bit ISA • # of registers = 8 + PC (Program Counter) + PSR (Program Status Register) • Memory size = 176KB Before Register and Memory After Register and Memory

  25. Instruction Set Architecture Register Memory Register Memory STR R0, [R2] • Assumptions • 32bit ISA • # of registers = 8 + PC (Program Counter) + PSR (Program Status Register) • Memory size = 176KB Before Register and Memory After Register and Memory

More Related