C in a uC... what were they thinking??
Re: C in a uC... what were they thinking??
It's interesting that several of us - perhaps all of us - seem to find some languages inherently more comfortable than others, and find some other languages just hit a sort of mental block.
Brad isn't alone in finding C difficult, and sark02 has good company in never having gained proficiency in Forth. And we've noted that the great majority of programmers haven't even tried assembly language. APL is interesting in that there's anecdotal evidence that it's very accessible to untrained people but very difficult for people already skilled in conventional languages.
I like the idea of a language's expressiveness, and I like the idea that if you can do a job in fewer lines of code then you'll probably on average have fewer bugs. But it's clear that some languages have more overhead than others, so on tiny machines those languages can be a poor fit.
Brad isn't alone in finding C difficult, and sark02 has good company in never having gained proficiency in Forth. And we've noted that the great majority of programmers haven't even tried assembly language. APL is interesting in that there's anecdotal evidence that it's very accessible to untrained people but very difficult for people already skilled in conventional languages.
I like the idea of a language's expressiveness, and I like the idea that if you can do a job in fewer lines of code then you'll probably on average have fewer bugs. But it's clear that some languages have more overhead than others, so on tiny machines those languages can be a poor fit.
Re: C in a uC... what were they thinking??
sark02 wrote:
resman wrote:
However, I have seen engineers get carried away with the concept of building a grand "Master Control Program" (seriously, that's what one lead engineer called it) [...]
Re: C in a uC... what were they thinking??
BigEd wrote:
I like the idea of a language's expressiveness, and I like the idea that if you can do a job in fewer lines of code then you'll probably on average have fewer bugs. But it's clear that some languages have more overhead than others, so on tiny machines those languages can be a poor fit.
Re: C in a uC... what were they thinking??
resman wrote:
sark02 wrote:
resman wrote:
However, I have seen engineers get carried away with the concept of building a grand "Master Control Program" (seriously, that's what one lead engineer called it) [...]
Doh!
Re: C in a uC... what were they thinking??
> helloworld in Go is 1.6MByte
That does seem large, but it cannot possibly be active code - must be libraries or methods brought in.
(A bit of info at https://blog.golang.org/go1.7-binary-size)
I'm a bit of a fan-at-a-distance of Go, but I can't say I've done anything with it. It has its flaws, and its detractors, but it has good aims and good ideas. And of the order of half a million users, apparently.
That does seem large, but it cannot possibly be active code - must be libraries or methods brought in.
(A bit of info at https://blog.golang.org/go1.7-binary-size)
I'm a bit of a fan-at-a-distance of Go, but I can't say I've done anything with it. It has its flaws, and its detractors, but it has good aims and good ideas. And of the order of half a million users, apparently.
Re: C in a uC... what were they thinking??
BigEd wrote:
> helloworld in Go is 1.6MByte
That does seem large, but it cannot possibly be active code - must be libraries or methods brought in.
That does seem large, but it cannot possibly be active code - must be libraries or methods brought in.
- commodorejohn
- Posts: 299
- Joined: 21 Jan 2016
- Location: Placerville, CA
- Contact:
Re: C in a uC... what were they thinking??
The first time you see a 1.6MB hello-world, it shouldn't give you pause.
It should send you running screaming for the hills.
It should send you running screaming for the hills.
Re: C in a uC... what were they thinking??
Expectations! I think it's all part of understanding how things work. If something surprises you, there's something going on you didn't expect. So, have a look, see what it is.
The point of a compiler is to make an executable which does what the source describes - a compiler which can swallow a million lines of code and burp out a working executable quickly isn't necessarily making the smallest possible executable, and isn't necessarily broken if it makes quite a large executable when fed a trivial source. The size of that executable doesn't necessarily bear much relation to the number of instructions it will execute or the amount of memory it will occupy - which is what really matters, in everyday computing environments.
The point of a compiler is to make an executable which does what the source describes - a compiler which can swallow a million lines of code and burp out a working executable quickly isn't necessarily making the smallest possible executable, and isn't necessarily broken if it makes quite a large executable when fed a trivial source. The size of that executable doesn't necessarily bear much relation to the number of instructions it will execute or the amount of memory it will occupy - which is what really matters, in everyday computing environments.
- BigDumbDinosaur
- Posts: 9428
- Joined: 28 May 2009
- Location: Midwestern USA (JB Pritzker’s dystopia)
- Contact:
Re: C in a uC... what were they thinking??
Elminster wrote:
Reasons for not using asm is it is I won't remember how it works in a year...
Quote:
I think in the 6502 world people just used to asm and forget outside most people don't know asm.
x86? We ain't got no x86. We don't NEED no stinking x86!
Re: C in a uC... what were they thinking??
BigDumbDinosaur wrote:
Elminster wrote:
Reasons for not using asm is it is I won't remember how it works in a year...
Edit: i.e. Comparing Fully commented version of C vs fully commented version of ASM to non regular ASM programmers. Looks like magic.
Re: C in a uC... what were they thinking??
I've no problem understanding my minicomputer assembly programs / libraries that I wrote in the early eighties.. even though I hadn't looked at them for decades.
I remember sitting down and writing some assembly routines now and then, to get my energy back.. it was very relaxing.
I remember sitting down and writing some assembly routines now and then, to get my energy back.. it was very relaxing.
Re: C in a uC... what were they thinking??
Tor wrote:
I've no problem understanding my minicomputer assembly programs / libraries that I wrote in the early eighties.. even though I hadn't looked at them for decades.
I remember sitting down and writing some assembly routines now and then, to get my energy back.. it was very relaxing.
I remember sitting down and writing some assembly routines now and then, to get my energy back.. it was very relaxing.
Re: C in a uC... what were they thinking??
It really depends on the project at hand.
I've been programming 6502 assembly much longer than C (or Java which is my day job).
However, I also built a AY-3-8910 music player for an Arduino using the PRE-BUILT SD libraries and the PRE-BUILT serial libraries, etc. I wrote the entire project in C very quickly. Worked great. Assembly would have provided no additional benefit for THAT project. In fact, it would have taken MUCH longer because I needed various interfaces that I would have had to write myself. I don't fancy re-inventing the wheel very often.
I've been programming 6502 assembly much longer than C (or Java which is my day job).
However, I also built a AY-3-8910 music player for an Arduino using the PRE-BUILT SD libraries and the PRE-BUILT serial libraries, etc. I wrote the entire project in C very quickly. Worked great. Assembly would have provided no additional benefit for THAT project. In fact, it would have taken MUCH longer because I needed various interfaces that I would have had to write myself. I don't fancy re-inventing the wheel very often.
Cat; the other white meat.
Re: C in a uC... what were they thinking??
I think the problem with commenting assembly language is the thought that every line should have a comment. When doing it that way the programmer tends to fall into the trap of writing a comment that is a redundant statement of the instruction.
As an example: LDX #5 ; put 5 into X
Comments of context are usually more useful.
Many like to put all their assignments at the top of the program to be in a location for common referencing but often mixing an assignment locally, especially if it is only used in that location makes more readable code. I believe more readable code is better that comments:
Grapes equ 5
...
LDX #Grapes
As an example of good naming in the right context.
Always, a statement of what you'll be doing is important for any stretch of code.
Now if only I could convince my self, while writing code, to use the good commenting practices I preach.
Dwight
As an example: LDX #5 ; put 5 into X
Comments of context are usually more useful.
Many like to put all their assignments at the top of the program to be in a location for common referencing but often mixing an assignment locally, especially if it is only used in that location makes more readable code. I believe more readable code is better that comments:
Grapes equ 5
...
LDX #Grapes
As an example of good naming in the right context.
Always, a statement of what you'll be doing is important for any stretch of code.
Now if only I could convince my self, while writing code, to use the good commenting practices I preach.
Dwight
- BigDumbDinosaur
- Posts: 9428
- Joined: 28 May 2009
- Location: Midwestern USA (JB Pritzker’s dystopia)
- Contact:
Re: C in a uC... what were they thinking??
dwight wrote:
I think the problem with commenting assembly language is the thought that every line should have a comment. When doing it that way the programmer tends to fall into the trap of writing a comment that is a redundant statement of the instruction.
Code: Select all
;DUART TRANSMITTER IRQ PROCESSING
;
iirq0300 lda #n_nxpch-1 ;starting channel
;
;
; channel processing loop...
;
.0000010 pha ;save channel index
asl a ;channel pointer offset
tax
lda (tiaisr,x) ;get IRQ status
bit nxptqtab,x ;TxD interrupting?
beq .0000040 ;no, skip this channel
;
;
; FIFO processing loop...
;
.0000020 lda tiagettx,x ;CFIFO 'get' pointer
cmp tiaputtx,x ;CFIFO 'put' pointer
beq .0000030 ;nothing to transmit
;
lda (tiasr,x) ;get channel status
bit #nxptxdr ;TFIFO full?
beq .0000040 ;yes, done for now
;
lda (tiagettx,x) ;read CFIFO &...
sta (tiafif,x) ;write to TFIFO
inc tiagettx,x ;bump 'get' pointer &...
bra .0000020 ;loop
;
; ...end of FIFO processing loop
;
.0000030 lda #nxpcrtxd ;disable...
sta (tiacr,x) ;TxD
lda tiatstab,x ;tell foreground...
tsb tiatxst ;about it
;
.0000040 pla ;get channel index
dec a ;all channels serviced?
bpl .0000010 ;no
;
; ...end of channel processing loopx86? We ain't got no x86. We don't NEED no stinking x86!