Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > sci.electronics.design > #473729 > unrolled thread

Microchip ICD4 ?

Started byMartin Riddle <martin_rid@verizon.net>
First post2017-08-17 13:45 -0400
Last post2017-08-18 12:10 +0100
Articles 20 on this page of 91 — 25 participants

Back to article view | Back to sci.electronics.design


Contents

  Microchip ICD4 ? Martin Riddle <martin_rid@verizon.net> - 2017-08-17 13:45 -0400
    Re: Microchip ICD4 ? DemonicTubes <tlackie@gmail.com> - 2017-08-17 12:17 -0700
      Re: Microchip ICD4 ? Martin Riddle <martin_rid@verizon.net> - 2017-08-17 15:32 -0400
      Re: Microchip ICD4 ? speff <spehro@gmail.com> - 2017-08-17 19:02 -0700
    Re: Microchip ICD4 ? bitrex <bitrex@de.lete.earthlink.net> - 2017-08-17 15:52 -0400
      Re: Microchip ICD4 ? piglet <erichpwagner@hotmail.com> - 2017-08-17 21:23 +0100
        Re: Microchip ICD4 ? boB <boB@k7iq.com> - 2017-08-17 13:42 -0700
        Re: Microchip ICD4 ? Lasse Langwadt Christensen <langwadt@fonz.dk> - 2017-08-17 14:23 -0700
          Re: Microchip ICD4 ? rickman <gnuarm@gmail.com> - 2017-08-17 17:46 -0400
        Re: Microchip ICD4 ? rickman <gnuarm@gmail.com> - 2017-08-17 17:44 -0400
          Re: Microchip ICD4 ? bitrex <bitrex@de.lete.earthlink.net> - 2017-08-17 18:40 -0400
            Re: Microchip ICD4 ? DemonicTubes <tlackie@gmail.com> - 2017-08-17 16:19 -0700
              Re: Microchip ICD4 ? bitrex <bitrex@de.lete.earthlink.net> - 2017-08-17 22:04 -0400
            Re: Microchip ICD4 ? rickman <gnuarm@gmail.com> - 2017-08-17 20:03 -0400
              Re: Microchip ICD4 ? bitrex <bitrex@de.lete.earthlink.net> - 2017-08-17 23:17 -0400
                Re: Microchip ICD4 ? "Michael A. Terrell" <mike.terrell@earthlink.net> - 2017-08-18 07:36 -0400
              Re: Microchip ICD4 ? Paul Rubin <no.email@nospam.invalid> - 2017-08-17 22:50 -0700
                Re: Microchip ICD4 ? Martin Brown <'''newspam'''@nezumi.demon.co.uk> - 2017-08-18 14:43 +0100
                Re: Microchip ICD4 ? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-08-18 13:42 +0000
                  Re: Microchip ICD4 ? bitrex <bitrex@de.lete.earthlink.net> - 2017-08-18 12:49 -0400
                    Re: Microchip ICD4 ? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-08-18 17:11 +0000
                      Re: Microchip ICD4 ? bitrex <bitrex@de.lete.earthlink.net> - 2017-08-18 16:22 -0400
                      Re: Microchip ICD4 ? Martin Brown <'''newspam'''@nezumi.demon.co.uk> - 2017-08-19 08:44 +0100
                  Re: Microchip ICD4 ? Paul Rubin <no.email@nospam.invalid> - 2017-08-18 23:19 -0700
                  Re: Microchip ICD4 ? Paul Rubin <no.email@nospam.invalid> - 2017-08-28 00:22 -0700
                    Re: Microchip ICD4 ? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-09-02 16:35 +0000
                Re: Microchip ICD4 ? Cecil Bayona <cbayona@cbayona.com> - 2017-08-18 10:58 -0500
                  Re: Microchip ICD4 ? Paul Rubin <no.email@nospam.invalid> - 2017-08-18 09:34 -0700
              Re: Microchip ICD4 ? David Brown <david.brown@hesbynett.no> - 2017-08-18 13:22 +0200
                Re: Microchip ICD4 ? stephen@mpeforth.com (Stephen Pelc) - 2017-08-18 11:54 +0000
                  Re: Microchip ICD4 ? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-08-18 14:40 +0000
                  Re: Microchip ICD4 ? Paul Rubin <no.email@nospam.invalid> - 2017-08-18 09:29 -0700
                    Re: Microchip ICD4 ? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-08-18 17:06 +0000
                      Re: Microchip ICD4 ? Tom Gardner <spamjunk@blueyonder.co.uk> - 2017-08-18 19:59 +0100
                        Re: Microchip ICD4 ? dplatt@coop.radagast.org (Dave Platt) - 2017-08-18 12:49 -0700
                          Re: Microchip ICD4 ? albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-08-19 01:52 +0200
                            Re: Microchip ICD4 ? bitrex <bitrex@de.lete.earthlink.net> - 2017-08-18 20:40 -0400
                              Re: Microchip ICD4 ? bitrex <bitrex@de.lete.earthlink.net> - 2017-08-18 20:43 -0400
                              Re: Microchip ICD4 ? albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-08-19 13:03 +0200
                                Re: Microchip ICD4 ? bitrex <bitrex@de.lete.earthlink.net> - 2017-08-19 10:30 -0400
                                  Re: Microchip ICD4 ? albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-08-19 21:03 +0200
                          Re: Microchip ICD4 ? Paul Rubin <no.email@nospam.invalid> - 2017-08-18 23:28 -0700
                          Re: Microchip ICD4 ? David Brown <david.brown@hesbynett.no> - 2017-08-21 16:49 +0200
                        Re: Microchip ICD4 ? David Brown <david.brown@hesbynett.no> - 2017-08-21 16:43 +0200
                      Re: Microchip ICD4 ? Paul Rubin <no.email@nospam.invalid> - 2017-08-18 23:26 -0700
                Re: Microchip ICD4 ? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-08-18 14:11 +0000
                  Re: Microchip ICD4 ? David Brown <david.brown@hesbynett.no> - 2017-08-18 16:49 +0200
            Re: Microchip ICD4 ? Terry Porter <terry@tjporter.com.au> - 2017-08-18 02:40 +0000
              Re: Microchip ICD4 ? bitrex <bitrex@de.lete.earthlink.net> - 2017-08-17 22:55 -0400
                Re: Microchip ICD4 ? Terry Porter <terry@tjporter.com.au> - 2017-08-18 09:14 +0000
                  Re: Microchip ICD4 ? jack4747@gmail.com - 2017-08-18 03:10 -0700
                    Re: Microchip ICD4 ? Clive Arthur <cliveta@nowaytoday.co.uk> - 2017-08-18 11:38 +0100
                      Re: Microchip ICD4 ? Martin Brown <'''newspam'''@nezumi.demon.co.uk> - 2017-08-18 12:13 +0100
                      Re: Microchip ICD4 ? jack4747@gmail.com - 2017-08-18 04:25 -0700
                        Re: Microchip ICD4 ? Clive Arthur <cliveta@nowaytoday.co.uk> - 2017-08-18 13:43 +0100
                        Re: Microchip ICD4 ? Johann Klammer <klammerj@NOSPAM.a1.net> - 2017-08-18 23:40 +0200
                      Re: Microchip ICD4 ? David Brown <david.brown@hesbynett.no> - 2017-08-18 16:57 +0200
                        Re: Microchip ICD4 ? Przemek Klosowski <przemek@tux.dot.org> - 2017-08-22 03:24 +0000
                      Re: Microchip ICD4 ? bitrex <bitrex@de.lete.earthlink.net> - 2017-08-18 12:32 -0400
                  Re: Microchip ICD4 ? Neon John <no@never.com> - 2017-08-18 10:02 -0400
                    Re: Microchip ICD4 ? bitrex <bitrex@de.lete.earthlink.net> - 2017-08-18 11:02 -0400
                    Re: Microchip ICD4 ? Terry Porter <terry@tjporter.com.au> - 2017-08-20 07:46 +0000
                      Re: Microchip ICD4 ? David Brown <david.brown@hesbynett.no> - 2017-08-21 16:57 +0200
                  Re: Microchip ICD4 ? David Brown <david.brown@hesbynett.no> - 2017-08-18 16:54 +0200
              Re: Microchip ICD4 ? rickman <gnuarm@gmail.com> - 2017-08-17 23:01 -0400
                Re: Microchip ICD4 ? Terry Porter <terry@tjporter.com.au> - 2017-08-18 07:58 +0000
                  Re: Microchip ICD4 ? Paul Rubin <no.email@nospam.invalid> - 2017-08-18 01:19 -0700
                    Re: Microchip ICD4 ? Terry Porter <terry@tjporter.com.au> - 2017-08-18 20:51 +0000
                      Re: Microchip ICD4 ? Paul Rubin <no.email@nospam.invalid> - 2017-08-18 23:35 -0700
                        Re: Microchip ICD4 ? Terry Porter <terry@tjporter.com.au> - 2017-08-20 07:42 +0000
                          Re: Microchip ICD4 ? Paul Rubin <no.email@nospam.invalid> - 2017-08-20 19:49 -0700
                  Re: Microchip ICD4 ? rickman <gnuarm@gmail.com> - 2017-08-18 05:18 -0400
                    Re: Microchip ICD4 ? Terry Porter <terry@tjporter.com.au> - 2017-08-20 07:22 +0000
                      Re: Microchip ICD4 ? rickman <gnuarm@gmail.com> - 2017-08-22 00:08 -0400
                        Re: Microchip ICD4 ? Paul Rubin <no.email@nospam.invalid> - 2017-08-21 22:41 -0700
                          Re: Microchip ICD4 ? Terry Porter <terry@tjporter.com.au> - 2017-08-22 07:28 +0000
                            Re: Microchip ICD4 ? rickman <gnuarm@gmail.com> - 2017-08-23 16:52 -0400
              Re: Microchip ICD4 ? Paul Rubin <no.email@nospam.invalid> - 2017-08-17 22:54 -0700
              Re: Microchip ICD4 ? David Brown <david.brown@hesbynett.no> - 2017-08-18 16:36 +0200
                Re: Microchip ICD4 ? Terry Porter <terry@tjporter.com.au> - 2017-08-20 08:49 +0000
                  Re: Microchip ICD4 ? David Brown <david.brown@hesbynett.no> - 2017-08-21 17:03 +0200
                Re: Microchip ICD4 ? Terry Porter <terry@tjporter.com.au> - 2017-08-26 02:33 +0000
                  Re: Microchip ICD4 ? rickman <gnuarm@gmail.com> - 2017-08-26 01:55 -0400
                  Re: Microchip ICD4 ? Paul Rubin <no.email@nospam.invalid> - 2017-08-27 13:40 -0700
                    Re: Microchip ICD4 ? rickman <gnuarm@gmail.com> - 2017-09-02 12:58 -0400
                  Re: Microchip ICD4 ? David Brown <david.brown@hesbynett.no> - 2017-08-28 16:25 +0200
            Re: Microchip ICD4 ? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-08-18 13:28 +0000
      Re: Microchip ICD4 ? speff <spehro@gmail.com> - 2017-08-17 19:09 -0700
      Re: Microchip ICD4 ? TTman <pcw1.cad@ntlworld.com> - 2017-08-18 10:12 +0100
        Re: Microchip ICD4 ? rickman <gnuarm@gmail.com> - 2017-08-18 05:21 -0400
          Re: Microchip ICD4 ? TTman <pcw1.cad@ntlworld.com> - 2017-08-18 12:10 +0100

