Tuesday, March 28, 2017






Well, there it is. Velleman PCS500.
Hooked up to a Pittman GM34423E066-R7 3phase brushless supermagnet gearmotor handcranked as a generator for 6 green 3mm straw hat 2.8-3.2V LEDs put into the 3 holes.

What a day though. Came with bad power supply. Ground the flathead security screws of it down with a carbide rotary drill. Inside the transformer coils desoldered reads0.4 ohm secondary(quite fat wires to where it's believable) and 45 ohms primary. Inside there is the two coil transformer, 4 diodes and a 1000uF capacitor. But it won't get 9VAC on the desoldered secondary. It's not shorted unless you call the 0.4 ohms a short. I still don't know whats wrong with it, I'll figure it out later. Luckily I had another power supply 9V 0.6A of the same plug type, which I'm using now. Fixed that problem, but now it would not calibrate. Sometimes.

So my Toughbook CF-29 LPT port has hiccup issues. Flatline "transient recorder" mode with probe tip grounded gets all kind of garbage jumps and spikes. So that above is from an Presario R3000 with properly functioning LPT port. Probe tip clipped to the diode legs, and motor cranked back and forth a few gearmotor turns.I don't have good data on what comes off the control-measuring section of the motor, but this scope is gonna be the tool to figure that out. I might be ultimately able to use some of these motors for bicycle assist type stuff. Not too much, just to keep the bike rolling on flat terrain without pedaling We'll see.

Wednesday, September 24, 2014

Fever

Yay, I have a fever. I used to have fevers all the time while growing up, but I have not had a fever, no matter how sick, since 2006 November, last I remember. I must have been immune suppressed by something, but I finally have a fever again! :) I did go through hell to attain it though.

Thursday, November 4, 2010

coincidences

sometimes i wonder if there are higher intelligence beings around, and we're to them like chickens, dogs or more like monkeys are to us.. aliens from other worlds or even beings from this earth, meddling in our lives, for entertainment, curiosity, or who knows what.. i mean why is it that we're on top, the best, as far as we can tell.. the most intelligent? what if there is another layer of "fun loving" beings between us and the "one" God if there is one, and he is God for them as he is to us and the chickens ... and what if "God" doesn't really get involved, but they, they do, and sometimes they have different plans for us than we do, and make all kinds of weird things happen to us, including smacking ourselves.. out of benevolence or what not... weird things happen to me too nonstop, i mean like omg, all this is way past what randomly should happen... but im one stubborn mofo.. i go head against the wall nonstop... i can feel "guidance" in one direction, but i purposely make suicidal and unrational choices against it simply to assert freedom.. inner freedom.. because that is the most essential ingredient of life and survival.. you let freedom slowly erode and slip from you and people in general, you might as well call yourself dead.. it does not mean stupidity, conceitedness, lack of discipline or even unwillingness to die.. or disregard for the rights of other beings, including other people.. we talk about inner freedoms, and whatever externally affects that.. a one God would not set out to rob you of your inner freedom, but other, higher intelligence beings might, just like we, humans, unfortunately, do animal research because we dont know the answers, or, have to control animals to breed them, or hunt them simply for food, like eskimos almost have no other choice, its hard to be vegetarian where nothing is green, just ice.. a one God knows the research answers, and does not need food... of course with the advent of remote control, tiny candid cameras, and unpublished scientific research, it might be just people like you and me pulling amazing stunts on you, they dont have to be higher intelligence.. and then again, also, one has to be careful with drawing the conclusion that something is nonrandom... i cant find the exact reference, but i read somewhere this: a teacher gave as homework to roll a dice 3000 times or so, and write down the numbers.. he' grade them, like 27 kids got A's, and 3 got F's for cheating, for making up the numbers without actually rolling the dice.. how did he know? it's easy.. the people who did not have enough 4 sixes or twos or threes in a row, or enough density of 3 of the same kind in a row, something we may not generate enough of when we make up the numbers off the top of our heads.. true randomness requires a certain density of coincidences, of spookiness, and lack of such things is what should actually be very spooky.. as in how come nothing weird or spooky ever happens to me... that would be spooky.. so when calling a judgement on this is way past simple coincidences, am i on candid camera, is somebody messing with me, why does all this happen to me but nobody else around me, at least nowhere near to the same extent.. one has to consider the minimum required threshold of spookiness before things can be deemed nonrandom anymore, and a search for deliberate intent can be justified.. this is how religion throughout the world might be so universal... saying i can feel a "presence" may simply be an error in the human mind's judgment about the minimum required spookiness threshold for truly random things.. but then again, it may not..

