Showing posts with label assembler. Show all posts
Showing posts with label assembler. Show all posts

20160823

People who love their lives do differently


Irish cows (I suppose)

Two things from a web site entitled "10 Things That The People Who Love Their Lives Are Doing Differently":

 - They do things because they want to do them, not because they believe they have to do them.

 - They don’t bother changing others, but instead learn how to deal with them appropriately.

Differently? For me I think not, and neither were any of the other eight any surprise. And yet I still find myself often dancing to another tune. But who is the piper?

Is it when I don my Christian hat? Not that I ever take it off - I just think about taking it off. A bit like Kipling's Muslim Mahbub Ali 'So says my Law--or I think it does'. I wonder what God wants of me and to what extent I should "be faithful" to those I fellowship with. Hmm. Like what would Jesus do? Not that I would ever wear one of those bracelets. I abhor anything unnecessary being attached to my body. And, no, I do not have a wedding ring - I don't even wear a watch unless it is the GPS variety and then only for a short period. So does that make me a hedonist? Or an ascetic?

Christians are often accused of thinking it is somehow wrong to enjoy oneself. Something to feel guilty about.  This quote from Chelsea Handler, who doesn't come across as a God seeker herself, sums up the absurdity nicely: "I think only hedonists believe in God, in the same way that I think only hedonists have babies."

Then there is the Buddhist's "middle way" a path of moderation, between the extremes of sensual indulgence and self-mortification which sounds to me a bit like a cop out.

My drainage canal on the lake shore

Joining the ponds to the lake proper

So is it wrong to make canals in the sand at my age? Or to run barefoot imagining I am a locomotive following a well graded permanent way along the lake shore, carefully choosing places to cross gorges and chasms hundreds of millimetres deep carved out over the eons by surface run-off. Or messing in mud. Or taking random photos of cows whilst I am on a run. Or posing for ridiculous shadow selfies. All on my own. Or, on a slightly more serious note, randomly improvising on the piano, or humming a favourite tune in parts. Combining colour filters in a search for the ultimate hue. Maintaining a blog that few read. Or, as the song goes, climbing mountains or jumping in a lake. Enjoying a Cherry Bakewell. Is it not possible to praise my Maker in such things? Rather than being restricted by accepted evangelical/charismatic liturgy and the paraphernalia that goes with it?


A random stock photo - not me, but it might have been

Looks like it runs in the family...

And this is me - yet again!

We non-conformists watch Catholic or high-church antics with mingled horror and disbelief, and yet how much of what we do is likewise mumbo-jumbo to the average agnostic? Lord save me from doing things just because some implied rule book tells me I should. But on the other hand Lord save me from only ever doing things just because I want to. There has to be a better reason, like "hath God said?". But I wonder just how much He does say and then, in the absence of such direction or other constraints like "love thy neighbour as thyself", why not enjoy life: abounding as well as sometimes being abased?

Here's another thing. I'm not good with words. Hence this blog as being just possibly a better way for me to communicate. Typically I will re-read and make changes to a longer post like this one many time and over many days, a degree of freedom one does no have with speech. And besides, when speaking, especially in public, I often fail to get across the very point I set out to make. In an argument the other person can easily walk all over me. When I was very young I was given speech therapy and they said I was lazy. With worship songs that we sing, I know the music but often cannot recall the exact words. I do not believe I have ever written poetry and am probably incapable of it. It is not that words have no meaning for me - I marvel when I read a book that is (IMHO) well written and I have even been known (though rarely) to appreciate poetry. I am a slower than average reader and am intimidated by small print or excess or flowery description. What interests me in a book or a film is believable fantasy, portrayal of character, the set, and music - more than plot - and if I identify then I long to know what happens to the protagonist (or the actor) afterwards.

I prefer emails to telephone calls. I will do almost anything to avoid the latter. With an email there is at least the chance to make changes before pressing the button. But I know folk who are quite the reverse and sometimes we don't meet.

Why am I saying this? Because the liturgy and paraphernalia I mentioned above is so bound up in words and, where does that leave those of us who struggle with speaking? - I have noticed how such people easily get side-lined. Because so much value is placed on words.