Page 3 of 5 — ← Prev page 1 2 [3] 4 5  Next page →


#474088

Fromalbert@cherry.spenarnc.xs4all.nl (Albert van der Horst)
Date2017-08-19 21:03 +0200
Message-ID<ona21i$rg6$1@cherry.spenarnc.xs4all.nl>
In reply to#474048
In article <XXXlB.4787$Pn2.200@fx37.iad>,
bitrex  <bitrex@de.lete.earthlink.net> wrote:
>On 08/19/2017 07:03 AM, Albert van der Horst wrote:
>
>> I've made some solid C++ code, but I shudder what remains of it
>> after a few years of "maintenance" by a novice.
>> See ssort.html on my site below as of 1993.
>>
>> Groetjes Albert
>
>It looks very 1994. ;-) Large classes, lots of methods which look like
>straight-C internally.

Sure.

>
>Nowadays if you wanted to use a custom sorting algorithm on a custom
>buffer you'd probably subclass or composite one of the STL containers
>that implemented most of the "concepts" you wanted like say
>"SequenceContainer", BackInsertable", etc.; if you wanted custom memory
>allocator behavior you'd write a class conforming to the "Allocator"
>template (you can hot-plug any allocator policy into just about any
>conformant Container), and your algorithm would follow the "Algorithm"
>template. Then apply the algorithm to the objects in the container.