PS. disregard for the rights of other beings:
we need to kill in order to live, and figuring out a sterile way to live, such as desert solar electric run plants generating ammonia and food proteins from co2, h2o, n2 and rock, without any dna being involved or "killed" in the generation of that food, is not necessarily "better," compared to being embedded in the middle of trees, bugs, birds, inside a desert arboretum, touching the trees, walking on grass and crushing it in the process, stepping on bugs because its impossible to walk around any other way if there is abundance of life, but if seeing a sufficiently large one, not stepping on it on purpose.. but stepping next to it.. killing for food, but as little "higher" lifeforms with a mind and nerves and "pain" as possible.. it's hard to say whats better for the cows.. us eating them as meat, and ensuring their survival by making them numerous, or just milking them, and being less numerous.. ethics is a measure of luxury, and some people stuck in a cave from an avalanche on a ski trip for weeks have been excused in the eyes of the law for eating each other, given the circumstances.. because life is precious.. in view of disregarding the rights of other beings.. and just as with cows, same with chickens and eggs.. what's better for them... not eating chicken meat, or not even eating their eggs, and thereby threatening them with extinction.. in this sense we too, would we rather be slaves, to beings of higher intelligence than us, or even to our fellow humans, that would breed us, protect us and ensure our own survival too, as long as we obeyed them and followed their command, or would we rebel and say, give me liberty or give me death? we could say the thing that separates human beings from animals is this necessity of freedom, but that is not true.. animals have the same need for freedom (as much as i can relate to other social mammals like dogs and cats, that come to me out of their own good will, but do not like to be forced, less to salmons spawning and dying that could care less about me).. life is precious and i'd rather live through slavery than die.. holding on to some inner freedom that comes across as some retarded stupidity and suicidal occasional stubbornness, that constant dormant unpredictability.. that makes my masters uneasy, and give up like an unpredictable horse breed.. temporary slavery is ok.. is all i ever known.. permanent.. that is a different story.. i'd like to see chickens roam around freely, embedded among other life and trees, happy, but i do buy cheap eggs out of nonluxurious necessity, temporarily.. thats how id like to be a permanent slave to higher lifeforms.. happy and free... like a mexican native complained.. he does not like it in the city.. there is no room for the chickens.. back in his village the chickens roam around wildly.. he loves chickens and cannot imagine his life without them, even if he eats them, he likes hi chicken to be free and happy, he loves them.. if i'd have to be a permanent slave, or a chicken, thats the kind of master i'd want.. the one that eats next to me, lets me sit on his shoulders.. and we "live" together, fighting death using each other.. thats a stark contrast to remote ownership profit driven industrialized crowded chicken cages.. a hell which i presently have to support because i have bills to pay

PS2. Animals need freedom just like humans - in zoos the fertility rate used to be very low, until recent times, when the needs and happiness and freedom of animals has been better understood. Often even after artificial insemination females used to reject offsprings, because they were not feeling free. That is for wild animals, which come from a world where absence of balance and self regulation can devastate everything, including the highly successful and proliferating species itself. Truly wild animals high up on the foodchain, responsible for the balance of vast ecosystems beneath them and with a lot of power to devastate it, do not breed well in captivity. In this sense man is an animal thats highly proliferating, but ceases to be truly wild, dangerously out of balance with its environment. Though if you can live sustainably in outer space, and "create" new space for life (there is a whole lot of room up there), you can say that you are responsibly proliferating. Ultimately, even considering all the room and resources of outer space, the malthusian catastrophe of populations getting out of hand can only be countered with war, disease, predators, famine - none of which are nice - or self regulation, like China's 1 child policy, of course, only in times of need. Self regulation aint no fun, but it's better than any of the other choices.
Freedom is an overall sense of space, room, excess and abundance of resources, all in all excess luxury, that new life depends on.

Thursday, January 7, 2010

Changes

Well, so much for lack of sleep. After 4 months of irregular pay, no pay all December, and reluctance to change direction into something profitable, such as growing mushrooms, I finally quit my worm castings job today. I said I resigned, and the 1 year notification clause of any inventions in the intellectual property agreement should be counted from today. They did not accept my resignation. What can I do? Now I just hope I can save my other job where I was messing up from not enough sleep.

