Cosmos/source/Unused/Cosmos.Sys.Plugs/Assemblers/Reboot.cs
Matthijs ter Woord 12d1ae5614 .
2016-06-15 12:50:06 -04:00

67 lines
2.2 KiB
C#

using Cosmos.IL2CPU.Plugs;
using Assembler=Cosmos.Assembler;
using CPUAll = Cosmos.Assembler;
using CPUx86 = Cosmos.Assembler.x86;
using Cosmos.Assembler.x86;
namespace Cosmos.Sys.Plugs.Assemblers
{
public class Reboot : AssemblerMethod
{
public override void AssembleNew(Cosmos.Assembler.Assembler aAssembler, object aMethodInfo) {
new CPUx86.ClrInterruptFlag();
/* Clear all keyboard buffers (output and command buffers) */
new CPUAll.Label(".waitBuffer");
new CPUx86.Mov {
SourceValue = 0x64,
DestinationReg = CPUx86.Registers.DX
};
XS.InFromDX(XSRegisters.AL);
new CPUx86.Test {
DestinationReg = CPUx86.Registers.AL,
SourceValue = 2
};
new CPUx86.ConditionalJump {
Condition = CPUx86.ConditionalTestEnum.NotEqual,
DestinationLabel = ".waitBuffer"
};
new CPUx86.Mov {
DestinationReg = CPUx86.Registers.AL,
SourceValue = 0xD1
};
new CPUx86.Mov {
DestinationReg = CPUx86.Registers.DX,
SourceValue = 0x64
};
XS.OutToDX(XSRegisters.AL);
new CPUAll.Label(".clearBuffer");
new CPUx86.Mov {
SourceValue = 0x64,
DestinationReg = CPUx86.Registers.DX
};
XS.InFromDX(XSRegisters.AL);
new CPUx86.Test {
DestinationReg = CPUx86.Registers.AL,
SourceValue = 2
};
new CPUx86.ConditionalJump {
Condition = CPUx86.ConditionalTestEnum.NotEqual,
DestinationLabel = ".clearBuffer"
};
new CPUx86.Mov {
DestinationReg = CPUx86.Registers.AL,
SourceValue = 0xFE
};
new CPUx86.Mov {
DestinationReg = CPUx86.Registers.DX,
SourceValue = 0x60
};
XS.OutToDX(XSRegisters.AL);
new CPUAll.Label(".loop");//failed... halt
new CPUx86.Halt();
new CPUx86.Jump {
DestinationLabel = ".loop"
};
}
}
}