//Cycles public void fetch() { //First Get the instruction from the address of the pc counter. //Since the memory can load directly without the need of the full address, //Calculate the offset int offset = PC - 4194304; //Now fetch; IR = Mem.loadInstruction(offset); //First check if IR =0 int IR_int = Convert.ToInt32(IR, 2); if (IR_int == 0) { //Now check if Clock == 0; if (clock == 0) { running = false; EmptyInstructions.Invoke(); } else { running = false; Terminate_Dropped.Invoke("Program Dropped...\n"); } } else { running = true; //Now increment the PC; PC += 4; //by one because LoadInstruction handles the stuff.. ;) Fetched.Invoke(); } }
private static async Task <XDocument> LoadFromUrlAsync(Uri url) { using (var httpClient = new HttpClient()) { httpClient.DefaultRequestHeaders.Add( "User-Agent", "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.3; WOW64; Trident/7.0; Touch; .NET4.0E; .NET4.0C; .NET CLR 3.5.30729; .NET CLR 2.0.50727; .NET CLR 3.0.30729; Tablet PC 2.0)"); Fetching?.Invoke(null, new FetchingEventArgs(url)); try { using (var hs = await httpClient.GetStreamAsync(url)) { var document = SgmlReader.Parse(hs); Fetched?.Invoke(null, new FetchedEventArgs(url, document, null)); return(document); } } catch (Exception ex) { Fetched?.Invoke(null, new FetchedEventArgs(url, null, ex)); throw; } } }