When you get a job and are asked to sign an intellectual property agreement, what are your choices? Not sign and be out the door, or sign and shut your brain down, especially when the nature of the job is a physical labor type job. They were trying to turn it into a research type position by forcing you to record observations about earthworms, which of course eventually leads to experiments with earthworms, and of course some questions can only be answered by things such as a vivisection. Oh come on, they are only worms! I'd rather be out the door than have to perform vivisections, at least as long as nobody holds a gun to my head, or the other choice being starvation. There is a fine line between experimental research and record keeping for accounting purposes. I squarely refused to do any kind of biotech research from the beginning, but I had to end up doing record keeping type of stuff for the physical labor. By the way, in general an intellectual property agreement is in fact saying that if you come up with anything, you can't do it, because we own the technology, you signed it over when you started the job, and you can only practice it if you purchase a license from us for the stuff that you came up with. It used to be that inventors owned their inventions. Now it's owned, or more like extorted by those who provide them with the chairs, pens, or lab equipment. Or food. Because you have to eat. What's fair? Signing a standard intellectual property agreement that we own anything and everything is a default requirement for almost any job anymore, because they can get away with it. I practically gave up a good paying job over it. I'm looking for only jobs that don't require such an agreement anymore, because I like to think freely, without worrying about oops, there it goes, I had just come up with an idea there, and I should have run to my "owner", or "boss" or "manager" and should have protected his intellectual property for him, because he made me sign an agreement. Freedom of mind is like the most important thing to me anymore. That ip agreement was the worst part of that job, being "forced" to sign that agreement, to acknowledge that thoughts are owned by anyone. Of course you're not "forced", anyone is free to quit a job as soon as they win the lottery, but you're signing an unequal treaty out of necessity. When you have bills, the only way to make it is to have an income, and usually that means having a job, and someone "has to" give you a job, or else you can't pay your bills. Of course they don't "have to," but once someone gives you one, what can you do? If nothing else, it's entertainment - they tell you to dance, or do really retarded and stupid things for their personal entertainment, and you do it, because it's a job, especially in an economy where you can't find another job, or the other ones go even deeper against your conscience. What's wrong with entertainment?

On the computing front, I've come across the Loongson cpu, and the Yeelong laptop used by Stallman too. "The world's first laptop which contains completely free software. All system source files(BIOS, kernel, drivers etc.) are free, no close firmware needed." It's not very beefy, not enough power, but it's surely beefier than a Microchip microcontroller, with similar freedoms. Did I say freedom to do whatever you want on your computer in the privacy of your own home? On more than just a microcontroller? I'm salivating. Too bad I can't afford one right now.

Saturday, November 21, 2009

Well