My work involves programming. Writing assembler for a RISC processor is great - there are only about 50 instructions to remember: I can memorise that many and then I am in total control. Assembler is simple and deterministic. An op-code such as "incf 23" increments the value in memory address 23 and takes exactly one machine cycle to execute. At the other end of the extreme a language like C# is very verbose and maybe few programmers know all the vocabulary it offers. C# is very clever and, given such knowledge, enables you to do very smart things with just a few lines of code, but don't expect a known result in a known amount of time! I am not comfortable with programming in C# because I can't remember all those words and thus feel out of control.

Granted that the Gospels are more about Jesus but you'd think they or maybe Paul's epistles would mention his disciples - but for most of them there is little or no record of what they said or did. Simon Peter is of course the exception. And yet I suppose the rest of them were chosen for a reason. Take Matthew - we suppose he wrote the gospel bearing his name and yet there is no record of what he did or said in the whole of the NT apart from the fact that he was a tax collector and followed Jesus immediately when called.

One other disciple in particular comes to mind. Dear Thomas, pragmatist to the end. I say "dear", of course, because I identify with him.

In the four very obviously ordered lists of apostles (Matthew, Mark, Luke and Acts) he comes half way - neither most nor least noteable. His three other mentions are all in the gospel of John.

Dean Jones in John on Patmos

In chapter 11 he makes a possibly snide remark which Adam Clarke comments well on. In chapter 14, whilst Jesus is explaining spiritual truths in somewhat mysterious language, he interjects "we haven't a clue what you're talking about so how can be possibly know the way?" And finally, post resurrection, we have Jesus appearing to and showing his hands and side to the disciples, but Thomas happens not to be there. On catching up afterwards he remarks indignantly "Unless I see in his hands the marks of the nails and place my fingers into his side, I will never believe" which Dean Jones impersonates rather well in his John on Patmos. Dear Thomas. I hope I would have done the same, for I'd certainly have thought it. Maybe the more "spiritual" among us might despise him (and me) for lack of faith - such folk might consider themselves spiritual but I think they do not understand the word.

Eight days later, Jesus (though the doors were locked) enters and announces himself with "Peace be with you" and in the very next breath, wonder of wonders and never mind the other disciples there, he says to Thomas "Put your finger here, and see my hands; and put out your hand, and place it in my side." No ticking off, no putting down, he meets Thomas just where he is and supplies just what he needs to evoke his response "My Lord and my God!"

Martyrdom of St. Thomas, by Peter Paul Rubens

Wanting, as always, to know what happened to the protagonist, I did a bit of research and found that there is good reason to believe that Thomas later traveled to India where he preached the gospel and was martyred. Less certain is the tradition that he was killed by a sword being thrust into his side.

In this short life that we live there is a whole lot more than talking.

20160325

If you don't see sharp you'll be flat



Visual C# is a strongly typed, object orientated and managed programming language. As opposed to the computer's native computer assembler which is not typed, orientated or managed at all.

If I've lost you already, it's likely to only get worse so, if I were you, I'd go find something else to do.

The point I am making is that IMHO the education of all serious programmers ought to start with assembler before moving on to a high level languages like C#. Because otherwise they will inevitably fall into the traps of unnecessary obfuscation, abstraction, bloating, redundancy, and other such anti-Occam's Razor-isms that force the rest of us to buy ever increasingly complex computers.  The young people of today won't believe you when you recall surprisingly complex software that used to run within the MSDOS memory limit of 640Kbyte. Not that complexity is bad per se - nature is full of it!

"Managed" means the language depends on, in this case, the gargantuan Microsoft .NET framework and cannot run without it. Which means the programmer does not have full control of the machine and the very simplest program still needs all that framework code.

The objects in "Object orientated" are packages of code that are called by the main program rather like subroutines of assembler-speak but with many more bells and whistles which are nice but only when needed. C# forces the programmer to use objects even when something less heavy would be more efficient all in the interests of readability and self documentation.

"Strongly typed" means that every quantity is forced to be of a specified type. Like when Mickey Mouse is doing his homework and asks "what is 3 + 4?" and Pluto replies "Is it apples or bananas?"

The computer itself only knows about "bits" aka binary digits that are either "on" or "off".  Groups of these can represent either instructions or data according to context. The computer doesn't care if the data describes apples or bananas. That's the programmer's job. Just as it is the mathematicians job to decide how to use an algebraic symbol or the what to use the digits 0 to 9 for. So when C# insists that a symbol must describe e.g. apples, that distinction is purely in the mind of the compiler (the software that converts a high level language like C# into assembler).

