3 ms·
Could anyone explain why POP CS is so "obviously useless"? The author says it is "as obvious as it is useless", and never explains further. As far as I can und
by jakear 9y ago
Could anyone explain why POP CS is so "obviously useless"? The author says it is "as obvious as it is useless", and never explains further.
As far as I can understand, CS is the top byte of the 16-bit instruction pointer, so sure you wouldn't want to go around changing just that byte. But I feel like I'm missing something because that doesn't seem too crazy out of this world useless to get such a special mention.
- cdumler 9y agoExecution occurs with two registers, Code Segment and Instruction Pointer. Normally, you use other operation codes (JMP, CALL, etc) because they will take into account modifying IP or CS:IP, as appropriate. It would be a really odd situation where you would change the CS, not update IP, and have the proper alignment where it can execute the next instruction. Normally, all of that is computed by the compiler/linker and executed with proper operation codes. The 8086 is a weird beast where the memory access is two 16 bit values mapped to 20 bits (ie. 1 megabyte into overlapping 64k blocks offset by 16 bytes each time). It was easier to write code staying inside a single segment, so chunks of code were often written staying inside one. Nothing particularly useful comes to mind just updating CS; but, my assembly days were a long time ago.