+ Reply to Thread
Page 2 of 4 FirstFirst 1234 LastLast
Results 11 to 20 of 31
Like Tree3Likes

Thread: Foxi Project

  1. #11
    Wire Sofaking Fizyk's Avatar
    Join Date
    Jun 2008
    Location
    Łomianki, Poland
    Posts
    740
    Blog Entries
    1

    Default Re: Foxi Project

    Quote Originally Posted by -=Fox=-
    I've been trying to diagnose why my external code execution fails... so far no luck...
    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

    My programs: BIOS - Alcyone - Calculator - Notepad - Movie Player
    My tutorials: applyTorque - Quaternions - PID controllers
    Some other things I made: FT Chip - RK4 Solar System

  2. #12
    That furred thing Black Phoenix's Avatar
    Join Date
    Feb 2007
    Location
    Kyiv, Ukraine
    Posts
    3,565

    Default Re: Foxi Project

    Quote Originally Posted by Fizyk View Post
    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
    You can use address bus to auto-translate all addresses up by 65536, effetively allowing second way
    I'm a wire-crazy person with a tail.

    Take a daily journey into my brain

    D2K5

  3. #13
    Wire Sofaking Fizyk's Avatar
    Join Date
    Jun 2008
    Location
    Łomianki, Poland
    Posts
    740
    Blog Entries
    1

    Default Re: Foxi Project

    Oh, I didn't know about the possibility with the address bus.

    Also, I forgot to mention one thing: with the first way, it will still fail at memory references. Every #variable will refer to the main CPU, because variable names are also labels, and in this way label addresses are translated with the assumption that code begins with 0. This can be fixed by changing DS to 65536, as #variable really is DS:#variable - so when you change DS, this reference will be shifted by 65536 bytes and everything will be ok. The way with "offset" macro doesn't have this problem - offset already shifts the variables too for you.

    My programs: BIOS - Alcyone - Calculator - Notepad - Movie Player
    My tutorials: applyTorque - Quaternions - PID controllers
    Some other things I made: FT Chip - RK4 Solar System

  4. #14
    That furred thing Black Phoenix's Avatar
    Join Date
    Feb 2007
    Location
    Kyiv, Ukraine
    Posts
    3,565

    Default Re: Foxi Project

    Quote Originally Posted by Fizyk View Post
    Oh, I didn't know about the possibility with the address bus.

    Also, I forgot to mention one thing: with the first way, it will still fail at memory references. Every #variable will refer to the main CPU, because variable names are also labels, and in this way label addresses are translated with the assumption that code begins with 0. This can be fixed by changing DS to 65536, as #variable really is DS:#variable - so when you change DS, this reference will be shifted by 65536 bytes and everything will be ok. The way with "offset" macro doesn't have this problem - offset already shifts the variables too for you.
    Negative address bus offsets are your friends!
    I'm a wire-crazy person with a tail.

    Take a daily journey into my brain

    D2K5

  5. #15
    Wire Sofaking -=Fox=-'s Avatar
    Join Date
    Feb 2007
    Location
    Somewhere in my Mind...
    Posts
    1,846
    Blog Entries
    7

    Default Re: Foxi Project

    I've tried :

    jmpf 0,65536

    It didn't seem to do that job... I've tried several variants of it as well.

    I didn't think about offsets, I'm not sure what I should try... So obviously I'm a little confused... I need concrete examples that work to really understand it.

    So could I get a very small example of WORKING external execution code?

    AND! (questions)

    Does the external CPU (with code) need to have anything done to it, to better have its code run.

    And does the code have to be formatted in a certain way, should their be defines or alloc's in external the code?
    http://tiny.cc/OMFGWTFBBQ

    Best People On Wiremod!

    Black Phoenix, Azrael, Jat Goodwin, Magos Mechanicus, ITSBTH, Fizyk, g33v3s,tuusita, InfectiousFight, ief015

    Pointless things that are pointless, are pointlessly pointless, therefore pointlessness is pointless.
    So pointlessly pointing out the pointlessness of this pointless signature is utterly pointless.
    My IQ is 123

  6. #16
    No u Divran's Avatar
    Join Date
    Jul 2008
    Location
    Sweden
    Posts
    4,582

    Default Re: Foxi Project

    Are you using a graphics tablet to get the aim coordinates? I suggest using :toLocal() and :keyUse() for more epicness. I made an E2 that works just like a graphics tablet that way
    SVN Tutorial
    My SVN:
    Code:
    http://divranspack.googlecode.com/svn/trunk/%20divranspack/
    Get dropbox and get 250 MB extra space: Dropbox

  7. #17
    Wire Sofaking Fizyk's Avatar
    Join Date
    Jun 2008
    Location
    Łomianki, Poland
    Posts
    740
    Blog Entries
    1

    Default Re: Foxi Project

    Quote Originally Posted by -=Fox=-
    So could I get a very small example of WORKING external execution code?
    Main CPU:
    Code:
    mov ds,65536
    jmpf 0,65536
    External CPU:
    Any code that you could execute in a single CPU

    And of course that's with the assumption, that the external CPU is connected directly to the MemBus of the main CPU.

    Quote Originally Posted by -=Fox=-
    Does the external CPU (with code) need to have anything done to it, to better have its code run.

    And does the code have to be formatted in a certain way, should their be defines or alloc's in external the code?
    No and no.

    My programs: BIOS - Alcyone - Calculator - Notepad - Movie Player
    My tutorials: applyTorque - Quaternions - PID controllers
    Some other things I made: FT Chip - RK4 Solar System

  8. #18
    Wire Sofaking -=Fox=-'s Avatar
    Join Date
    Feb 2007
    Location
    Somewhere in my Mind...
    Posts
    1,846
    Blog Entries
    7

    Default Re: Foxi Project

    AH! Sweet Fizyk, that makes sense.

    I'll be updating the First post with a more updated version of the dupe *soon*
    http://tiny.cc/OMFGWTFBBQ

    Best People On Wiremod!

    Black Phoenix, Azrael, Jat Goodwin, Magos Mechanicus, ITSBTH, Fizyk, g33v3s,tuusita, InfectiousFight, ief015

    Pointless things that are pointless, are pointlessly pointless, therefore pointlessness is pointless.
    So pointlessly pointing out the pointlessness of this pointless signature is utterly pointless.
    My IQ is 123

  9. #19
    Wire Sofaking -=Fox=-'s Avatar
    Join Date
    Feb 2007
    Location
    Somewhere in my Mind...
    Posts
    1,846
    Blog Entries
    7

    Default Re: Foxi Project

    Hey! Just letting everyone know I'm still alive.

    I've had MAJOR setbacks in internet access and getting on Gmod so hang on to your pants.

    I have a new version of Foxi and I've got the first peripheral for it (a Modem!) and a program to work the new peripheral (which has a few bugs) but at any rate I'll continue to work the bugs out and TRY to get a release out to you guys, I know I haven't been active but its a limitation that I have to live with for the moment.

    Hang in there!
    http://tiny.cc/OMFGWTFBBQ

    Best People On Wiremod!

    Black Phoenix, Azrael, Jat Goodwin, Magos Mechanicus, ITSBTH, Fizyk, g33v3s,tuusita, InfectiousFight, ief015

    Pointless things that are pointless, are pointlessly pointless, therefore pointlessness is pointless.
    So pointlessly pointing out the pointlessness of this pointless signature is utterly pointless.
    My IQ is 123

  10. #20
    Wire Amateur krazyfool's Avatar
    Join Date
    Jul 2009
    Posts
    77

    Default Re: Foxi Project

    I look forward to its epicness ^__^

+ Reply to Thread
Page 2 of 4 FirstFirst 1234 LastLast

Similar Threads

  1. Sapphire Project
    By dnifan in forum Developer's Showcase
    Replies: 77
    Last Post: 07-14-2010, 09:54 AM
  2. Project Boss
    By gameguysz in forum Installation and Malfunctions Support
    Replies: 9
    Last Post: 10-14-2008, 12:29 AM
  3. Current Big Project?
    By Eagleguy125 in forum Wiremod General Chat
    Replies: 55
    Last Post: 01-06-2008, 02:29 AM
  4. Project Overlord
    By Eagleguy125 in forum Wiremod General Chat
    Replies: 25
    Last Post: 11-11-2007, 08:00 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
proceed-collector
proceed-collector
proceed-collector
proceed-collector
linguistic-parrots
linguistic-parrots
linguistic-parrots
linguistic-parrots