Quick: Identify what this assembly language code does in a 'com' file on MS DOS
dec ax;
push ax;
push bx;
iret;
It restarts the machine!! But why?
A com file on dos is loaded with the AX, BX, CX and DX registers set to 0000h.
dec ax; --> Decrements AX register by 1, hence turning 0000h to FFFFh
push ax; --> Pushes AX register on to the stack which is FFFFh
push bx; --> Pushes BX register on to the stack which is 0000h
iret; --> Fire interrupt return which will grab FFFF:0000 off the stack and load it up in Program Counter
So what lies at FFFF:0000, a simple google search gives us this
" The reset vector is a pointer or address, where the CPU should always begin as soon as it is able to execute instructions."
Basically the CPU starts running code from the BIOS / UEFI , effectively restarting the computer.
BTW...this is not equivalent to int 19 which claims to restart the computer. Int 19 will most likely in some instances restart your boot loader than restart the x86/x64 machine.
This code was the basis of a shutdown/restart program I once wrote to enable dos based virus scanning.
and
This code works right since the 8086 processor.
No comments:
Post a Comment