Programming for Electronics Engineers

In article <csjkg1$bev$3@blue.rahul.net>, kensmith@green.rahul.net
says...
In article <lgjqu05i2em2pd9fujpu9t81l2rmrshbov@4ax.com>,
John Larkin <jjlarkin@highSNIPlandTHIStechPLEASEnology.com> wrote:
[...]

The PDP-8 had a conditional skip. I suppose it was a RISC machine,

That was the only type of conditional it had.

since it wasn't microcoded and did everything in one clock.

This is not true. The master clock was divided down to make a sequence of
timing pulses. The PDP-8S (I think it was) took something like 24 clock
cycles per instruction becasue some of its workings were serial in nature.
IIRC the PDP-8E had a serial ALU, so single-cycle ops would be a rather
rather difficult design point.

--
Keith
 
On Tue, 18 Jan 2005 19:36:33 +0000 (UTC), "Reg Edwards"
<g4fgq.regp@ZZZbtinternet.com> wrote:

GOTO's are a positive menace. Any language which allows them is a disgrace
to mankind's considerable acheivements in that direction.

They constitute abandonment of essential discipline to complete chaos in
program structure. Helpful only to lazy, soltitary, so-called programmers,
obtaining money under false pretences, who are unable to remember what its
all about the next day. But GOTO's are wicked, useless, obstructions to
bug-finding and maintenance operations carried out by poor unfortunate later
workers who get all the blame for the enormous costs involved.

Oops, I guess I scooped up about $40 million under dishonorable
conditions. I should give it all back, I suppose.

John
 
On Tue, 18 Jan 2005 19:36:33 +0000 (UTC), "Reg Edwards"
<g4fgq.regp@ZZZbtinternet.com> wrote:

GOTO's are a positive menace. Any language which allows them is a disgrace
to mankind's considerable acheivements in that direction.
---
Assembler with no labels? What a concept!

--
John Fields
 
In article <MPG.1c571fd39a625af398986f@news.individual.net>,
Keith Williams <krw@att.bizzzz> wrote:
In article <csjekk$7s9$1@blue.rahul.net>, kensmith@green.rahul.net
No-one has mensioned IDL, so I will.

Pointer?
www.rsinc.com


--
--
kensmith@rahul.net forging knowledge
 
In article <csjog1$c45$1@sparta.btinternet.com>,
Reg Edwards <g4fgq,regp@ZZZbtinternet,com> wrote:
GOTO's are a positive menace. Any language which allows them is a disgrace
to mankind's considerable acheivements in that direction.
Variable assignment, looping constructs and the case statement are just as
dangerous. You can directly convert any GOTO ridden code into a loop
containing variable assignments, and a case statement. The result is no
easier to understand or debug.

--
--
kensmith@rahul.net forging knowledge
 
Subject: Re: GOTO's
From: kensmith@green.rahul.net (Ken Smith)
Date: 1/18/05 3:13 PM Pacific Standard Time

In article <csjog1$c45$1@sparta.btinternet.com>,
Reg Edwards <g4fgq,regp@ZZZbtinternet,com> wrote:

GOTO's are a positive menace. Any language which allows them is a disgrace
to mankind's considerable acheivements in that direction.

Variable assignment, looping constructs and the case statement are just as
dangerous. You can directly convert any GOTO ridden code into a loop
containing variable assignments, and a case statement. The result is no
easier to understand or debug.

I recently wrote a Visual Basic 6 test program, and I used one goto to loop the
sequence of tests back to the top to wait for the next circuit board to be
installed. This main loop called the subroutines that did the actual testing,
however it was still about 200 lines of code long, with another couple of
hundred lines of comments. In this case the Goto seems to make more sense than
ending the sequence with the end of a looping construct, because the statement
"goto next_test_start" is far more descriptive than a something like a Wend
with a comment.

Visual basics statement are almost like Pascal, if you set the variables to be
explictly defined. Really not very different at all, other than all the crap
that is added to make the program driven off screen objects.

Rocky
 
On Tue, 18 Jan 2005 15:53:49 -0600, John Fields
<jfields@austininstruments.com> wrote:

On Tue, 18 Jan 2005 19:36:33 +0000 (UTC), "Reg Edwards"
g4fgq.regp@ZZZbtinternet.com> wrote:


GOTO's are a positive menace. Any language which allows them is a disgrace
to mankind's considerable acheivements in that direction.

---
Assembler with no labels? What a concept!

There have been some attempts at "structured assembler" with 'for' and
'while' type kluges, generally by use of a simple preprocessor or a
bunch of weird macros. This makes debugging especially silly.

John
 
On Tue, 18 Jan 2005 16:55:42 +0000, Thaas wrote:

On Tue, 18 Jan 2005 15:33:40 +0000, John Woodgate
jmw@jmwa.demon.contraspam.yuk> wrote:

I read in sci.electronics.design that Keith Williams <krw@att.bizzzz
wrote (in <MPG.1c56f051c517484e989867@news.individual.net>) about
'Programming for Electronics Engineers', on Tue, 18 Jan 2005:

Everyone knows that no matter what the question, the
answer is 'C'.

What is the circuit symbol for an inductor?

|
C|
C|
C|
|
(created by AACircuit v1.28.4 beta 13/12/04 www.tech-chat.de)

See?
Damn! I wish I'd thought of that! ;-)

--
Keith
 
In article <8ufru0td1qlt8r195ufn4es34bjr13ohqp@4ax.com>,
John Larkin <jjSNIPlarkin@highTHISlandPLEASEtechnology.XXX> wrote:
[...]
No, it would be more proper to have all math operations be declared
external subroutines:

Div_Int_By_Float(*var1,*var2)
Better yet:

float Div_Int_By_Float ... etc

I think the routines should be in the form of "optionally inline
routines". The compiler could be made to expand the routines like macros
or call them. This way the optimizer can slim them down for speed.

I'd include all of the operators not just specifically the math ones.
This way, you could have range checked versions of the assign,
dereferencing and indexing operations.


--
--
kensmith@rahul.net forging knowledge
 
In article <7bgru0hu2ornqrtl3fh7sbqef7ijuhjka2@4ax.com>,
John Larkin <jjSNIPlarkin@highTHISlandPLEASEtechnology.XXX> wrote:
[...]
There have been some attempts at "structured assembler" with 'for' and
'while' type kluges, generally by use of a simple preprocessor or a
bunch of weird macros. This makes debugging especially silly.
Somewhere (perhaps on a disk that is not installed in my PC anymore) I
have a bunch of macros I made for the turbo assembler that did structured
stuff.

They were only slightly silly. They did allow programs to be written
without actually using a jump instruction. All they really did was
convert the IF_COND into a jump of the inverse sense and stuff like that.
It was a useful exersize that didn't make a useful result. It did prove
to me that it could be done.

--
--
kensmith@rahul.net forging knowledge
 
Ken Smith <kensmith@green.rahul.net> wrote:

[...]
example: (that actually does something)

{ <-- this is a comment --> }
var
q, p, r : extended; { Make my variables }

i : integer; { The usual loop counter }

{remember := is needed to assign }
begin
write('Q = '); readln(q); { Read in the values }
write('P = '); readln(p);