It would be interesting to look at it converted to modern C++.

The main difficulties are:
1.  After reading, there is raw bytes. Then there must be imposed
 a record and field structure based on a regular expression given
by the user. Then it must be again be output as raw bytes, that
can be reinterpreted in the same way.
2. Reading must be in chunks, in MSDOS this was available memory
(1 Mbyte), now it must be about an L2 cache worth.

My guess is that it amounts to a lot of frustration before the
compiler does your bidding.

It would be an academic exercise though. The choice of algorithm
results in poor locality on modern machines. Disk merging would
be replaced by mapped files, or straight use of virtual memory,
maybe even swapping would not be too detrimental.
But then, variable length records that must be output in sorted
order to a file will result in a lot of cache misses even in
qsort. Now records are copied once for each merge phase.
With 5-10 way merge there are few merge phases.

(On a 1 Gbyte file it looses a factor 10-40 compared to GNU
sort. Yet, because of its capabilities, there is talk about adding it
to Debian. )

Groetjes Albert
-- 
Albert van der Horst, UTRECHT,THE NETHERLANDS
Economic growth -- being exponential -- ultimately falters.
albert@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst

[toc] | [prev] | [next] | [standalone]


#474018

FromPaul Rubin <no.email@nospam.invalid>
Date2017-08-18 23:28 -0700
Message-ID<8760dknk9o.fsf@nightsong.com>
In reply to#473938
dplatt@coop.radagast.org (Dave Platt) writes:
> I once took advantage of a compiler bug in a Univac FORTRAN system, to
> demonostrate to my doubting FORTRAN instructor that the computer
> believed that two plus two equals six.  I incremented the value of a
> parameter which was passed into a FORTRAN function (and FORTRAN of the
> era always passed all parameters by reference, not by value).

Fortran historically passed parameters by copy-restore (not by
reference), so the compiler did a permissible thing in your example.

[toc] | [prev] | [next] | [standalone]


#474280

FromDavid Brown <david.brown@hesbynett.no>
Date2017-08-21 16:49 +0200
Message-ID<onermc$b6s$1@dont-email.me>
In reply to#473938
On 18/08/17 21:49, Dave Platt wrote:
> In article <mOGlB.665617$lQ6.78056@fx29.am4>,
> Tom Gardner  <spamjunk@blueyonder.co.uk> wrote:
> 
>> Too true :( Plus the programmer often lies.
>>
>> What /is/ the consequence of one compilation unit
>> "casting away the constness" of something defined
>> in another compilation unit?
> 
> "Undefined behavior" which is highly application-specific.  Anything
> from no ill effect, to incorrect output (either immediately or at some
> later time), to terrible data corruption, to a quick crash/segfault.
> 
> In extreme cases, things like "destruction of hardware" and "loss of
> life" can occur.
> 
> I once took advantage of a compiler bug in a Univac FORTRAN system, to
> demonostrate to my doubting FORTRAN instructor that the computer
> believed that two plus two equals six.  I incremented the value of a
> parameter which was passed into a FORTRAN function (and FORTRAN of the
> era always passed all parameters by reference, not by value).  Since
> I'd passed a constant "2", and since the compiler hadn't bothered
> either to memory-protect the constant or provide an emphermeral
> copy... foom.
> 
> The "all constants are variable" rule took hold.  :-)
> 

You can do that in Forth - it is not even a bug:

: 2 3 ; ok

2 2 + . 6 ok

[toc] | [prev] | [next] | [standalone]


#474279

FromDavid Brown <david.brown@hesbynett.no>
Date2017-08-21 16:43 +0200
Message-ID<onerbe$a40$1@dont-email.me>
In reply to#473928
On 18/08/17 20:59, Tom Gardner wrote:
> On 18/08/17 18:06, Anton Ertl wrote:
>> Paul Rubin <no.email@nospam.invalid> writes:
>>> stephen@mpeforth.com (Stephen Pelc) writes:
>>>> Where gcc (in particular) wins is in the huge amount
>>>> of time and money spent on the ARM and x86 versions
>>>
>>> The type system also helps with alias analysis,
>>
>> It doesn't.  What you mean is: By (often wrongly) assuming that C
>> programs don't access data through pointers of other types,
>> adversarial C compilers save themselves the trouble of trying to do
>> proper alias analysis.  But of course, the result is often wrong,
>> because the assumption is often wrong.
> 

You mean C compilers generate code that does not do what the programmer
expected, when the programmer does not know how to write C code properly?

A programming language - any programming language - is a contract
between the programmer and the compiler.  The programmer promises to
obey the rules of the language, and the compiler promises to give object
code that implements the source code.  If the C programmer accesses data
through pointers of other types, without taking proper measures (using
unions, memcpy, volatile, char* types, or implementation-specific
techniques), then he is breaking his side of the bargain.

