PNF: Help with a Loop to Identify extrai values
I have this loop:
Code:
unsigned long ifcounter = 0, ifcounter2 = 0, sifcounter = 0; Here's a brief explanation of what's supposed to be going on. This is running a program. A program has a variable number of memory slots. It has the same amount of extrai values. extrai is a register. extrai is computed at run time, during the load. The rest of the information comes from a file. A file has a signature: !@.PNF A file has a series of numbers. Generally the first number is the instruction, the second, the type, and the third, the operand. For ifs, extrai is supposed to count the ifnumber. That's where this goes wrong. This is a loop that is computed at load time. It's supposed to count the ifs, and then load extrai with the ifnumber. Ifs look like this: Code:
IF TVOID 0V |
If variable i is equal to reg.ecount, then the loop will never execute.
What have you done to debug this? You gave code, but not all references contained within the code. Run GDB on this and single step through it using some watchpoints on the relevant variables. There are some links in my signature giving instruction about how to accomplish this. |
reg.ecount marks the end of memory. It isn't and won't be equal to that until we have looped through the memory.
I have been doing a series of write technique output commands. Plus I've been desk checking it thourouly. I always forget about gdb... What references are still missing? |
I figured it out, it would seem.
Code:
unsigned long ifcounter = 0, sifcounter = 0; Code:
case IIF: Code:
VERSION TVOID 0V |
I should probably give one more code block:
Code:
case IIF: |
Quote:
You've got this class reg containing methods and variables which are not defined, nor described here. Same thing for the mem class. One can only infer what things mean if they come close in descriptive names, however that's not the way it should be because mistakes can be made by way of incorrect assumptions. Further, there are tons of if-test result conditions where you are using definitions, macros, or type defines; once again, none of these are referenced or defined. At this point I don't understand what, if any, question remains. You've posted so much additional code of similar lack of background explanation. |
des_a, I know that you have been pointed here previously, but I ask you again to please review the Site FAQ for guidance in asking well formed questions.
The file signature, more blocks of code and your PNF language syntax are not relevant nor helpful to others taking their time to try to understand and answer your question. If you are troubleshooting a loop problem, then begin by defining a simplest case which will reproduce the problem, with well defined loop parameters and entry and exit conditions. Then try to troubleshoot it using printf statements to show the state of those parameters on each pass and use gdb to help figure it out. If you cannot figure it out, then you will have at least collected the necessary information to post here when asking for help. Please refrain from posting blocks of code and asking others to first try to understand how it should all work, then why it may not be working. That is not a proper use of this forum and is not respectful of the time others contribute to help with your problem. Help others help you by presenting a minimal test case with well defined parameters relevant to a clearly stated question. |
It looks like I didn't define the question well enough. The problem I'm facing may not be the loop at all anymore. The problem may be somewhere else in the code, probably in my PNF::execute() function.
|
Code:
VERSION TVOID 0V Clearly it's jumping to the wrong part of the if. Why??? |
1 Attachment(s)
Documentation on the language so far.
|
Any other registers are new, so they are "scratch registers" for the current time. mem, is the program's memory.
|
If this is still not clear, I will just close this thread. I have one other possible source I can think of to find more information on what's going on, besides "luck". If I need to, I will do that, and then see what that produces, and then if needed still, THEN come back here, with hopefully a better question. If you need to tell me whether I should do that or not. Thanks!
|
P.S. - The problem is probably that I didn't phrase the question right, so I'm not getting as good of help as if I'd thought that through better...
|
Quote:
Quote:
Meanwhile, your first post here used code in the C language, which is what I was addressing. Your proposed language is mostly C, or very similar. Quick review of that syntax tells me that there's nothing I can't do in the C language and that you've just written a wrapper for the C language. To me this is a supporting architecture which I'd use for an R&D project. That's how things are done, you create customized macros, enumerations, type definitions, and functions to help the form of your architecture be what you intend it to be. As Astrogeek says, you should review the forum guidelines about how to ask an effective question. If you are going to persist with discussions about your invented language, then literally every thread you start should have a couple of things (a) a clear statement at the top of the first post which states this is what it is about, not "I have this loop" followed by a bunch of code and then continued discussion on your part with little direct questions, and (b) reference links for those interested in reviewing the language in general, such as your grammar document, and other information about this language. Otherwise you will be wasting your time and the time of others |
Quote:
|
All times are GMT -5. The time now is 12:50 AM. |