1 / 68

languages and tools

languages and tools. SA. BY. machine code. assembly.

jola
Download Presentation

languages and tools

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. languages and tools

  2. SA BY

  3. machine code

  4. assembly

  5. section .textglobal mainmain: mov eax, 4;system call number (sys_write) mov ebx, 1;first argument: file handle (stdout) mov ecx, msg ;second argument: pointer to message to write mov edx, len ;third argument: message length int 0x80;call kernel mov eax, 1;system call number (sys_exit) mov ebx, 0;first syscall argument: exit code int 0x80;call kernelsection .data msg db"Hello, world!", 0xa len equ $ - msg

  6. NASM(Netwide Assembler) GAS(Gnu Assembler) MASM(Microsoft Macro Assembler)

  7. assembler linker hello (executable) hello.asm (source) hello.o (object file)

  8. assembler linker foo.asm foo.o assembler baz bar.o bar.asm

  9. dynamic linking (linking at runtime) .so (Linux) .dll (Windows)

  10. high-level • expressiveness • portability low-level • precise control • efficiency

  11. compiler

  12. compiler linker foo.c foo.o compiler baz bar.c bar.o

  13. assembler linker foo.asm foo.o compiler baz bar.o bar.c

  14. interpreter

  15. interpreter hello (source)

  16. interpreter foo bar

  17. 88 + 5 2 – 9 8 * (-3 + 5)

  18. 93 88 + 5 2 – 9 8 * (-3 + 5)

  19. -7 88 + 5 2 – 9 8 * (-3 + 5)

  20. 16 88 + 5 2 – 9 8 * (-3 + 5)

  21. 4 • as foo 1 + 2 1 + foo

  22. compiler virtual machine hello.java (source) hello.class (bytecode)

  23. VM with JIT (Just-in-time) compiler hello.java (source) hello.class (bytecode) (machine code)

  24. garbage collection

  25. function factorial n • as val1 • while (gtn1) # error when n is not a number • as val(mulnval) • as n(subn1) • return val • (factorial true) # improper type Type error:

  26. function num:factorial num:n • as num:val1 • while (gtn1) • as val(mulnval) • as n(subn1) • return val • (factorial true) # improper type Static typing:

  27. function num:factorial num:n • as num:val1 • while (gtn1) • as val(mulnval) • as n(subn1) • return val • (factorial (foo)) Static typing:

  28. as list:foo(list“hello” 14 8) • as num:bar (getfoo 1) # unknown type

  29. as numList:foo(numList5 14 8) • as num:bar (getNumfoo 1)

  30. (accepts varied number and/or types of inputs) polymorphism • (print“hello”) • (print100) • (printfalse)

  31. function foo a b • if (isNuma) • … • else • … • (foo 3 true) • (foo “hello” true)

  32. function foo a b • if (isNullb) • … • else • … • (foo 3 true) • (foo “hello”null)

  33. function foo a b • if (isNullb) • … • else • … • (foo 3 true) • (foo “hello”)

  34. function num:foo num:a bool:b • … • function bool:foo str:a bool:b • … • function str:foo str:a • …

  35. function num:foo num:a bool:b • … • function bool:foo str:a bool:b • … • function str:foo str:a # illegal • … • function num:foo str:a # illegal • …

  36. function num:foo num:a bool:b • … • function bool:foo str:a bool:b • … • function str:foo str:a • … • (foo “hello”) • (foo 3 true) • (foo “hello” false)

  37. function num:foo num:a bool:b • … • function bool:foo str:a bool:b • … • function str:foo str:a • … • asstr:x (foo “hello”)

  38. function foo a • if (isNuma) • … • else • … • asbar4 • ifx • asbarfalse • (foo bar)

  39. function num:foo bool:a • … • function num:foo num:a • … • asnum:bar4 • ifx • asbarfalse # illegal • (foo bar)

  40. function num:foo bool:a • … • function num:foo num:a • … • (foo (ack))

  41. Weak typing: Strong typing: • Possible to modify any bytes of data in any way. Operations only treat a piece of data appropriately to its type.

  42. paradigms imperative (domodify state) functional (don’tmodify state) procedural (action-centered design) object-oriented (data-centered design)

  43. syntax semantics libraries idioms tools

  44. compiler linker interpreter text editor debugger profiler version control IDE (Integrated Developer Environment)

More Related