I have a new reality to adapt to, lack of sleep - I work 2 jobs now, 11pm-7am, then my old job where there is a promise to pay but intermittent pay from 8 to 1230.. got paid last Friday for two weeks there, which made a whole lot of difference when you are in an income to bills is almost even pinch, anything above normal income makes a huge difference. Otherwise I never get out of debt. Of course I'm always on the lookout on how to cut cost too, to break that income to expense ratio into something with more freedom, and part of the reason for currently having such a pinch is the promise later there'd be more freedom. Or the illusion of a promise. Anyway, the first few days at my new job I was still thinking about this stuff, microcontrollers, but mostly off my mind lately, for practical reasons. I have to sort of let my mind be blank and not wander off on the deep end and mess up at work hard. Instead I've become a farmville addict on facebook, to take me into the next year if everything goes right, and once I pick up and get all used to the job, I can start pondering things off on the deeper end again. I haven't written here for a while.. the following are gonna be just jotted down notes of what I remember thinking, without full explanation. Lack of full explanation also means you don't know something well, because you don't know something thoroughly until you can teach it or explain it to death. So I'm not learning as well as I could either. So I was gonna write that of course the factoradic is not more terse than the positional arabic/indian. For any selected base, you might as well go all the way up to the base in each placeholder and not stop halfway there, and if you're past the base, the diff notations are equivalent - hex vs binary, hex digits being a summary of 4 binary, one can go arbitrarily high on the base if ultimately it has to be hardware represented in binary, a high base is equivalent to binary. But this gets one thinking on the right path of how to find more terse ways. Terser notation, even if the mechanics are very complicated - such as mechanics of addition of positional is more complicated than tally, but still well worth it. Mechanics and sofistication are cheap, storage is expensive. Look at life - complexity and sophistication is cheap, food and energy is expensive, and even something very complex, such as a shark, might die from simple lack of food. So for numbers, we can look at how notation evolved over time - simple additive tally stick, then special symbols such as roman numerals, for multiples of tally sticks, then raising to the power positional system where the special multiple is understood in the position and extensible to infinity, the power being multiple multiples. That is, multiplication comes about from repeated addition of the same thing, 2+2+2+2+2 we call it 2x5, raising to power comes about from repeated multiplication of the same thing, 2x2x2x2x2=2^5, so the next logical step would be 2^2^2^2^2=2something5, repeated raising to the power of the same thing. It's a way to succinctly represent very large numbers. But that in itself is not enough. Just as floating point representation has many holes in it, but very succinct for very large numbers, n^n^n has holes in it, lacking granularity, and representation of each integer in between the gaps. Basically we need a representation that can do an n and n+1 easily no matter how large the numbers. The arabic/indian positional system is great, because the sum of geometric progression, for example 9x10^0+9x10^1+9x10^2+9x10^3=10^4-1, has a neat formula for the next introduced expansion in notation requiring one further symbol being the sum of all the other symbols -1, so adding the one clears all the others and expands the notation. Same with factoradic, 5!-1=4x4!+3x3!+2x2!+1x1!+0x0!. Basically all the other notation digits get reset to 0 as the new expansion symbol is introduced into the notation. Of course there are other number systems, such as the roman, which are not positional (or weakly so). In roman the symbols are just piled on, each new expansion requiring inventing a new symbol, and the notation is not terser than the positional, except for numbers very close to the invented symbol. That nonuniformity may be an advantage in certain situations. I've come across over some posts by Golovchenko, where multiplying by every single constant up to 8 is optimized.. still have to read through it, can't find the page right now. Basically if you have a number very close to say 2^2^2^2...^2, then it can be represented more tersely and possibly with fewer cpu cycles. But complexity in execution is not at stake here, if we can find a more efficient way of storing numbers in a minimum amount of space and representation, that takes precedence, but for equal storage density, of course lower complexity or fewer operations is better, even if it only happens in special cases.
So is there a full granularity integer representation between the geometric series representation, with no holes of granularity, and between the speed of n^n type representation that's too fast, and loses granularity per bit? Finding such a thing would be a nice leap forward. Even the maya had a positional system with mixed bases.

Sunday, October 18, 2009

Musings

Since the resources and space are so limited on the PIC, one always has to think of clever ways to squeeze out more from very little. For instance, on the PIC 16F84 memory, or working RAM is limited to 80 bytes. 3(for 2s/20MHz) to 6(for 1y/20MHz) of those were used up in the previous code simply to implement a delay. We needed to use 6 variables of 256, because (2*6+1)*256*256*256.. 6times=15*256^6 is what's able to execute the needed amount of instructions for 1 year. 256 is the biggest number we can represent in the PIC with a single memory location.
I was thinking perhaps there were a way to get away with less variables, to make big numbers. After all, if I'm given two bytes, d1 and d2, each able to store 256, my options are 256+256, or 256*256, or.. or.. how about 256^256.. now that's a huge number. Even 256^8 is huge. So is there a way to get aways with say d1 storing 255, and d2 say 8? What's the mechanics under the hood, can we generate the huge number of operations needed for a delay with just these two register? In C one would just make a routine,
pow(int x, int y) {int i, result=1; for(i=0;i!=y;i++) result=result*x; return result;}