Which is all fine and dandy until it gets out of hand.  Like when the QuickBooks SDK interface which I have been working with requires me to use their programmer's name for a value that, to the computer, is just an integer and woe betide if I spell or capitalise it wrongly.

This morning I read a news article reporting how, when a certain Jennifer Null tries to buy a plane ticket, she gets an error message on most websites. This is a prize example of the point I am making. There is no reason why a programming language should not define a special value to mean that a variable or database field has not yet been assigned, but to confuse a string of characters "Null" with that value is unforgivable.

I came across a new word recently that describes this nonsense nicely: cruft = badly designed, unnecessarily complicated, or unwanted code or software.

20131226

F8 bug or how I hate I2C bus

I have been revisiting assembler code I wrote maybe 10 years ago because of a software bug.  The device announces the problem by displaying a message "ERROR CODE F8" which, being translated into the vernacular, means that when my Microchip 8-bit microprocessor accesses external serial EEPROM via I2C bus the bus gets into a can't-get-out-of-it situation. That the serial memory devices should suffer such ignominy is my case against I2C.  SPI bus is simpler and is my preferred choice.

It turned out I was trying to access a memory address that did not exist and, after many days of searching, it turned out that this was because I had initialised said memory (pointers and wotnot) after my first attempt to access it. The solution - move the call to the initialise code back before the first access. Simple - once I had identified the problem.

It took me so long to identify because I had very poor debug tools.  I had very poor debug tools because I hadn't previously made any those 10 years back when my teeth were shorter, and in this recent spate of work I thought I could do it without the necessary tools. This morning I decided that was bad thinking. I made a terminal routine that would dump salient registers to a display screen and hey presto I was able to locate the bug. The most helpful part of my debug tool was the display of stack pointer and return addresses on the stack from which I was able to figure what part of the code caused the error display.

Which adds weight against the inference in the absurd proverb "a bad workman blames his tools". It should read something more like "a bad workman has bad tools".

A similar principle applies when routing cables through or driving screws or hammering nails in awkward positions. If you cannot see what you are doing, chances are you will mess up: the screw will drop into a void, you will instead hit the nail on your finger, or the cable being poked will just refuse to exit where you want. But once you can see what you are up against it is oh so much easier!  For this reason I keep a stock of small flash-lights and mirrors.

There could be a moral here somewhere...

20130410

Occam's razor


Eric Isaacson programmer par excellence

Occam's razor in the vernacular might be "Keep It Simple Stupid!".  William of Ockham was a 14th century logician and Franciscan friar. He wrote in latin but, roughly translated, Wikipedia has it as a principle of parsimony, economy, or succinctness used in logic and problem-solving.

I try to apply the principle in my work as an electronics design engineer. I often use Microchip PIC processors in my designs, mostly 8-bitters, and typically code in assembler. Recently I have tried my hand at 'C' (just the ANSI flavour) - apparently it is the "way to go" and, anyway, one's hand is forced by the need to use C-friendly libraries.  But I hate the verbosity and obfuscation of 'C'. What requires little thought and a few simple statements in assembler can consume hours of research and require far more typing in 'C'. In short it contravenes Occam's razor.

OK - I like the way 'C' encourages good structure and offers ready made functions to save one having to re-invent the wheel. But couldn't these good things have been provided in a simpler, more intuitive way? So I figured I would create a new language and call it 'Occam' - but I am too late - Occam already exists but is not at all the 8-bit job I was looking for.

'C' poses itself between low level (i.e. assembler) and high level languages. It's not that I have anything against high level languages - they have their place - just that I hate unnecessary verbosity, and not only in the field of programming.

Long ago in the heyday of MSDOS I purchased and used A86, an assembler for the PC. The author Eric rightly claims that A86 "is the finest assembler available, at any cost under any terms, for the Intel 86-family of microprocessors". No painful setup red-tape is required - you write your assembly statements, assemble and, hey presto you have an executable.  That's as good an example of Occam's razor as you'll get.


Shalom is often translated as 'peace' but means much more - well-being, completeness, wholeness, health, soundness, tranquility, prosperity, fullness, rest, harmony, the absence of agitation or discord. How is 'shalom' encoded in brain neuron-patterns?  Similarly, a high level programming language command like "draw a 3D cube with rendering" – who cares how it is encoded? Except that you do care at the hardware level I work at. I care about every bit and every micro-second and, for some applications, only assembler will fit the bill.