Monday Q&A #5 (2023-03-13)

Answers to questions from last week's video


Each Monday I answer questions from the comments on the prior week’s videos. Transcripts are not available for Q&A videos due to length. I do produce closed captions for them, but Substack still has not enabled closed captions on videos :(

Questions addressed in this video:

  • [0:50] STDS → STOS

  • [1:40] $+0 solves the $0 problem

  • [8:25] “However, this means that an instruction encoded in the stream as 2 bytes might end up in a struct using much more memory.

    Is this the kind of trade-offs that could have terrible performance implications ?”

  • [14:43] “Relatedly, it would be convenient to include these files in my source as tests. but as I've got that publicly on GitHub I'm not sure if that's ok? I'm happy to continue writing my own if not.”

  • [16:55] “Could you please clarify, how does ‘bits 16’ command affects the assembly, if we already use only 16 bits registers? What would happen if we omit it, or, the opposite, what if we write "bits 16" on top of the file but then try to write something like mov eax, ebx? would there be a compilation error?”

  • [22:05] “Probably jmp thegun: here, but does the CPU decode these and turn them into operation its micro architecture understand how to do? Like, the ISA is the interface to the CPU, but the CPU may implement these differently?”

  • [24:10] “Is there a typo for XOR Immediate-to-register/memory?”

  • [25:30] “The Intel document's stuff about the ‘S field’ and ‘sign extension’ of immediate values for ADD/SUB/CMP was rather confusing for me. Sign extension itself was not the problem but it's a bit vague when describing what happens for W = 0 or 1 for immediate data.”

  • [32:30] “I noticed something in trying to decode `lock xchg byte [100], al`, and by that I mean that the order of operands matters somehow with the `lock` prefix?”

  • [37:00] “Why have we been skipping over the segment register encoding?”

  • [38:50] “Also, if three bits in the opcode are enough to identify the operation then what are the rest of them doing? xxx,mov,d,w right? What is the xxx then?”

This video is for paid subscribers