p := abs(p); { The sign doesn't matter }
q := abs(q);

if (p=0) and (q=0) then halt; { Don't use silly values }
That's BAD user interface!

var
q, p, r : extended; { Make my variables }

i : integer; { The usual loop counter }
flag : boolean;

{remember := is needed to assign }
begin

repeat
flag := true;
write('Q = '); readln(q); { Read in the values }
write('P = '); readln(p);
if (p=0) and (q=0) then { Don't use silly values }
begin
writeln('Illegal value(s)');
writeln;
flag := false
end
until flag { = true } ;

p := abs(p); { The sign doesn't matter }
q := abs(q);


if p<q then begin { p must be the bigger component.
r := p; p := q; q := r;
end;

if q<>0.0 then begin
for i := 1 to 10 do begin
r := q/p;
r := r*r;
r := r/(4+r);
p := p + 2*r*p;
q := q*r;
end;
end;

writeln('The radius is ',p);
end.


[....]
--
http://www.flexusergroup.com/
 
On Tue, 18 Jan 2005 19:36:33 +0000, Reg Edwards wrote:

GOTO's are a positive menace. Any language which allows them is a disgrace
to mankind's considerable acheivements in that direction.
Religion for the 2000's: AntiGOTOism, second only to antismokerism in
popularity and venom.
--
The Pig Bladder From Uranus, Still Waiting for
Some Hot Babe to Ask What My Favorite Planet Is.
 
On Wed, 19 Jan 2005 00:31:48 +0000, Rolavine wrote:
I recently wrote a Visual Basic 6 test program, and I used one goto to loop the
sequence of tests back to the top to wait for the next circuit board to be
installed. This main loop called the subroutines that did the actual testing,
however it was still about 200 lines of code long,
If you have one loop that's 200 lines long, then you're doing something
wrong. There's this little trick, called "subroutines", or sometimes
"functions".

And a "GOTO" at the end of it destroys your continuity. A Wend closes the
loop. A GOTO can go anywhere, and is more likely to leave crap on the
stack from the call it's pooping out of. It's a serious bug hole, and
hellishly difficult to debug.

Good Luck!
Rich
 
In article <pan.2005.01.19.06.09.58.115178@example.net>,
Rich Grise <richgrise@example.net> wrote:
[...]
Again, it depends on what you're trying to accomplish. I designed a bank
of Sallen-Key filters using a spreadsheet once. When the only tool you
have is a hammer, all problems start to look like a nail. ;-)
I still use a spreadsheet for such things sometimes. I must have a
hundred Pascal programs that model various parts of systems I've designed.
Logic equations in Pascal look a lot like the ones in VHDL or Abel.

One of the nice things about using a Pascal program instead of the real
system to test ideas is that the Pascal program can compare the results to
some ideal value and flag the ones that are out of range. Filters
implemented with integers almost never are exactly the ideal.

--
--
kensmith@rahul.net forging knowledge
 
On Wed, 19 Jan 2005 15:16:44 +0000 (UTC), kensmith@green.rahul.net
(Ken Smith) wrote:

In article <pan.2005.01.19.06.23.14.112876@example.net>,
Rich Grise <richgrise@example.net> wrote:
[...]
And a "GOTO" at the end of it destroys your continuity. A Wend closes the
loop.

"WEND" is short for "What the hell did that END" You have to put a comment
on it to say what it ended.

A GOTO can go anywhere, and is more likely to leave crap on the
stack from the call it's pooping out of.

Someone more expert in C will have to comment on this for C but in Pascal,
no you can't. Jumps out of context are not allowed. Algol had the
"thunk" method to handle the jump out of context. It is quite a good
idea.
Not possible in C/C++. goto can only branch within a function, and
will clean up any stacks created by blocks that you leave.
setjmp/longjump are also stack-clean, by definition.

Rick
 
In article <sqisu0p73ove1rgedvsrhet6b98vsm9h2b@4ax.com>,
Rick Thompson <nospam@nospam.com> wrote:
[....]
Good point. I write a lot of C++ and I can't see how you could write a
complex system without try/catch, or setjmp/longjump, or whatever.
You'd have to use numbering instead of indenting:


/* 10023 */ if (!IsBogus(Entry)) {
/* 10024 */ destruct->level = entry;
/* 10024 */ }
/* 10023 */ else {
/* 10024 */ destruct->level = DEFAULT_DESTRUCT_LEVEL;
/* 10024 */ Badness++;
/* 10024 */ }

See that way all you code doesn't end up 6 feet to the right.

--
--
kensmith@rahul.net forging knowledge
 
Ken Smith <kensmith@green.rahul.net> wrote:

In article <pan.2005.01.18.00.11.41.303631@example.net>,
Rich Grise <richgrise@example.net> wrote:
[...]
writeln('Q must be between 0 and 10000');
writeln;

This is still no good because Q and be above 10000 and still work.

You've also added a whole bunch of lines to the program. Is this effort
really worth it? How many times will you use the program before you
edit it into being a function some larger program calls.
Sorry, I've missed the earlier replies because I've limited the
number of posts in one download to the latest 50 in each group.

My comment was a bit 'tongue in cheek,' but I really think one should
under no circumstances let a program quit, without letting the user know
whether the program crashed or he/she did something wrong.

--
http://www.flexusergroup.com/
 
On Tue, 18 Jan 2005 18:06:42 -0800, John Larkin wrote:

On Tue, 18 Jan 2005 13:42:44 -0500, Keith Williams <krw@att.bizzzz
wrote:

In article <giequ0la46torit42hhv4lj1n1qesk6orn@4ax.com>,
jjSNIPlarkin@highTHISlandPLEASEtechnology.XXX says...
On Tue, 18 Jan 2005 11:09:43 -0500, Keith Williams <krw@att.bizzzz
wrote:

In article <1BrIGJEUxS7BFwhz@jmwa.demon.co.uk>,
jmw@jmwa.demon.contraspam.yuk says...
I read in sci.electronics.design that Keith Williams <krw@att.bizzzz
wrote (in <MPG.1c56f051c517484e989867@news.individual.net>) about
'Programming for Electronics Engineers', on Tue, 18 Jan 2005:

Everyone knows that no matter what the question, the
answer is 'C'.

What is the circuit symbol for an inductor?

What's the problem? indu-C-tor ;-)

If it can't be done in 'C', it's not worth doing. ;-)


The original design of C was too timid. Insteading of minimizing
keywords, K&R should have been bold and eliminated them entirely,
creating a language based entirely on punctuation marks.

I *hate* the punctuation marks C uses now! I much prefer begin/end to
{}. It's easier for my eyes to find words.

And the math operations should have been external subroutines like
everything else.

That would make overloading the functions easier, but do you really
want M$ to overload '/' like Intel did? ;-)

No, it would be more proper to have all math operations be declared
external subroutines:

Div_Int_By_Float(*var1,*var2)
....and you like 'C' because it uses punctuation marks instead of keywords?
<shudder>
like 'printf', evolving towards a pure, ideal language that does nothing
itself at all.
Scarry. I guess you're just going to have to put me down in the column
with other neandrathals who appreciate PL/I and VHDL, though I got along
with PASCAL too (other than it's total lack of I/O).


--
Keith
 
On Wed, 19 Jan 2005 11:24:00 -0800, Richard Henry wrote:

"Keith Williams" <krw@att.bizzzz> wrote in message
news:MPG.1c58752538b0628b989876@news.individual.net...
In article <7bgru0hu2ornqrtl3fh7sbqef7ijuhjka2@4ax.com>,
jjSNIPlarkin@highTHISlandPLEASEtechnology.XXX says...
On Tue, 18 Jan 2005 15:53:49 -0600, John Fields
jfields@austininstruments.com> wrote:

On Tue, 18 Jan 2005 19:36:33 +0000 (UTC), "Reg Edwards"
g4fgq.regp@ZZZbtinternet.com> wrote:


GOTO's are a positive menace. Any language which allows them is a
disgrace
to mankind's considerable acheivements in that direction.

---
Assembler with no labels? What a concept!


There have been some attempts at "structured assembler" with 'for' and
'while' type kluges, generally by use of a simple preprocessor or a
bunch of weird macros. This makes debugging especially silly.

FOr a while I used a set of PL/I macros for M$ MASM. They worked out
quite well and were recognized by the source debugger. I can't
remember if they supported the complete PL/I SELECT/WHEN construct, but
they were quite useful and produced tight code (even understanding
near/far).

I recall a Zilog product call PLZ for programming Z-80s. There were two
flavors: PLZ-ASM, which was pretty much Z-80 assembler with some linkage
support, and PLZ-SYS, which added the IF-ELSE-FI and DO-OD and similar
structure controls. I recall the first compiler bug I ever found: if the
object of a SWITCH-CASE structure was 16 bits, and the lower byte was
exactly 0, the program would lose track of its jump table, read two bytes
somewhere else in the program as the jump-to address, and promptly go
insane.
Failures of the implementaion aren't failures of the concept. The fact is
that such macros can be written properly and they do improve productivity.

--
Keith
 
On Tue, 18 Jan 2005 13:20:32 -0800, John Larkin
<jjlarkin@highSNIPlandTHIStechPLEASEnology.com> wrote:


Oops, I guess I scooped up about $40 million under dishonorable
conditions. I should give it all back, I suppose.
John, did I ever mention that along with Winston Churchill, you're the
one of the guys I most admire?
;-)
--

"What is now proved was once only imagin'd." - William Blake, 1793.
 

Welcome to EDABoard.com

Sponsor

Back
Top