Fireship · @fireship

Assembly Language in 100 Seconds

Uploaded April 14, 2022 · Length 2:44

Assembly Language in 100 Seconds

Summary

assembly language basics, its history, and usage in programming, including low-level performance and web assembly.

  • assembly language
  • low-level programming
  • web assembly
  • cpu architecture
  • programming basics

Transcript preview

The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.

  1. 0:00

    assembly a low-level programming

  2. 0:02

    language designed to simplify the

  3. 0:03

    instructions fed into a computer CPU in

  4. 0:06

    other words it's a human readable

  5. 0:08

    abstraction on top of machine code so

  6. 0:10

    programmers don't have to manually count

  7. 0:11

    ones and zeros the First Assembly

  8. 0:13

    Language was created by Kathleen booth

  9. 0:15

    in 1947 for the allpurpose electronic

  10. 0:18

    computer over the next decade it evolved

  11. 0:20

    into many different formats to power the

  12. 0:22

    supercomputers of the day like the IBM

  13. 0:24

    790 which had a $20 million price tag in

  14. 0:27

    today's dollars writing code in assembly

  15. 0:29

    was standard until the emergence of

  16. 0:31

    highlevel languages like Fortran a few

  17. 0:33

    years later however assembly is still

  18. 0:35

    used today for direct access to the bare

  19. 0:37

    metal hardware and to address low-level

  20. 0:39

    performance issues often on device

  21. 0:41

    drivers and embedded systems and it's

  22. 0:43

    also used to run native software in a

  23. 0:44

    web browser via web assembly what's

  24. 0:46

    tricky is that each Assembly Language

  25. 0:48

    only works on a specific CPU

  26. 0:50

    architecture like arm for Apple silicon

  27. 0:52

    and Raspberry Pi or x86 for Intel chips

  28. 0:55

    to get started you'll first need an

  29. 0:56

    assembler like the netwide assembler for

  30. 0:58

    x86 chips in assembly program is divided

  31. 1:01

    into three sections the text section

  32. 1:03

    contains the actual Logic for the

  33. 1:04

    program by convention it contains an

  34. 1:06

    entry point called start which is where

  35. 1:08

    the code will start executing next we

  36. 1:10

    have the block starting symbol section

  37. 1:11

    which contains variables that might

  38. 1:13

    change throughout the life cycle of the

  39. 1:14

    app and finally the data section is

  40. 1:16

    where we can initialize constants or

  41. 1:18

    data that does not change to declare a

  42. 1:20

    constant like a string we start with a

  43. 1:21

    label then use DB for defined bite to

  44. 1:24

    place the hello world string into memory

  45. 1:26

    by itself it doesn't do anything and to

  46. 1:28

    print it to the standard output we will

  47. 1:29

    will also need its length we can use

  48. 1:31

    equate to convert a symbol into a

  49. 1:33

    constant the dollar sign will subtract

  50. 1:35

    the current position from the hello

  51. 1:36

    label providing the length of the string

  52. 1:38

    and now these constants can be

  53. 1:39

    referenced from the start label in the

  54. 1:40

    main program each line of code contains

  55. 1:42

    an instruction along with one or more

  56. 1:44

    operands and there are hundreds of

  57. 1:45

    instructions built into the language now

  58. 1:47

    to perform operations quickly the CPU

  59. 1:50

    has a limited number of registers which

  60. 1:51

    are like 64-bit chunks of memory built

  61. 1:54

    directly into the CPU instead of the ram

  62. 1:56

    we can insert data into a register with

  63. 1:58

    the move instruction by providing

  64. 1:59

    operands for the register name and the