Q:Code,ProgramWhy can it end normally?
Assume Cs: codesgcodesg segment mov ax, 4c00h int 21 hstart: mov ax, 0 s: NOP mov Di, offset s mov Si, offset S2 mov ax, CS: [Si] mov Cs: [di], ax S0: JMP short s S1: mov ax, 0 int 21 h mov ax, 0s2: JMP short S1 nopcodesg endsend start
After the s part is executed, the s part is rewritten:
JMP S-8
MoV Di, offset s
MoV Si, offset S2
MoV ax, CS: [Si]
MoV Cs: [di], ax
Therefore, when JMP short s executes s again, it will jump to the Cs: 0000 location, that is
MoV ax, 4c00h
Int 21
So it will end normally.
Knowledge point: the transfer instruction is converted to a relative offset address during compilation. Here, ebf6 is the reverse jump of 8 bytes from S2 to S1.
The same command code, ebf6, that indicates redirection
S2:
JMP short S1
NOP
JMP short S1
In
S:
JMP 0000
MoV Di, offset s
MoV Si, offset S2
MoV ax, CS: [Si]
MoV Cs: [di], ax
JMP 0000