Monday Q&A #7 (2023-04-10)
Answers to questions from last week's videos
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:
[00:31] Me explaining the parity bit.
[11:07] Me explaining the overflow bit.
[20:44] “Is it generally possible to directly write to the Flags register? In which case a fully accurate simulator should be better off storing it like a register instead of using i.e. booleans for each flag?”
[23:00] “I didn't know that the CPU keeps track of overflow of operations, I always though we just get wrong result when there is overflow. Is it possible to examine the overflow flag in C? If so, why is it not common practice to do so?”
[24:57] “In listing 47 you begin the program by doing an add without initializing the registers. In a real program are the registers set to zero at the beginning, or do they hold garbage values?”
[27:17] “Am I right in guessing that AF was used for fixed point arithmetic based on the manual saying that the thing was used for decimal arithmetic?”
[29:12] “This might be off-topic. It seems the 8086 architecture was trying to save as much as space as it could. Yet the flags register has 7 bits not being used. Was it possible back then for programmers to access those "unused" flags bits to store additional information for the programmers?
If those bits are not accessible, why not move all of the bits to the right to fill up the "empty" gap? Is there a performance hit if there is only one bit used within 8 bits?”
[31:25] “aren't you rather testing at the top, then if true, execute the body of the loop, and at the end do an unconditional jump back to top? what you describe is a do/while.”
[32:25] “I might have missed it but how we would be able to jump more than 127 bytes forward and 128 bytes backward if we only have a single byte for displacement?”
[33:55] “What does the "$" mean within the jumps in the output?”
[35:44] “In listing_0049_conditional_jumps, shouldn't the immediate value for 10 in `add bx, 10` be 2 bytes since w is 1? Looks like it is only 1 byte, there is no 0 byte following `0b1010`.”
[40:44] “My question is only loosely related to this week's homework.
What is the correct interpretation of the documentation for the high byte of multi-part opcode (immediate ...) add, sub, cmp?
I mean this...
add: [data if s: w=01] ... I interpreted this as s=0, w=1
sub: [data if s: w=01]
cmp: [data if s: w=1] ... I interpreted this as s=1, w=1”