I don't think type-based alias analysis actually helps very much in
optimisation, but on the other hand I don't see it as being a high risk
of mistakes.  Code that messes about accessing the same data as
different types is usually wrong anyway - and if you really /do/ want to
do it, there are perfectly good and efficient ways to do it correctly.

And if you want to write code that gets this wrong - such as the Linux
kernel - then compilers that implement strong optimisations typically
have options to control that behaviour.  gcc has "-fno-strict-aliasing".
 And since it does not do alias analysis unless you ask it for
optimisation, you can just add that in as an option along with "-O2" or
whatever optimisation options you pick.  (That's what the Linux kernel
does.)

> Too true :( Plus the programmer often lies.

Lie to your compiler, and it will bite you.  I have sympathy for people
who make mistakes in their coding - no programmer is perfect (not even
Forth programmers).  But I have little sympathy for people who knowingly
write bad code because they feel it /should/ work.

> 
> What /is/ the consequence of one compilation unit
> "casting away the constness" of something defined
> in another compilation unit?
> 

If you have an object originally defined as "const", and cast away that
constness, then try to write to the object - then you get undefined
behaviour.  The consequences are therefore unpredictable.

In C, if you use a "const" pointer, you are saying "I promise not to
change the thing pointed at, via this pointer".  No more, no less.  You
are not claiming you will /never/ change the object, just that you won't
do it with that pointer.

But if the object is originally defined with "const", then you /are/
promising that the object will never be changed.  (If it is "volatile
const", you are saying that something else might change it, but you
never will.)  The compiler can optimise on that assumption - it can use
the const value directly in code without creating an object in memory,
or it can put the object in read-only memory, or it can do both.

So if the original object is const and you cast away the constness
(which is allowed), and then try to write to it (reading is fine), you
are breaking your contract and anything can happen.  In particular, some
bits of code might read the new value, other bits might continue to use
the old value.  And the write itself can fail if the memory is protected
against writing in some way.

[toc] | [prev] | [next] | [standalone]


#474017

FromPaul Rubin <no.email@nospam.invalid>
Date2017-08-18 23:26 -0700
Message-ID<87a82wnkdo.fsf@nightsong.com>
In reply to#473890
anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
> It doesn't.  What you mean is: By (often wrongly) assuming that C
> programs don't access data through pointers of other types,
> adversarial C compilers save themselves the trouble of trying to do
> proper alias analysis.

Well, I'm thinking partly of the restrict keyword introduced in C99,
which explicitly tells the compiler that there's no alias.  

> But of course, the result is often wrong, because the assumption is
> often wrong.

That's true, accessing data through pointers of multiple types is not
allowed in C, so it's unsurprising that programmers who make wrong
assumptions to the contrary can get wrong results.  Wrong assumptions
are the cause of plenty of bugs no matter what language is used.

> The Forth *programmer* gets rid of unneeded loads and stores by not
> writing them.

That requires close manual control over large stretches of code, that a
real compiler automates.

[toc] | [prev] | [next] | [standalone]


#473851

Fromanton@mips.complang.tuwien.ac.at (Anton Ertl)
Date2017-08-18 14:11 +0000
Message-ID<2017Aug18.161141@mips.complang.tuwien.ac.at>
In reply to#473831
David Brown <david.brown@hesbynett.no> writes:
>As a simple example, lets consider a scaling routine:
>
>
>static const int divFactor = 2815;
>static const int multFactor = 31214;
>
>int scale(int x) {
>    return (x * multFactor) / divFactor;
>}
...
>(I cannot tell you if a Forth compiler can generate object code like
>this - I know they can do /some/ optimisations, but I have no idea of
>the details.)

2815 constant divfactor
31214 constant mulfactor
: scale mulfactor divfactor */ ;
: scale1 mulfactor * divfactor / ;

VFX and SwiftForth (for IA-32) use IDIV in both variants, for iForth I
don't know how to see the generated code (SEE produces something
resembling the source code).

However, the Forth way is to let the compiler and the programmer work
hand-in-hand, and for this particular case, the solution already
exists (as long as x is not negative):

http://git.savannah.gnu.org/cgit/gforth.git/plain/compat/stagediv.fs

include compat/stagediv.fs
2815 constant divfactor
31214 constant mulfactor
: scale mulfactor * [ divfactor ]u/  ;

VFX:
SCALE 
( 080C0D50    69DBEE790000 )          IMUL      EBX, EBX, # 000079EE
( 080C0D56    68EF471700 )            PUSH      001747EF
( 080C0D5B    B8EA064C44 )            MOV       EAX, 444C06EA
( 080C0D60    F7E3 )                  MUL       EBX
( 080C0D62    59 )                    POP       ECX
( 080C0D63    8D6DF4 )                LEA       EBP, [EBP+-0C]
( 080C0D66    895D00 )                MOV       [EBP], EBX
( 080C0D69    C7450400000000 )        MOV       DWord Ptr [EBP+04], 00000000
( 080C0D70    895508 )                MOV       [EBP+08], EDX
( 080C0D73    8BD9 )                  MOV       EBX, ECX
( 080C0D75    8BC3 )                  MOV       EAX, EBX
( 080C0D77    F76500 )                MUL       [EBP]
( 080C0D7A    034508 )                ADD       EAX, [EBP+08]
( 080C0D7D    135504 )                ADC       EDX, [EBP+04]
( 080C0D80    8BDA )                  MOV       EBX, EDX
( 080C0D82    8D6D0C )                LEA       EBP, [EBP+0C]
( 080C0D85    C3 )                    NEXT,
( 54 bytes, 17 instructions )

No DIVs, although quite a lot of MOVs.  The SwiftForth variant
executes more code.  iForth disassembles this time around:

