Two Pass Assemblers Tutorial

Поділитися
Вставка
  • Опубліковано 1 лис 2024

КОМЕНТАРІ • 20

  • @smolus0512
    @smolus0512 11 місяців тому +7

    Just for anyone wondering. This is absolutely not applicable to a real architecture like x86 (at least not in the way it was presented). First of all the idea of opcode table is impossible since opcodes depend on their arguments. For example, in x86, the assembly mnemonic "add" can refer to 12 different machine instructions, each with different encodings. Second of all, building symbol table on the first pass is also impossible since certain instructions can have variable length. For example "jz" (jump if zero) will be 2 bytes long for 8bit offset, 4 bytes long for 16bit offset and 5 bytes long for 32bit offset. We can't know what length this instruction will have until we know it's distance to the label, and we can't know addresses of labels until we resolve all of these variable length encodings. Chicken and egg kind of problem. Things can get even more complicated if we add external symbols to the mix. On top of that, encoding operands is fairly complicated and varies between different instructions and addressing modes. There are also 6 different prefixes that can be added before an instruction to affect its meaning. Assemblers do a ton of work to encode your assembly code in the most optimal way possible. A lot of people seem to think that assembly is a 1-1 translation to machine code and don't realize how much abstraction there is between assembly and machine code. Assemblers make a ton of choices for you and perform many different optimizations/instruction substitution. They are a lot more sophisticated than people realize.

  • @ra7binet
    @ra7binet 4 роки тому +8

    1: LocationCounter ← 0
    2: Get first line of source code.
    3: while more lines do
    4: if line has a label then
    5: SymbolTable.Symbol ← label
    6: SymbolTable.Location ← LocationCounter
    7: end if
    8: Determine number of bytes required by the line when assembled.
    9: LocationCounter ← LocationCounter + NumberOfBytes
    10: Get next line of source code.
    11: end while

  • @petrosfore6854
    @petrosfore6854 3 роки тому +1

    My Class loved this. Thanks mate.

  • @yelocalwierdo2440
    @yelocalwierdo2440 4 роки тому +5

    OMG I'M SUCH A BIG FAN PLEASE COME TO THAILAND

  • @samuraijosh1595
    @samuraijosh1595 Рік тому +1

    simple and concise. nalla video machi

  • @colonelbarker
    @colonelbarker 2 роки тому +1

    Thanks for making this. Really appreciated!

  • @planetlumi4138
    @planetlumi4138 3 роки тому +2

    I love this man so much

  • @tobbyx3306
    @tobbyx3306 2 роки тому

    There is a question from AS computer Science paper suggest that data items are converted into their binary equivalent is done by first pass

  • @nyan272
    @nyan272 2 роки тому

    Clear and concise

  • @ikran7869
    @ikran7869 2 роки тому

    excellent video!

  • @barrydevine
    @barrydevine 2 роки тому +1

    They aren't highlighted because they are variables (not labels)

  • @vaibhavmankar5275
    @vaibhavmankar5275 3 роки тому

    JUST AWESOME

  • @tarcymatinhure1633
    @tarcymatinhure1633 4 роки тому +1

    your awesome

  • @yelocalwierdo2440
    @yelocalwierdo2440 4 роки тому +1

    incredible video. 420/69