low level - CPU Emulation and locking to a specific clock speed

If you had read my other question, you'll know I've spent this weekend putting together a 6502 CPU emulator as a programming exercise.The CPU emulator is mostly complete, and seems to be fairly accurate from my limited testing, however it is running incredibly fast, and I want to throttle it down to the actual clock speed of the machine.My current test loop is this: // Just loop infinitely. while (1 == 1) { CPU.ClockCyclesBeforeNext--; if (CPU.ClockCyclesBeforeNext <= 0) { // Find out ...Read more

low level - How does CheatEngine's speed hack work?

Cheat Engine comes with a feature called speed hack which basically can slow down or increase speed of the game. Actually, not only games, if there is a software with clock ticking it can speed-en up that too. How does that work? I might imagine there is some internal clock on which these things run but not sure how these things happen on low level.While this feature has worked on most of the games I tried, it has also failed on many, for eg, NFS Most wanted. Why? Is there any different mechanism on which these games run or it is just some ant...Read more

low level - Is my 'variable-storing area' basically a 'heap'?

I'm planning to implement a simple VM/interpreter kind of thing for a simple language I'm making. The compiler of the language emits mostly stack-oriented instructions to be executed by the VM.The structure of the program will be something like this:The execution part (for lack of a better term): interprets theopcodes and executes them.The call stack: to keep track of function calling, and for parameterpassing and return values.The data stack: for none function-calling-related computation, such asarithmetic.The variable-storing area, where vari...Read more

low level - How does a stack VM manage with only one stack?

Lately I've been asking a lot of questions here about VMs. Here's another one:I understand that often stack based VMs use only one stack - the call stack - for everything. E.g. it is also used for evaluation of arithmetic expressions.What I don't understand is, how doesn't this complicate things a whole lot? I'll demonstrate what I mean with an example.Please consider the following psuedocode program:func main: funcA()func funcA: 2 + 4 * 8This would compile to the following bytecode:main:call funcAendfuncA:push 2push 4push 8multaddend(In ...Read more

low level - What would the register-machine bytecode for this code look like?

I hope this kind of question isn't off-topic on this site.I'm finally getting the hang of what a stack based machine is, and how to compile code for it. For example, the following code: 2 * 5 + 1 would compile to this bytecode:push 2push 5multpush 1addHowever what I want to understand is, the fundamental differences between compiling for a stack based machine and compiling for a register based machine.Basically I want to see what a register-machine's bytecode would look like, as opposed to a stack-machine's bytecode.To understand this, I'd like...Read more

product names - In what way(s) is LLVM Low Level?

In what way(s) is LLVM (Low Level Virtual Machine) Low Level? (At the time of writing, I did not find this expansion of the abbreviation "LLVM" on its web site, but on Wikipedia.)Is it called "Low Level" in what is it designed for (a compiler infrastructure) or because it is works on a "lower level" than other tools?As a (kind of) "illustration" of this, is LLVM lower-level than the JVM and CLR, or is it only designed for "lower level" uses?...Read more

low level - Why do executables depend on the OS but not on the CPU?

If I write a C program and compile it to an .exe file, the .exe file contains raw machine instructions to the CPU. (I think).If so, how is it possible for me to run the compiled file on any computer that runs a modern version of Windows? Each family of CPUs has a different instruction set. So how come any computer that runs the appropriate OS can understand the instructions in my .exe file, regardless of it's physical CPU?Also, often in websites in the "download" page of some application, you have a download for Windows, for Linux, and for Mac ...Read more

What kinds of low level knowledge matter?

I realize that this question is similar to Low level programming - what's in it for me, but the answers didn't really address my question well. Part from just an understanding, how exactly does your low level knowledge translate into faster and better programs?There's the obvious lack of stop-the-world from garbage collection, but what else is an advantage? Do you really outperform your optimizing compiler? Do you pack your data structures in as tight as possible and be concerned about alignment? There's extra freedom naturally, but does th...Read more

High level vs. low level programming. Do I really have to choose?

Every once in a while I'm asked in interviews which I like the best- low level or high level. It seems to me that the implicit message is that they are both a specialty and they want to know which direction I'm heading. The trouble is, I seem to like both. Low level is extremely challenging and often requires a great deal of esoteric knowledge. High level is where all the sexy things happen: applications that people use directly, results that can be easily demonstrated (showed off) in a way that is accessible to everybody, and you get to work w...Read more

As a programmer, should I know low and high-level programming languages?

I been contacted to do some work remote controlling LEDs displays over TCP/IP, but my experience and preparation is mostly about high-level programming language. I said that to the person who contact me about the work and he told me that: "if you call yourself a programmer you should know all these things"Should a programmer really know the details of low-level programming? Or can I treat it as a black box concept, as theoretical knowledge but not necessarily doing it or implementing low level language solutions, having in mind that low-leve...Read more

flowchart - Is there any example or resource explaining/showing code from High-level to Low-level to deep down Machine code?

I have been searching for an example over the internet that shows any operation like saving a file or drawing anything in UI or any other sort that shows the implementation from High-leve language code to Low-level code to deep down machine level code.The basic idea is to explain the computer working in a nutshell. Like, in high-level laguage we write int c= int a + int b which is compiled into low-level code IL_0001: ldarg.1IL_0002: ldarg.2 IL_0003: add and then to machine level code.Any example or code flowchart from high-leve language to dee...Read more