GPIO Module and the old SWI's
Pages: 1 2
Tank (53) 375 posts |
If anyone is interested, I have started to add some of the old GPIO SWI’s that are not in the new official module to a new one. |
Steve Pampling (1551) 8170 posts |
Perhaps that should be submitted as an update to the ROOL source? |
Andrew Conroy (370) 740 posts |
That’s great, thanks! Simple things like “GPIO_FlashOn” were nice to have, and saved you messing about coding it yourself. Also the ability to read/write a word at a time was also useful! It will be nice to see the extra features that ROOL removed when they gutted the module being replaced in the extension module. |
Tank (53) 375 posts |
Perhaps that should be submitted as an update to the ROOL source? The new module is in “C”, and I cannot get my head around that. All my work is in assembler…. |
Steve Pampling (1551) 8170 posts |
Ah, not just me then. 1 Sometimes, on a good day etc. |
Clive Semmens (2335) 3276 posts |
Indeed not. |
Rick Murray (539) 13840 posts |
C, and how it does things, is quite different to BASIC. It took me time before I got my head around it. Before, it was incomprehensible gibberish. |
David J. Ruck (33) 1635 posts |
Don’t think of C as an alternative to BASIC, think of it as an assembler with more register names. |
Julie Stamp (8365) 474 posts |
I get frustrated if I’m I trying to just reach into some block of data and change something, I have to spend too long getting the types to work out. |
Clive Semmens (2335) 3276 posts |
I don’t think of C as as alternative to BASIC. Nor do I think of it as an alternative to Fortran, nor COBOL, nor PDP8 Assembler, nor PASCAL, nor 6502 Assembler, nor any of the other languages I know (or knew, now so rusty I wouldn’t say I really know them any longer). ARM once paid for me to spend three days on a C++ course, which was pathetically easy to get 100% marks in; but C is still a rat’s nest. Where is this, that or the other actually defined? Bloody mess, I don’t need it fortunately. Okay, sorry, there are a few things I can’t help with, but at my age, I don’t care any longer. |
Rick Murray (539) 13840 posts |
Why not? One’s a programming language, the other’s a programming language…?
It’s all about objects and inheritance. But when it comes to actually writing C++ is when you understand the horrific abuse of the poor colon and asterisk.
That’s one of the reasons I absolutely do NOT use the shared makefiles. It’s enough to track down definitions of stuff in larger products when you know what is being included. Trying that when “the whole world” is automagically added is a nightmare. Something sorely missing from the preprocessor is a command like #where that will remember a name of something and output messages where it is defined and where it is used.
Happiness is knowing that, and equally not caring, when you’re younger. ;-) |
Clive Semmens (2335) 3276 posts |
I don’t think of a Big Mac as an alternative to caviar, either. They’re both food (allegedly).
That would help, but having a map of a tangle is still a poor alternative to not having a tangle in the first place.
There’s the twin cruces of this matter in a nutshell. |
Steve Pampling (1551) 8170 posts |
So the idea of doing a verbose and searching the 15 million lines of verbosity won’t work then?
I can’t dance1, and I knew that as part of a junior school list, but I didn’t care then or now. Various stuff I can do that others struggle with, or fail. Suits me.
Indeed, but with or without the cash2 makes no difference if I don’t have a personal interest. 1 Not a Genesis reference. 2 Maybe I’ve not been offered enough. Past offerings were never more than about 1/20th of my salary – which interestingly is now a tad over 10x my start salary. |
Rick Murray (539) 13840 posts |
I think that depends upon context. Certainly one doesn’t usually get a choice between burger or caviar. However, this one time So we went there and I probably saved her a fortune. ;-) I’ve never eaten posh and/or designer food. I don’t consider food to be works of art. It’s a functional form of nourishment. That doesn’t mean it shouldn’t be appetising, of course… So, it’s not quite a burger vs caviar, but it’s probably about as close as we’re going to get in any reasonable discussion as people who eat burgers and people who eat caviar don’t tend to interact much. Well, McDo hasn’t yet launched the McPoshAssTory burger. Yet.
I think the problem arises because BASIC is a language with keywords, where the closest you get to modular coding is to include a LIBRARY or two; though it seems most programs I’ve seen just stick the library at the end – it can be munged better that way, especially if everything shares the same non-LOCAL namespace. C, by contrast, has very few keywords. There are keywords to define variable types, to make comparisons, to do loops, and to define/exit functions and… I think that’s about it. [including other stuff is a preprocessor command, it isn’t strictly C] Everything else in C is a function in a library somewhere. All those things that exist in BASIC don’t exist in C until you pull in the appropriate library. Even such things as string handling. The most you’ll get out of pure C is an array of bytes. For printf() you need the standard library, and for working with strings (equivalent to LEN, INSTR, etc) you need the string library. It’s all part of SharedCLibrary, but different bits need to be added to the source so the compiler can find all the things it needs. I use DeskLib. Some use OSLib. Others use Toolbox. Nobody who wishes to remain sane uses RISC_OSLib. Some of us might want to use the TCP/IP libraries. People who have been coding a while probably also have their own little library of “that damn thing I’ve written for the umpteenth time”. The price we pay for this flexibility is that compiling something just a touch larger than “hello
About as useful as writing a little program to xxFS_SectorOp to read each sector in turn looking for the variable, to then try to work backwards from a disc address to a filename. There’s a way to find something, and that ain’t it. Ditto searching ridiculous verbosity… If the Norcroft compiler even supports that level of gibberish making.
While there’s always a need to have an interest, I think the anticipated level of interest would depend upon the amount of coin. Things that one might have thought “sod that” might be more “I guess I could take a look” with a suitable dangling carrot. 1 The company decided they didn’t want to pay for the monthly updates to their software at £80 a pop (I think it was 80, might have been 180 but that sounds a little high for a small company to bear) because while they were getting a disc in the post every month, they noticed that the version number was the same so what were they paying for? After one month the software popped up a nag when it was started, and after two months it simply erased itself and it’s data files. Thankfully the woman was clued up enough to UNDELETE all the files (though she mostly said the first character of each filename was ‘a’ because they all had gibberish names). So my job was to look in the files and compare what I saw there with her notebook that contained some client details. Took a while, but once I twigged that everything was EORed twice (with different values), it became a matter of looking for sequences and then writing a bit of TurboPascal code to walk the file building a CSV file. The weak link were the phone numbers. When most of them begin 01252, it makes a regular-ish five byte sequence. |
Steve Pampling (1551) 8170 posts |
I ate a Muckburger once. I don’t believe I will repeat the experience.
I may be different (OK, weird then) but I will do without things rather than make the effort when I’m not interested and the doing without includes not collecting cash. I have put silly high costs on things I don’t really want to do though – it’s easier than saying no to some people.
Ah, that was the way I ‘cracked’ the crappy encoding of the passwords in a door access system. Repeated portions of the “encrypted” content. |
Dave Higton (1515) 3526 posts |
I was 40 years old when I learned C. I thought it was an awful language at first. But I persevered. I’m still not a great C programmer, and I can’t claim that I am entirely happy with the language. But it does have huge advantages: it’s widely implemented, it’s portable, and it’ll do very nearly everything that you need. It’s rare to need to descend into assembly language. The advent of 64-bit ARM processors, and the likelihood of very few more 32-bit ones that would be any good to us, is perhaps the most forceful reminder of a huge disadvantage of assembly language: it’s not portable. I know well one of the downsides of the shotgun approach to files (sorry, that’s modularity!) – there is often no obvious choice of where to define something. When I’m working on a project in C (as I am at the moment), I have Textseek on the icon bar. That’ll help find, very rapidly, where something is. I really recommend to those who like assembly language and don’t like (or think they can’t cope with) C: persevere. It’s not nearly as bad as all that. Learning C to an adequate level will help you write more maintainable code: code with a longer lifespan. |
Frank de Bruijn (160) 228 posts |
Yes it is. It’s worse. It has some absolutely retarded features. Like the one mentioned above: making a fuss about redefining something WITH THE SAME VALUE. I mean, who tf cares if it’s the same value? And if you do, then TELL ME where it’s defined first! I gave up on my last attempt. I checked all files, plain sources and libraries. The original definition was nowhere to be found. And after the last updates even the assembler produces an error if you define something more than once. |
Clive Semmens (2335) 3276 posts |
That’s the whole issue. C is very simple, but the libraries? Um. There’s the tangle. If I want to create my own stuff, fine, I find the libraries I like and that’s like putting my own language together. Then anyone else is going to find that as weird and incomprehensible as I find everyone else’s C programs.
Well certainly assembly language is tied to CPUs that have a particular instruction set, or a superset of it. But C is as impenetrable as assembly code, only worse, because of that library issue. It’s the lingua franca, no-one can deny that, but to pretend it’s anything better than an atrocious mess is just that: a pretence.
I was 48 when I started work at ARM. I’d done some ARM assembler work and a lot of BBC BASIC work knocking up helper apps to get Impression to do what I needed to publish The Journal of Physiology and a few smaller physiology publications; but apart from that I’d been out of programming since the 1970s, when I did various COBOL and IBM3790 contracts (I’d used Fortan and PDP8 assembler as a nuclear engineering student in the late 1960s). ARM sent me on that C++ course, which was, as I said, pathetically easy – C and C++ are pathetically easy – but the libraries aren’t, and C without the libraries is pathetically useless. And since I was, among the technical authors, in demand as Mr Assembly Language, I never really got to use that C++ (or C). I was 57 when I retired from ARM. I’m now 70, and I don’t think I’m about to tackle C. |
Steve Pampling (1551) 8170 posts |
Oh, I haven’t given up – it’s something I’m interested in. 1 25 years ago, and single, I would start on something in the evening, have breakfast and go to work. 2 The wife scans net articles and various eye problems including macular degeneration have been found to be triggered by Covid. |
Rick Murray (539) 13840 posts |
Generally it’s a mixture of the standard libraries (for the basics) and whatever custom libraries are wanted.
You know, ObjAsm isn’t much different. The RISC OS source code is a brilliant example of the fact that one can make a delightful mess in any language that supports modularity. Can you tell me where “MetroGnome” is defined? Or, here’s one for you. The OS can automatically load and set up an environment for an Absolute (&FF8) program, including in our version messing with the WimpSlot if the program is larger than the current slot size (a very useful addition!). Can you tell me in which of the many bits of the Kernel this is actually done? 1 Oh, and you’ll notice various extra instructions like SetV or Enter, What are these and where are they defined? I’m not expecting you to actually answer. Just highlighting that the mess that C makes with stuff scattered all over the place is really not so different to the mess one can make in assembler with stuff scattered all over the place.
Several of my assembler programs include definitions (in a separate header file) for the EQUx versions of defining things, because I could never remember which bit of punctuation ObjAsm uses for bytes, words, and strings. I’m used to EQUB, EQUD, and EQUS from BASIC. Along the way I added EQUSZ and EQUSZA (terminull, and terminull/align). I thing something also has EQUSB (CR terminated), but that doesn’t get used much outside of BASIC. Somebody reading that might have to think a little harder if they’re used to & and * and = (or whatever it is – I still can’t remember…).
Oh, for so many reasons it is a god-awful mess. A language that is happy with stuff like: However, C is a very popular language because it worked. It gives you the flexibility (and also the responsibility) to choose the most appropriate variable type for a job; noting that the definitions may very from machine to machine (an ‘int’ is 16 bit in the DOS world, and 32 bit in Windows, RISC OS, etc) because it is implicity related to the underlying machine. Not only that, but you can specify whether a number is signed or unsigned. BASIC, for instance, does not give you this choice. &FFFFFFFF and -1 are the same thing. But more than all of that, C is very simple. Not from a learning point of view, but from a language point of view. It can be implemented without much in the way of overheads. You can write programs to run on PICs in C. The Minitel demo (burned into a small ROM to run on a woefully underspecified 8051 device) is written in C. There is even, I believe, a C compiler for the Beeb. There is no reliance on a pile of frameworks and support libraries. Individual programs may require that (look at all the baggage that Otter comes with), but the language itself does not. Funny thing is, if you look around, you’ll see C all over the place. Would you rather code in Lua? Well, Lua itself is written in C (lightweight, portable, and powerful enough to get stuff done). Original (Matz) Ruby is written in C. There’s a Java version and while today’s Java compiler is written in Java, the underlying JRE is in C. PHP is written in C. So, really, you can use some trendy modern language or you can just cut out the middleman and write stuff in C. ;-)
Oh, yes. That’s why I keep saying “it’s not BASIC”. If one comes at it like it’s sort of like BASIC only weird, they’ll run into roadblocks every time they encounter things that really don’t work like BASIC. Just minor things, really…
Yeah. Pulling all nighters was no big deal to the 20-something Rick. The over-the-hill-Rick is looking at the clock and thinking he’d better type fast or he’ll conk out before this message gets sent.
Eighty minutes later? You should tell her to nudge you eight minutes later!
Like I said to you earlier, the more I read about it, the more it seems to screw with the body in all sorts of horrible and unexpected ways. Psychiatric issues, macular degeneration, exploding hearts… WTF? It’s supposed to be a lung virus. You know, SARS, as in respiratory. Not a “let’s toss a spanner into the cogs and see what breaks” virus! 1 Trick question, it’s in FileSwitch. 2 While the world has standardised on a sequence of bytes (not containing a zero byte) terminated by a zero byte; there’s actually nothing (other than the sheer pointlessness of it) stopping you rewriting all of the string handling routines to define a string as a sequence of characters terminated by &FF. Or maybe a sequence of words there each value is a character code. Or the string backwards, or whatever you feel should represent strings. You can do this because in C it’s just an array of bytes that some library functions make sense of. |
Steve Pampling (1551) 8170 posts |
Ah, well that was a first, and probably only, overrun: Today her laptop sounded a “factory hooter” as a little clue to stop. |
Clive Semmens (2335) 3276 posts |
For sure. You can even make a horrible tangle in BASIC if you want to (or don’t bother to avoid it – whistles innocently). The difference is that with C it’s unavoidable. |
Steve Pampling (1551) 8170 posts |
I think most of the WRT Rick’s comment about those other languages actually being written in C, do the users care? 1 While at Uni I had a session with spaghetti code on a printout that ran the length of the residence corridor 3 times. I walked up and down reading, with a home brew3 in hand (replaced at intervals) and re-wrote the offending article with a fine tip marker pen. The restructured code actually worked4, which the original did not and, because of the restructure, modifications to specific elements were far easier. I maintain that my mind needs “lubrication”5 2 Some might say “concoctions” or even “abortions” 3 It couldn’t have been beer, we weren’t allowed to do that – as the warden of the residence pointed out every brew day when he popped in for a chat. 4 My friend got an offer for a well paid job on the basis of that. He does something different now. I’m not sure he enjoyed the programming work they had him doing. 5 What we brewed definitely went beyond lubrication and tasted good too. All that before I and also my friend ever heard of CAMRA. |
Clive Semmens (2335) 3276 posts |
…either…or? No, I wouldn’t try to write a DTP app in BASIC. The fact is, I wouldn’t try to write a DTP app at all, nor even a vector drawing app. Impression and !Draw exist. All I ever wrote in BASIC (with sometimes a bit of assembler for heavily-used bits) was “helper” apps, mostly to fill in a few of the gaps in the capabilities of Impression or !Draw. Messy programs? Yes, fairly – ranging from “very” to “a bit.” Not spaghetti though, never that; very much broken up into functions and procedures. Never intended for anyone else to maintain, and so far I’ve not found them too hard to maintain/update/extend on the rare occasions I’ve felt the need. Being well up the autism spectrum (undiagnosed but pretty obvious) helps a lot with that. |
Steve Fryatt (216) 2105 posts |
Except that it isn’t, of course. |
Pages: 1 2