$10226440  : scale                      488BC04883ED088F4500      H.@H.m..E.
$1022644A  pop           rbx            5B                        [
$1022644B  imul          rbx, rbx, $000079EE d# 
                                        4869DBEE790000            Hi[ny..
$10226452  mov           rax, $5B084692:0D470675 q# 
                                        48B87506470D9246085B      H8u.G..F.[
$1022645C  mov           rdi, rbx       488BFB                    H.{
$1022645F  xchg          rdx, rdi       4887FA                    H.z
$10226462  mul           rdx            48F7E2                    Hwb
$10226465  xchg          rdx, rdi       4887FA                    H.z
$10226468  mov           rax, $001747EF:444C06E9 q# 
                                        48B8E9064C44EF471700      H8i.LDoG..
$10226472  xchg          rdx, rbx       4887DA                    H.Z
$10226475  mul           rdx            48F7E2                    Hwb
$10226478  xchg          rdx, rbx       4887DA                    H.Z
$1022647B  add           rdi, rax       4803F8                    H.x
$1022647E  adc           rbx, 0 b#      4883D300                  H.S.
$10226482  push          rbx            53                        S
$10226483  ;

Also no DIV.

- anton
-- 
M. Anton Ertl  http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
     New standard: http://www.forth200x.org/forth200x.html
   EuroForth 2017: http://euro.theforth.net/

[toc] | [prev] | [next] | [standalone]


#473853

FromDavid Brown <david.brown@hesbynett.no>
Date2017-08-18 16:49 +0200
Message-ID<on6uih$7j6$1@dont-email.me>
In reply to#473851
On 18/08/17 16:11, Anton Ertl wrote:
> David Brown <david.brown@hesbynett.no> writes:
>> As a simple example, lets consider a scaling routine:
>>
>>
>> static const int divFactor = 2815;
>> static const int multFactor = 31214;
>>
>> int scale(int x) {
>>    return (x * multFactor) / divFactor;
>> }
> ...
>> (I cannot tell you if a Forth compiler can generate object code like
>> this - I know they can do /some/ optimisations, but I have no idea of
>> the details.)
> 
> 2815 constant divfactor
> 31214 constant mulfactor
> : scale mulfactor divfactor */ ;
> : scale1 mulfactor * divfactor / ;
> 
> VFX and SwiftForth (for IA-32) use IDIV in both variants, for iForth I
> don't know how to see the generated code (SEE produces something
> resembling the source code).
> 
> However, the Forth way is to let the compiler and the programmer work
> hand-in-hand, and for this particular case, the solution already
> exists (as long as x is not negative):

Obviously it is not possible to compare exact outputs without using the
same target devices.  But it would seem that you are getting roughly the
same kind of optimisations - but with a good deal more manual work.
Still, it is nice to see that it is possible to do this in Forth too.

[toc] | [prev] | [next] | [standalone]


#473795

FromTerry Porter <terry@tjporter.com.au>
Date2017-08-18 02:40 +0000
Message-ID<59965381$0$1499$c3e8da3$5496439d@news.astraweb.com>
In reply to#473768
On Thu, 17 Aug 2017 18:40:58 -0400, bitrex wrote:

> On 08/17/2017 05:44 PM, rickman wrote:
>> piglet wrote on 8/17/2017 4:23 PM:
>>> On 17/08/2017 20:52, bitrex wrote:
>>>> On 08/17/2017 01:45 PM, Martin Riddle wrote:
>>>>> Any folks using this ICD4?
>>>>>
>>>>> Cheers
>>>>>
>>>>>
>>>> I hope nobody's still writing uP code in asm in the year 2k17.
>>>
>>> I do, assembler is the best!
>>>
>>> With a good suite of macros can do anything better than them darn
>>> annoying "high level" languages claim.
>> 
>> I have often thought of Forth as a macro assembler on steroids. 
>> Mecrisp is being given optimizations that get it even closer to working
>> in assembler in terms of speed and code size.  Have you ever looked at
>> it?
>> 
>> 
> My contention is that well-written modern C++1x will destroy any
> handwritten asm or compiled-Forth "macro assembler" program on both
> execution speed and code size for any nontrivial general computing task
> in all but the most extreme edge-cases, even on say AVR 8 bit devices.
> 
> There should be a contest! ;-)

Why not, personally I believe that hand wrtten assembly will murder any 
modern C++1x, so here is my challenge.

A human-visible Blinky with the smallest binary size, and without strange 
electrical states on other pins. A 'Blinky" blinks a LED around once a 
second but may be faster or slower as long as it's clearly 'blinking' to 
a human.

The targets: 
MCU		       | Assembly binary size to beat so far:
1) STM32F051 Discovery | 32 bytes
2) MSP340	       | 14 bytes

Note: The binary sizes above were above hand crafted by Matthias Koch, 
author of Mecrisp, Mecrisp-Stellaris, Mecrisp-Across and many other 
programs.

A personal note, my own efforts are tabled below, both are boring, no 
shortcut tutorial Blinkies:
Assembly STM32F051 Discovery Blinky: 84 bytes.
GCC STM32F051 Discovery Blinky: 312 bytes.

Cheers,
Terry


-- 
Mecrisp-Stellaris Unofficial User Doc: http://128.199.141.78/index.html

[toc] | [prev] | [next] | [standalone]


#473797

