I'm just guessing, but you probably have problems with the way CPU compiles code. I told you once on IRC "just jump to the code", and while that is exactly what you should do, a simple jmp won't suffice.
Let's say you have a CPU with external code connected to the MemBus of the main CPU. Then your external code is at address 65536. You could do "jmp 65536" and your external code would start executing, but... it will fail the first time it encounters an instruction, that used a label.
The problem is that when CPU compiles code, it translates all labels to addresses, but it assumes, that you program starts from address 0, and when you connect it as external code, it starts from address 65536! There are two ways to make it work:
1. Use segmentation.
2. Use "offset" macro.
With using segmentation, you make the CPU execute the code, like it was starting from address 0. Instead of jumping to 65536 (which is 0:65536), you jump to 65536:0 using jmpf:
Code:
jmpf 0,65536 //offset first, then segment
This changes CS to 65536 and resets IP to 0. If your external program then encounters "jmp label", it changes IP to label, but leaves CS unchanged, so it will really jump to 65536+label - exactly where you want it to jump. If you had used "jmp 65536", CS would still be 0 and it would have jumped somewhere into your main CPU.
The way with "offset" macro is very simple. Just put "offset 65536" on the beginning of your external code - this will make the compiler know, that the code is shifted by 65536 bytes and all label addresses will be translated accordingly.
The second way has a drawback. While you can still run the external program as a standalone code when using the first way, you cannot do that with the second way, unless you remove the "offset" macro from the code.
I hope this helps you

Bookmarks