Well, here is where C programmers or high level programmers think abstractly, and forget about the underlying architecture, and expect things to just work out. In practice however, first of all, this function results in overflows pretty fast, because a power such as 10000^10000 is not going to fit in an int result variable. The very reason C has datatypes is to enable efficient use of memory, and for the programmer to keep in mind the limits and the architecture at hand. VB does not require type declarations, and anything undeclared ends up as a 16 byte Variant type. Note the even the biggest long long int, on C is only 12 bytes. Still, 16 bytes is not enough for everything, because it can overflow too. Abstraction makes it possible to write code independent of the architecture and the hardware that it runs on, but eventually it does come down to having limits, PC computer hardware is not unlimited, at least not like it used to be back in the days when IBM made the decision that 1 MB should be enough memory for everyone. That decision has been laughed at ever since. Note that in the picdelay.c program below, I made a similar decision that 1 year should be enough for anyone, in view of the architecture. In the end that 1MB decision turned out to be very wrong, and since then, we learned our lessons very well, and proper new design tries to eliminate any built in limits. For instance in the old 8086 DOS PC, working memory was up to 640 KB, and above that was the video memory, and other things, up to 1MB. When practical memory limits grew to 8 MB with the 80286, the computer had to keep running circles around that video memory, and load contiguous blocks of memory from above 1MB to the block of 0-640 KB, work work work with it til it ran out of stuff to do, and then it had to take everything and move it back above 1MB, and load a new work dose from 1MB-8MB region to the 0-640KB region. In fact some device drivers loaded, such as CD ROM drivers or mouse or joystick drivers, required a few KB's of memory, and you ended up with 600KB or 586 KB or even less "conventional" memory, which was not enough for a lot of games to run, which needed at least say 604KB contiguous to function. You had the option to not run the CD ROM device driver, that could save some memory, or there were some memory optimizers like QEMM, that sought out contiguous empty space that was not used by any hardware between 640 and 1MB, and loaded CDROM drivers there. They would stay resident, but this way you could squeeze 629 KB! of working RAM, AND have a gazillion device drivers still loaded "high." Had they designed DOS without this fixed location limitation, such as the video memory address start location shown by a pointer value stored somewhere, things might have been easier to adapt as technology advanced. But once you had to adapt to the status quo, and stay compatible, it was hard to change things. One option of course is to require each computer to come with 8MB and a newer design spec says video memory now is between 7.64 to 8.00 MB. Any old program written assuming 0-1 MB design would have to be rewritten. That would be a mess.
Win32 has a flat memory model, and any program written is given a sandbox where it thinks it has access to all the memory on the computer, and Windows does the translation of what a program memory of say 0 memory location, or 1MB memory location translates to in the real computer, which might be the 12.5MB to 13.5 MB region. This way you don't have to rewrite windows programs to adapt to the new limits.
So back to 256^256 - can you implement code with only 2 registers and do this many iterations, find a cleverer way than having to use 6 registers? Would this be more elegant, maybe use even less instructions? Well, the answer is no. I actually tried. What happens is that you need a way to represent and store the intermediate numbers. In order to raise to power, you need to multiply, and in order to multiply, you need to add. In the PIC you have to add manually to multiply, and then use this multiply to raise to power, manually. Things such as 3^3 =27 or 4^4=256 fit into a register, but anything bigger doesn't. You could try to consume up the so far stored stuff before you do a next step, so before you come and multiply again, how about doing the iterations now, one by one, instead of doing them later. This does not work, because the very essence of raising to power, such as 256*(current product of previous 256*256..) = 256*123456789012=12345679012+12345689012+.. 256 times. Should you use up any of these intermediate values, you won't have the huge numbers to add up on the next turn of multiplying with 256.. basically +/- is one operation step away from * multiplication, but ^ raising to the power is 2 steps away, there is no quick and dirty method to decrement in between so you don't get an overflow while raising to power. So you can't do raising to power, unless you're willing to store huge intermediate values. You can make your own custom type, and dedicate 16 or more bytes to storing the values in it, but that negates the whole purpose of trying to save registers in the first place - use 16 registers to save 7 registers, and make the code very complicated too, similar to old 32 bit Windows on 16 bit PC architecture such as a 286 - low byte, high byte, what a mess that was. Linux was started out later, and by design it does not run on anything less than a 386, which is natively 32 bit, simply to not have to deal with low byte, high byte mess for internal calculations of memory addressing.
Basically the below delay code, using as many registers as needed and going with the 256*256*256*256... way to generate large numbers, is the most elegant and efficient way I can think of. In the mechanics, the intermediate values needing to be stored are never greater than 256, and can be decremented along the way, while the multiplication happens, so you don't need to first generate the product, then start 1 at a time from a huge number, but you can take one of them, decrement it all the way, then continue with the multiplication, and the final result of how many instructions were ultimately done, is not affected. Using registers + is not as efficient as * to create large numbers, and ^ is unimplementable without storing large intermediate values greater than 256, so it's not more elegant. Unless you can think of something I didn't think of.
By the way, while surfing around for answers on this topic, I came across the factoradic number system, which is a mixed radix number system (it's not 2 base like binary, or 10 base like decimal, or 16 base like hex, but each digit has its own base, the prior factorial up to that point. Because factorial is roughly proportional to N^N, huge numbers can be stored with few digits after a certain threshhold. The factoradic number system is basically the next step beyond arabic numeral notation - the + is tally marks fast, the arabic numeral system is developing * to its finesse with a fixed radix, and the factoradic gives a notation ^ fast. I'm not smart enough a mathematician to really analyze this, but there might be ways to implement factoradic in hardware that could give more efficient computation, at least when the number of digits stored is huge, probably well beyond 64 bit. Instead of the highest number stored being around say 2^64, one might be able to get closer to 64^64 magnitude number with accurate individual step granularity squished into 64 bits.

Made my own offline picdelay calculator

I made my offline version of www.golovchenko.org/cgi-bin/delay
that should work for up to 1 year delay on a PIC which should
be enough for ordinary people. If you don't like it, you can change
the source! There is a discrepancy on 31536000 seconds output,
and I contacted the original author.
It mostly works the same, especially on small numbers, but on one year
delay his page gets d1 as 0x4D, me, I get 0x4E.
Also, the final cycles he needs 8+4, I need 6+4.
When I do the hand calculations with his numbers, the number of inner
cycles is 157679999999977 instead of 157679999999988 that his page states.



/* picdelay.c
usage: gcc picdelay.c; ./a.out
Generates source code for delay up to 1 year on <20MHz PIC ucontrollers
Mimics output of www.golovchenko.org/cgi-bin/delay

License: Public Domain by me,
the Anonymous Author@kolomp.blogspot.com
No contact info, so I don't get bothered with spam.
Hope you enjoy it.
*/


#include <stdio.h>

int main(void) {

long double mhz, delay_s, act_delay_s;
unsigned long long int totalcycles, ncycles, dummy;
unsigned char d[8], i, nvars;
//d[8], 256^8 > 365*24*60*60 secs * 20 MHz/4 cycles, max prog limit
//needs to be changed for longer delays/faster chips

printf("Delay seconds: "); scanf ("%Lf", &delay_s);
printf("Clock MHz: "); scanf ("%Lf", &mhz);

totalcycles=1e6/4*mhz*delay_s;
act_delay_s = (long double)totalcycles/mhz*4/1e6;

ncycles=totalcycles-4-1; //to include for "call" and last goto instructions

nvars=0; dummy=1;
while(dummy<ncycles)
{ nvars++; dummy = dummy*256*(2*nvars+1)/(2*nvars-1);}
//number of repeated instruction lines 2*nvars+1
//printf("dummy=%llu\n", dummy);

for(i=nvars;i>0;i--)
{ dummy = dummy/256;
d[i]=ncycles/dummy;
ncycles = ncycles % dummy;
//if (i>1)
// printf("d%d = 0x%X\n", i, d[i]+1);
//else
// printf("d%d = 0x%X\n", i, d[i] );
}
//ncycles left over, ex. on a 7 instruction loop the remainder could be 0,1,2,3,4,5,6
//add the 1 that the last goto misses
ncycles++;
//printf("ncycles=%d", ncycles);


//printf(" Delay seconds: %Lf seconds\n", delay_s);
//printf(" Clock frequency: %Lf MHz\n", mhz);
printf("; Actual delay = %.16Lf seconds %llu cycles\n", act_delay_s, totalcycles);
printf("; Error = %.16LF % \n", (1-act_delay_s/delay_s)*100);
printf("\n");
printf(" cblock\n");
for (i=1;i<nvars+1;i++)
printf(" d%d\n",i);
printf(" endc\n");
printf("\n");
printf("Delay\n");
printf(" ;%llu cycles\n",totalcycles-4-ncycles);
printf(" movlw 0x%X\n", d[1]);
printf(" movwf d1\n");
for (i=2;i<nvars+1;i++)
{ printf(" movlw 0x%X\n", d[i]+1);
printf(" movwf d%d\n",i);
}
printf("Delay_0\n");
for (i=1;i<nvars;i++)
{ printf(" decfsz d%d, f\n",i);
printf(" goto $+2\n");
}
printf(" decfsz d%d, f\n", nvars);
printf(" goto Delay_0\n");
printf("\n");
printf(" ;%d cycles\n", ncycles);
for (;ncycles>1;ncycles=ncycles-2)
printf(" goto $+1\n");
if (ncycles>0)
printf (" nop\n");
printf("\n");
printf(" ;4 cycles (including call)\n");
printf(" retlw 0; \n");

return 0;
}