Frombitrex <bitrex@de.lete.earthlink.net>
Date2017-08-17 22:55 -0400
Message-ID<AGslB.14534$wI2.8826@fx41.iad>
In reply to#473795
On 08/17/2017 10:40 PM, Terry Porter wrote:
> On Thu, 17 Aug 2017 18:40:58 -0400, bitrex wrote:
> 
>> On 08/17/2017 05:44 PM, rickman wrote:
>>> piglet wrote on 8/17/2017 4:23 PM:
>>>> On 17/08/2017 20:52, bitrex wrote:
>>>>> On 08/17/2017 01:45 PM, Martin Riddle wrote:
>>>>>> Any folks using this ICD4?
>>>>>>
>>>>>> Cheers
>>>>>>
>>>>>>
>>>>> I hope nobody's still writing uP code in asm in the year 2k17.
>>>>
>>>> I do, assembler is the best!
>>>>
>>>> With a good suite of macros can do anything better than them darn
>>>> annoying "high level" languages claim.
>>>
>>> I have often thought of Forth as a macro assembler on steroids.
>>> Mecrisp is being given optimizations that get it even closer to working
>>> in assembler in terms of speed and code size.  Have you ever looked at
>>> it?
>>>
>>>
>> My contention is that well-written modern C++1x will destroy any
>> handwritten asm or compiled-Forth "macro assembler" program on both
>> execution speed and code size for any nontrivial general computing task
>> in all but the most extreme edge-cases, even on say AVR 8 bit devices.
>>
>> There should be a contest! ;-)
> 
> Why not, personally I believe that hand wrtten assembly will murder any
> modern C++1x, so here is my challenge.
> 
> A human-visible Blinky with the smallest binary size, and without strange
> electrical states on other pins. A 'Blinky" blinks a LED around once a
> second but may be faster or slower as long as it's clearly 'blinking' to
> a human.
> 
> The targets:
> MCU		       | Assembly binary size to beat so far:
> 1) STM32F051 Discovery | 32 bytes
> 2) MSP340	       | 14 bytes
> 
> Note: The binary sizes above were above hand crafted by Matthias Koch,
> author of Mecrisp, Mecrisp-Stellaris, Mecrisp-Across and many other
> programs.
> 
> A personal note, my own efforts are tabled below, both are boring, no
> shortcut tutorial Blinkies:
> Assembly STM32F051 Discovery Blinky: 84 bytes.
> GCC STM32F051 Discovery Blinky: 312 bytes.
> 
> Cheers,
> Terry

I did handwavy-qualify my statement to "nontrivial" tasks. I'd consider 
blinking an LED "trivial" and wouldn't doubt asm could beat a compiled 
language on that one. YMMV.

312 bytes for GCC on that target seems gigantic, regardless. That was 
with the -Os size flag, yeah?

[toc] | [prev] | [next] | [standalone]


#473817

FromTerry Porter <terry@tjporter.com.au>
Date2017-08-18 09:14 +0000
Message-ID<5996aff9$0$1499$c3e8da3$5496439d@news.astraweb.com>
In reply to#473797
On Thu, 17 Aug 2017 22:55:28 -0400, bitrex wrote:


>>> My contention is that well-written modern C++1x will destroy any
>>> handwritten asm or compiled-Forth "macro assembler" program on both
>>> execution speed and code size for any nontrivial general computing
>>> task in all but the most extreme edge-cases, even on say AVR 8 bit
>>> devices.

> I did handwavy-qualify my statement to "nontrivial" tasks. I'd consider
> blinking an LED "trivial" and wouldn't doubt asm could beat a compiled
> language on that one. YMMV.

My mileage has never varied, assembly always beats a compiled
language Blinky in code size in my experience.

> 
> 312 bytes for GCC on that target seems gigantic, regardless. That was
> with the -Os size flag, yeah?

No, because while -Os does make the binary smaller, it optomizes away the 
blinking, a common hardware issue.



-- 
Mecrisp-Stellaris Unofficial User Doc: http://128.199.141.78/index.html

[toc] | [prev] | [next] | [standalone]


#473826

Fromjack4747@gmail.com
Date2017-08-18 03:10 -0700
Message-ID<003b53ab-9b85-45bc-82e5-34529857b82c@googlegroups.com>
In reply to#473817
Il giorno venerdì 18 agosto 2017 11:14:38 UTC+2, Terry Porter ha scritto:

> > 312 bytes for GCC on that target seems gigantic, regardless. That was
> > with the -Os size flag, yeah?
> 
> No, because while -Os does make the binary smaller, it optomizes away the 
> blinking, a common hardware issue.

If it does, it's because you wrote a very bad C code.

Bye Jack

[toc] | [prev] | [next] | [standalone]


#473827

FromClive Arthur <cliveta@nowaytoday.co.uk>
Date2017-08-18 11:38 +0100
Message-ID<on6frl$ojo$1@dont-email.me>
In reply to#473826
On 18/08/2017 11:10, jack4747@gmail.com wrote:
> Il giorno venerdì 18 agosto 2017 11:14:38 UTC+2, Terry Porter ha scritto:
> 
>>> 312 bytes for GCC on that target seems gigantic, regardless. That was
>>> with the -Os size flag, yeah?
>>
>> No, because while -Os does make the binary smaller, it optomizes away the
>> blinking, a common hardware issue.
> 
> If it does, it's because you wrote a very bad C code.
> 
> Bye Jack

That sums it up.  You write code to do something, the compiler makes it 
do something else, but it's somehow your fault.  Not the compiler 
writer's, no siree bob.

Like = and == in C.  Get those wrong and it's your fault, no blame at 
all attached to the donkeys who designed it for unreliability.

I like assembler.  What you see is what you get, and there's no-one to 
blame but yourself.  Use a compiler, and there's a black box designed by 
somebody else in the way.  Yes, I know you have to for many/most things.

What I don't like about assembler is the pointless limitations on 
positioning and labels.

Cheers
-- 
Clive

[toc] | [prev] | [next] | [standalone]


#473829

FromMartin Brown <'''newspam'''@nezumi.demon.co.uk>
Date2017-08-18 12:13 +0100
Message-ID<on6i55$1757$1@gioia.aioe.org>
In reply to#473827
On 18/08/2017 11:38, Clive Arthur wrote:
> On 18/08/2017 11:10, jack4747@gmail.com wrote:
>> Il giorno venerdì 18 agosto 2017 11:14:38 UTC+2, Terry Porter ha scritto:
>>
>>>> 312 bytes for GCC on that target seems gigantic, regardless. That was
>>>> with the -Os size flag, yeah?
>>>
>>> No, because while -Os does make the binary smaller, it optomizes away 
>>> the
>>> blinking, a common hardware issue.
>>
>> If it does, it's because you wrote a very bad C code.
>>
>> Bye Jack
> 
> That sums it up.  You write code to do something, the compiler makes it 
> do something else, but it's somehow your fault.  Not the compiler 
> writer's, no siree bob.

