3 ms·
Memory can addressed by taking offset from RSP (or [ 0x10 ] eg).
by meanduck 10y ago
Memory can addressed by taking offset from RSP (or [ 0x10 ] eg).
- bluetomcat 10y agoHere is how I implemented a small instruction set for the VM of my experimental language, without using GPRs. Basically, instruction operands are divided into 4 classes: - G (global): the operand refers to the global memory space and contains an offset and size. - A (automatic): the operand refers to the current stack frame. The offset is relative to the current base pointer. - I (immediate) - T (temporary): this is where intermediate results from computations are stored. For example, the result of `a + b` from `(a + b) * c` would be stored in the T memory space. Upon the end of a statement in the HLL, all values in the temporary space are discarded. Reference: https://github.com/bbu/quaint-lang/blob/master/src/exec.c https://github.com/bbu/quaint-lang/blob/master/src/exec.c
- meanduck 10y ago> - A (automatic): the operand refers to the current stack frame. The offset is relative to the current base pointer. Did you mean stack pointer ? base pointer gets set once where as stack pointer changes between every function call. > Here is how I implemented a small instruction set for the VM of my experimental language, without using GPRs. stack pointer is still necessery unless some memory region is predefined as stack pointer. 'A class' can be made more space efficient by dividing stack into 16 chunks and then instruction would only need 4bit to address.
- meanduck 10y agoAccording to the thesis recent intel microarchs caches the top several words of the stack[1]. Thesis references intel optmization manual but does not say where in the manual. [1] pg 12, para 5.