Vote count:
0
I disassembled a simple DOS .COM program and there was some code which saves and restores registers values
PUSH AX ; this is the first instruction
PUSH CX
....
POP CX
POP AX
MOV AX, 0x00 0x4C
INT 21 // call DOS interrupt 21 => END
This is very similar to function prologue and epilogue in C programs. But prologues are added automatically by compiler, and this program was written manually in assembler, so the programmer took full responsibility for saving and restoring values in this code. My question is what will happed if I unintentionally forgot to save some registers in my program? And what if I intentionally replace these instructions to
NOP in HEX editor? Will this lead to program crash? And why called function is responsible for saving outer context on the stack? From my point of view this should be done somehow in calling function to prevent problems if I use 3rd party libraries and poorly written code which may break my program execution.
Saving registers state in COM program
Aucun commentaire:
Enregistrer un commentaire