volatile usually fixes such loop invariant optimisation problems.
(but not always if your code looks too much like a benchmark!)

> Like = and == in C.  Get those wrong and it's your fault, no blame at 
> all attached to the donkeys who designed it for unreliability.

The alternative is := and = in Pascal and Modula 2.
Then people grumble about all the extra typing so you can't win.

> I like assembler.  What you see is what you get, and there's no-one to 
> blame but yourself.  Use a compiler, and there's a black box designed by 
> somebody else in the way.  Yes, I know you have to for many/most things.

Assembler doesn't scale well to large projects. We learnt that very 
early on when autocode was developed as a stepping stone to compilers.

-- 
Regards,
Martin Brown

[toc] | [prev] | [next] | [standalone]


#473833

Fromjack4747@gmail.com
Date2017-08-18 04:25 -0700
Message-ID<fdbf8d65-0496-4a62-8b3c-1f0f8969b228@googlegroups.com>
In reply to#473827
Il giorno venerdì 18 agosto 2017 12:38:54 UTC+2, Clive Arthur ha scritto:
> On 18/08/2017 11:10, jack4747@gmail.com wrote:
> > Il giorno venerdì 18 agosto 2017 11:14:38 UTC+2, Terry Porter ha scritto:
> > 
> >>> 312 bytes for GCC on that target seems gigantic, regardless. That was
> >>> with the -Os size flag, yeah?
> >>
> >> No, because while -Os does make the binary smaller, it optomizes away the
> >> blinking, a common hardware issue.
> > 
> > If it does, it's because you wrote a very bad C code.
> > 
> > Bye Jack
> 
> That sums it up.  You write code to do something, the compiler makes it 
> do something else, but it's somehow your fault.  Not the compiler 
> writer's, no siree bob.

the compiler follows rules.
If you don't follow them when writing code, you can't blame the compiler if it does things that you don't want.


> Like = and == in C.  Get those wrong and it's your fault, no blame at 
> all attached to the donkeys who designed it for unreliability.

that's more or less the same as using a arithmetic shift instead of a logical in assembler, of course it's not your fault, it's the donkeys who wrote the instruction set: the CPU should have a crystal ball and understand what you want even if you write it incorrectly.

Bye Jack

[toc] | [prev] | [next] | [standalone]


#473838

