World: r3wp
[rebcode] Rebcode discussion
older newer | first last |
Steeve 20-Feb-2007 [1666] | i attempt to do a Z80 emulator |
BrianH 20-Feb-2007 [1667x2] | It really doesn't gain you much speed. The label fixups are done once, at rebcode function creation time. After that it just calls the offsets - the label statement is a noop. I only do straight offsets when generating code (like you are). Be careful though, as the offsets are calculated from the end of the branch statement, not the beginning. |
This only matters when writing your own offsets. I only noticed when I started using the BRAB opcode, and its predecessor BRAW. | |
Steeve 20-Feb-2007 [1669] | anyway, can i replace assembly* by a dummy function ? |
BrianH 20-Feb-2007 [1670] | You can replace assembly* with a Z80 assembler even. |
Steeve 20-Feb-2007 [1671x2] | ok |
i noticed that i can join the code of 2 rebcode function without re-assemble them | |
BrianH 20-Feb-2007 [1673x2] | Remember that the current assembler* doesn't do much, and even that is done at rebcode function creation time. It has no effect on execution time. |
If you join these function blocks after the rebcode function is created, you may have context issues. It is better to join them before assembly. | |
Steeve 20-Feb-2007 [1675x3] | yes but i try to do emulation + a debugger , so Z80 opcodes are converts step by step |
i have no context issues, cause all words i use have the same context | |
there is no local words in my rebcode functions | |
BrianH 20-Feb-2007 [1678] | You can do code snippets for your emulation/debugger, and concatenation for direct execution. |
Steeve 20-Feb-2007 [1679] | it's what i do |
BrianH 20-Feb-2007 [1680x2] | As long as you are careful the semantics shouldn't change. |
Remember that these branch statements group statements together into basic blocks, so you should break up your code into snippets on boundaries between these blocks. | |
Steeve 20-Feb-2007 [1682x2] | that why i don't use branch statements |
branchements are controled outside rebcodes functions | |
BrianH 20-Feb-2007 [1684x2] | For non-generated code, the only useful branch statement in rebcode is BRAB. All others have better structured equivalents. |
BTW, the English word for branchements is branches. | |
Steeve 20-Feb-2007 [1686x2] | i have a main loop wich do the branchements and call the rebcode routines |
sorry | |
BrianH 20-Feb-2007 [1688x2] | Just trying to help :) |
Are you doing a compiler or an interpreter? A compiler would be faster, but would require you to translate branches. | |
Steeve 20-Feb-2007 [1690x2] | it's an hybrid way |
i try to do the two things | |
BrianH 20-Feb-2007 [1692] | A JIT compiler, perhaps? |
Maxim 20-Feb-2007 [1693x2] | sort of like a JIT ? |
hehe | |
Steeve 20-Feb-2007 [1695x3] | first i parse Z80 opcodes and execute them step by step, then they are concatened to build sub-routines and cached, if sub-routines are mantory another time, then i call cached sub-routines instead of reparse the opcodes. |
*mandatory | |
(requested is better) | |
BrianH 20-Feb-2007 [1698] | Do you do basic block analysis of the source opcodes to determine where the subroutine boundaries are? For that matter, does the Z80 have indirect branches? |
Steeve 20-Feb-2007 [1699] | ;-_- |
BrianH 20-Feb-2007 [1700] | Sorry, I don't speak IRC. |
Steeve 20-Feb-2007 [1701x2] | yes indirect branches exist |
but it's not a problem, the management of branches is done in real time, it's in a stack, so i can manage fixed as indirect branches. | |
BrianH 20-Feb-2007 [1703] | How common are they? Can you analyze them to determine their destinations to convert them into branches or calls? |
Steeve 20-Feb-2007 [1704x2] | all branches are converted into call |
difficult to explain with my bad english | |
BrianH 20-Feb-2007 [1706x2] | Call of function or continuation? (Sorry if your English doesn't include computer-science terms) |
Meaning, does the call return? | |
Steeve 20-Feb-2007 [1708x2] | when i seek a Z80 branch opcode (direct or indirect), i stop the current rebcode function construction and i build new one for the folowing opcodes |
so each rebcode function (routines) must return the adress of the next branch | |
BrianH 20-Feb-2007 [1710x2] | Continuation then. |
How do you handle back-branches then? | |
Steeve 20-Feb-2007 [1712x2] | if a routine return an unknwon adress, then the parser jump a these adress and rebuild a new function. |
back-branches are treated in the same manner | |
BrianH 20-Feb-2007 [1714] | So, no basic block analysis at all. All branches are considered non-local. |
Steeve 20-Feb-2007 [1715] | yep |
older newer | first last |