FromClive Arthur <cliveta@nowaytoday.co.uk>
Date2017-08-18 13:43 +0100
Message-ID<on6n5c$fhb$1@dont-email.me>
In reply to#473833
On 18/08/2017 12:25, jack4747@gmail.com wrote:
> Il giorno venerdì 18 agosto 2017 12:38:54 UTC+2, Clive Arthur ha scritto:
>> On 18/08/2017 11:10, jack4747@gmail.com wrote:
>>> Il giorno venerdì 18 agosto 2017 11:14:38 UTC+2, Terry Porter ha scritto:
>>>
>>>>> 312 bytes for GCC on that target seems gigantic, regardless. That was
>>>>> with the -Os size flag, yeah?
>>>>
>>>> No, because while -Os does make the binary smaller, it optomizes away the
>>>> blinking, a common hardware issue.
>>>
>>> If it does, it's because you wrote a very bad C code.
>>>
>>> Bye Jack
>>
>> That sums it up.  You write code to do something, the compiler makes it
>> do something else, but it's somehow your fault.  Not the compiler
>> writer's, no siree bob.
> 
> the compiler follows rules.
> If you don't follow them when writing code, you can't blame the compiler if it does things that you don't want.
> 
> 
>> Like = and == in C.  Get those wrong and it's your fault, no blame at
>> all attached to the donkeys who designed it for unreliability.
> 
> that's more or less the same as using a arithmetic shift instead of a logical in assembler, of course it's not your fault, it's the donkeys who wrote the instruction set: the CPU should have a crystal ball and understand what you want even if you write it incorrectly.
> 
> Bye Jack
> 
No. A logical shift and an arithmetic shift do different things and have 
different names, whereas = has been used for ever (donkeys' years!) to 
mean 'equals', or 'is equal to'.  To then specify that symbol to mean 
'is replaced by', and to invent the new symbol == to mean what 
*everybody* was taught that = means, is wanton stupidity.

I wasn't brought up with C in college, so I am allowed such blasphemy.

Cheers
-- 
Clive

[toc] | [prev] | [next] | [standalone]


#473959

FromJohann Klammer <klammerj@NOSPAM.a1.net>
Date2017-08-18 23:40 +0200
Message-ID<on7msq$1jp8$1@gioia.aioe.org>
In reply to#473833
On 08/18/2017 01:25 PM, jack4747@gmail.com wrote:
> 
> the compiler follows rules.

Vaguely specified ones, that differ from compiler to compiler and 
often depend on cmdline switches.

[toc] | [prev] | [next] | [standalone]


#473856

FromDavid Brown <david.brown@hesbynett.no>
Date2017-08-18 16:57 +0200
Message-ID<on6v17$8u3$1@dont-email.me>
In reply to#473827
On 18/08/17 12:38, Clive Arthur wrote:
> On 18/08/2017 11:10, jack4747@gmail.com wrote:
>> Il giorno venerdì 18 agosto 2017 11:14:38 UTC+2, Terry Porter ha scritto:
>>
>>>> 312 bytes for GCC on that target seems gigantic, regardless. That was
>>>> with the -Os size flag, yeah?
>>>
>>> No, because while -Os does make the binary smaller, it optomizes away
>>> the
>>> blinking, a common hardware issue.
>>
>> If it does, it's because you wrote a very bad C code.
>>
>> Bye Jack
> 
> That sums it up.  You write code to do something, the compiler makes it
> do something else, but it's somehow your fault.  Not the compiler
> writer's, no siree bob.

Correct.

If you try to write something in English, and you spell it incorrectly,
whose fault is it?  If you try to write something in assembly but get
the instructions wrong, whose fault is it?

If you try to write something in C, but do not know how to do so
correctly, then it is /not/ the compiler's fault - it is /your/ fault.

> 
> Like = and == in C.  Get those wrong and it's your fault, no blame at
> all attached to the donkeys who designed it for unreliability.

Yes, it is /your/ fault.  And if your tools don't spot such mistakes
automatically, it is /your/ fault for not understanding how to use your
tools properly.  Just like when you hit your thumb with a hammer - it is
not the fault of the hammer or the nail.

> 
> I like assembler.  What you see is what you get, and there's no-one to
> blame but yourself.  Use a compiler, and there's a black box designed by
> somebody else in the way.  Yes, I know you have to for many/most things.

If you want to use a tool, learn how to do so.  Compilers are not
mysterious or malicious - it is just that some users are incompetent.

> 
> What I don't like about assembler is the pointless limitations on
> positioning and labels.
> 
> Cheers

[toc] | [prev] | [next] | [standalone]


#474308

FromPrzemek Klosowski <przemek@tux.dot.org>
Date2017-08-22 03:24 +0000
Message-ID<ong84q$eab$3@dont-email.me>
In reply to#473856
On Fri, 18 Aug 2017 16:57:42 +0200, David Brown wrote:

>> I like assembler.  What you see is what you get, and there's no-one to
>> blame but yourself.  Use a compiler, and there's a black box designed
>> by somebody else in the way.  Yes, I know you have to for many/most
>> things.
> 
> If you want to use a tool, learn how to do so.  Compilers are not
> mysterious or malicious - it is just that some users are incompetent.

Brian Cantrell had a great line: "If you stick your hand into the 
lawnmower, it'll maim it. It doesn't hate you or anything---it's just 
being a lawnmower".

[toc] | [prev] | [next] | [standalone]


#473881

Frombitrex <bitrex@de.lete.earthlink.net>
Date2017-08-18 12:32 -0400
Message-ID<aEElB.1493$PB1.491@fx09.iad>
In reply to#473827
On 08/18/2017 06:38 AM, Clive Arthur wrote:

> That sums it up.  You write code to do something, the compiler makes it 
> do something else, but it's somehow your fault.  Not the compiler 
> writer's, no siree bob.
> 
> Like = and == in C.  Get those wrong and it's your fault, no blame at 
> all attached to the donkeys who designed it for unreliability.
> 
> I like assembler.  What you see is what you get, and there's no-one to 
> blame but yourself.  Use a compiler, and there's a black box designed by 
> somebody else in the way.  Yes, I know you have to for many/most things.
> 
> What I don't like about assembler is the pointless limitations on 
> positioning and labels.
> 
> Cheers

In C++ you shouldn't even be using the "==" operator on the basic 
literal types most of the time, anyway. It means your types aren't 
strong enough. You shouldn't ever be able to have -5000 pieces of gold 
or be 350 years old.

Instead you have classes which encapsulate and sanitize your user data. 
In C++1x:

auto player_1_gold = player_gold_t{500};  //player1 has 500 gold
auto player_2_gold = player_gold_t{1000}; //player2 has 1000 gold

So this works (assuming appropriately overloaded "==" operator):

player_1_gold == player_2_gold ? ...etc. //OK

But you define your copy constructor and user defined integer-conversion 
operator "explicit" to make stuff like this illegal:

if (player_1_gold = 1000) //Compiler error, can't assign "500 int" to a 
"player_gold_t"

if (player_1_gold == 500) //Compiler error, No implicit comparison 
possible between "500 int" and "player_gold_t"

if (player_1_gold = player_2_gold) //Compiler error, no implicit 
conversion from "player_gold_t" to "bool"

if (player_1_gold == static_cast<player_gold_t>(500)) //OK

void foo(unsigned int bar) {...

foo(player_1_gold); //Compiler error, no implicit conversion from 
player_gold_t to "unsigned int"

auto player_3_gold = player_2_gold //Compiler error, Copy constructor 
marked "explicit", direct initialization of "player_3_gold" from 
"player_2_gold" not possible


auto player_3_gold{player_2_gold}; //OK, player_3_gold initialized from 
player_2_gold's value

...

And this should all compile down to have no overhead as compared with 
the same operations written in straight C.

That is to say, if you get it wrong nowadays with modern C++ the 
"donkey" is _you_. It's the programmer's job to write sane code, not for 
the compiler to divine what it thinks you mean.

[toc] | [prev] | [next] | [standalone]


#473842

FromNeon John <no@never.com>
Date2017-08-18 10:02 -0400
Message-ID<ccsdpclieljqop80079mfmd889biqj5305@4ax.com>
In reply to#473817
On 18 Aug 2017 09:14:33 GMT, Terry Porter <terry@tjporter.com.au>
wrote:


>> 312 bytes for GCC on that target seems gigantic, regardless. That was
>> with the -Os size flag, yeah?
>
>No, because while -Os does make the binary smaller, it optomizes away the 
>blinking, a common hardware issue.

Declare the variable volatile and it won't be optimized away.

Putting my business hat on now, there is no way I'd pay someone to
write a non-trivial application in asm.  It would require a true
expert in the particular processor I use and the expense that goes
with such a person.  It would be a nightmare to maintain after the
uber-programmer moves on to his next project.

OTOH, an average or slightly above-average C programmer can write the
app in a fraction of the time and let the compiler make the code fast
and small.  All I care about as a businessman is that the code fit in
available flash and run adequately fast.

The rule here is that if a programmer wants to use some asm, he must
first write a business justification for the code.  That's not
happened in many years.

John
John DeArmond
http://www.neon-john.com
http://www.tnduction.com 
Tellico Plains, Occupied TN
See website for email address

[toc] | [prev] | [next] | [standalone]


Page 3 of 5 — ← Prev page 1 2 [3] 4 5  Next page →

Back to top | Article view | sci.electronics.design


csiph-web