User avatar
Jim JKla
Posts: 2219
Joined: Sun Jan 29, 2012 11:15 pm
Location: Newcastle upon Tyne UK

Re: Assembly - any use in teaching it?

Sat Feb 09, 2013 6:02 pm

Sign me up. :D
Noob is not derogatory the noob is just the lower end of the noob--geek spectrum being a noob is just your first step towards being an uber-geek ;)

If you find a solution please post it in the wiki the forum dies too quick

User avatar
aTao
Posts: 1086
Joined: Wed Dec 12, 2012 10:41 am
Location: Howlin Eigg

Re: Assembly - any use in teaching it?

Sat Feb 09, 2013 10:38 pm

Jim JKla wrote:
aTao wrote:Remind me, what are the goals of The Foundation? Is it computer awareness, computer programming or is it as I think computing? (or a nice mixed bag of all three).

Computing requires understanding of electronics, logic, maths, bits, bytes, machine code, assembler, interpreted languages, compiled languages and (I hate to admit) A.I.

To neglect any of these is exactly the failings that The Foundation wish to address.
Wot no formal methods? ;)
Only in the class of "How not to do it" Its just a load of management-speak BS detracting from the real requirement of getting on with the job, a bit like OOP really: no one seems to want to actually DO whats needed.
>)))'><'(((<

User avatar
joan
Posts: 13998
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Assembly - any use in teaching it?

Sat Feb 09, 2013 10:49 pm

...
Only in the class of "How not to do it" Its just a load of management-speak BS detracting from the real requirement of getting on with the job, a bit like OOP really: no one seems to want to actually DO whats needed.
Precisely. You are right. A different opinion.

User avatar
Wizard
Posts: 120
Joined: Sun Aug 19, 2012 4:52 am
Location: Sweden

Re: Assembly - any use in teaching it?

Sat Feb 09, 2013 11:14 pm

Back "in the days" when one had very little to chose from we had cobol, basic, c and assembler to choose from. (well, there were many other languages and dialects but they were specialised)

I wrote my first code in basic on a PET but was told early on that if you wanted to be a real coder (elite was yet to be stated) you only had one choice - assembler!

I first learned 6502 assembler and then jumped on 68k assembler when the first Amiga launched.
After a few years of writing loads-a-code for 68k I started my first professional job as a programmer.
We used an in-house developed CPU, the LM Ericsson APZ, and even if this assembler for this real-time system was way different from the 68k assembler the fundamentals were all the same and I was up and running very fast.

What I try to say is that learning assembler is not so much about learning the instructions or syntax as much as learning the architecture and structure of a CPU or microcontroller. Study CPU architecture and the transition to assembler is much easier.

You have different registers (memory) for data or comparison etc. Some have dedicated registers for (real) pointers where others only use reference pointers. x86 traditionally only have four "usable" registers unless 386 enhanced mode is used, others have 16+16 32 bit registers and a bundle of pointers etc...

If Amiga, or the Motorola 68k-something, still existed I'd recommend learning that architecture and assembler but since it doesn't perhaps x86 assembler is a good place to start?
There's plenty of help out there whereas arm assembler is limited with regards to examples and documentation...

Today I write very little asm because I'm old and lazy but when I need a super-fast function I write inline assembler and use the knowledge I once had and can still churn out really fast stuff.

If you do decide to learn assembler you should know that there are major differences between e.g "normal" assembler and risc assembler. x86 asm and arm asm are very different imho and can be quite confusing initially.

See examples of "Hello World" below.

68k Amiga asm

Code: Select all

        move.l  #DOS
        move.l  4.w,a6
        jsr     -$0198(a6)
        move.l  d0,a6
        beq.s   .Out
        move.l  #HelloWorld,d1

A)      moveq   #13,d2
        jsr     -$03AE(a6)

B)      jsr     -$03B4

        move.l  a6,a1
        move.l  4.w,a6
        jsr     -$019E(a6)
.Out    rts

DOS          dc.b    'dos.library',0
HelloWorld   dc.b    'Hello World!',$A,0


arm asm

Code: Select all

SWI "OS_WriteS"
EQUS "Hello World!"
EQUB 0
ALIGN
MOV PC,R14


x86 (dos) asm

Code: Select all

mov ax,cs
mov ds,ax
mov ah,9
mov dx, offset Hello
int 21h
xor ax,ax
int 21h

Hello:
  db "Hello World!",13,10,"$" 
Later (afaik?) assembler macros started to turn up in order to make it easier/quicker to write common functions but they can add quite a few clock cycles so one should always understand how they work in case you are working on critical code. This has luckily become less of an issue with modern hardware since we no longer measure CPU speed in single MHz digits ;)

Also I might be wrong on some of the mumbling above... It's been a long time since I really used assembler :p

nop
Last edited by Wizard on Sat Feb 09, 2013 11:36 pm, edited 1 time in total.
Raspberry Pi - finally a worthy replacement for A500!!!

User avatar
joan
Posts: 13998
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Assembly - any use in teaching it?

Sat Feb 09, 2013 11:19 pm

Who do the people who write assembler actually work for? That is the question!

User avatar
DavidS
Posts: 4178
Joined: Thu Dec 15, 2011 6:39 am
Location: USA
Contact: Website

Re: Assembly - any use in teaching it?

Sat Feb 09, 2013 11:26 pm

joan wrote:Who do the people who write assembler actually work for? That is the question!
I would say that the question is: Who do they not work for?
RPi = The best ARM based RISC OS computer around
More than 95% of posts made from RISC OS on RPi 1B/1B+ computers. Most of the rest from RISC OS on RPi 2B/3B/3B+ computers

User avatar
joan
Posts: 13998
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Assembly - any use in teaching it?

Sat Feb 09, 2013 11:32 pm

DavidS wrote:
joan wrote:Who do the people who write assembler actually work for? That is the question!
I'm a -1. I think you are a -1. Counting.

User avatar
DavidS
Posts: 4178
Joined: Thu Dec 15, 2011 6:39 am
Location: USA
Contact: Website

Re: Assembly - any use in teaching it?

Sat Feb 09, 2013 11:39 pm

joan wrote:
DavidS wrote:
joan wrote:Who do the people who write assembler actually work for? That is the question!
I'm a -1. I think you are a -1. Counting.
I am a Plus 1. What other language wuld you write maintainable system level code in?

Unless I take the time to create a Pascal Compiler that can fulfill the task (or maybe a BBC BASIC V compatible BASIC Compiler), Assembly is the only way to go at the sysem level.
RPi = The best ARM based RISC OS computer around
More than 95% of posts made from RISC OS on RPi 1B/1B+ computers. Most of the rest from RISC OS on RPi 2B/3B/3B+ computers

User avatar
joan
Posts: 13998
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Assembly - any use in teaching it?

Sat Feb 09, 2013 11:46 pm

I'm not sure what other language you would write code in, maintainable or otherwise.

I think I'd like to know what Linux, Basic, Python, and all the Gnu software is written in. Could you find out?

User avatar
DavidS
Posts: 4178
Joined: Thu Dec 15, 2011 6:39 am
Location: USA
Contact: Website

Re: Assembly - any use in teaching it?

Sun Feb 10, 2013 12:08 am

joan wrote:I'm not sure what other language you would write code in, maintainable or otherwise.

I think I'd like to know what Linux, Basic, Python, and all the Gnu software is written in. Could you find out?
Linux and most GNU software is written in C, same for X. BBC BASIC V is written in assembly, some BASICs are written in BASIC, some BASICs are writte in C, I have no clue what Python is written in.

Though as most of us know well (to well), Linux is far from easy to maintain, I would agree with Linus that since it has grown out of control it is unmaintainable (and that is just the Kernel + core modules [most of which was added by others than Linus]). I am trying to remmember where to point you to for a reference, though I am not remembering at this moment (will attempt to remember to post when I do).
RPi = The best ARM based RISC OS computer around
More than 95% of posts made from RISC OS on RPi 1B/1B+ computers. Most of the rest from RISC OS on RPi 2B/3B/3B+ computers

User avatar
DexOS
Posts: 876
Joined: Wed May 16, 2012 6:32 pm
Contact: Website

Re: Assembly - any use in teaching it?

Sun Feb 10, 2013 12:26 am

I think some people are mixing training and work place programming.
Its not the same.
Example: when you go for a programming job, these days they want a degree.
Now that degree does not after to be in computer science, it could be in maths.
That because they will train you anyway and only want to see that you have ability to learn.
So we are not training kids for the jobs them selfs, but we need to train kids to understand how computers work at a low level.
This does not mean do the job as fast as possible like in a work environment, but more having a full understanding of how it all works.
Teaching computer programming with higher level languages, is like teach electronics by saying push the switch and the light comes on, but not go into why the light comes on.

Lets put it another way, if you new everything you know now as far as programming goes, but you also had a good knowledge of assembly programming, would that knowledge help you get a better job ?.
Batteries not included, Some assembly required.

pygmy_giant
Posts: 1562
Joined: Sun Mar 04, 2012 12:49 am

Re: Assembly - any use in teaching it?

Sun Feb 10, 2013 12:50 am

The Marxist Theory of education is that what educational institutions in a capitalist society really teach is how to be compliant and that the learned subject itself is a just a means to that end.

Thats a bit conspiratorial for me but proof of having learned to learn is perhaps what employers really look for. Actual knowledge and experience itself does seem under-rated these days - especially as we all have information on tap. I think this is a mistake as without knowledge as a hook to hang other facts on, I don't think anyone can really understand or retain what they learn.

I keep daring myself to learn some low level stuff to better understand the higher level things that I have been using. If I understand what the computer actually has to do and how it works, I will probably better understand why HL stuff is organised the way it is.

Comming at it the other way around, if kids get a flavour of assembler early on they at the very least will appreciate HL more and perhaps learn the tricky bits like pointers more easily.

User avatar
DavidS
Posts: 4178
Joined: Thu Dec 15, 2011 6:39 am
Location: USA
Contact: Website

Re: Assembly - any use in teaching it?

Sun Feb 10, 2013 1:59 am

pygmy_giant wrote:The Marxist Theory of education is that what educational institutions in a capitalist society really teach is how to be compliant and that the learned subject itself is a just a means to that end.

Thats a bit conspiratorial for me but proof of having learned to learn is perhaps what employers really look for. Actual knowledge and experience itself does seem under-rated these days - especially as we all have information on tap. I think this is a mistake as without knowledge as a hook to hang other facts on, I don't think anyone can really understand or retain what they learn.

I keep daring myself to learn some low level stuff to better understand the higher level things that I have been using. If I understand what the computer actually has to do and how it works, I will probably better understand why HL stuff is organised the way it is.

Comming at it the other way around, if kids get a flavour of assembler early on they at the very least will appreciate HL more and perhaps learn the tricky bits like pointers more easily.
Well that s good. There are a few good books on CPU design, a good starting point may be the DLX. See:
http://wikipedia.org/wiki/DLX
There are some real hardware implementations, though still a hoby design. It is simple by design as it is designed for education, and it is a very simular architechure to the ARM (though a lot simpler than the ARM that we use).

I can not say for sure what the absolute best pace to begin is as I did my first hobby CPU back in 1990 when I was 12 years old. It was a crude 16-bit RISC design with 8 user registers(R0 through R7, R7 being PC) and a 12 bit address space, it did use a simple 3 stage pipeline in its second versiona year later. The instruction set heavily influenced by the PDP-11.
RPi = The best ARM based RISC OS computer around
More than 95% of posts made from RISC OS on RPi 1B/1B+ computers. Most of the rest from RISC OS on RPi 2B/3B/3B+ computers

User avatar
Wizard
Posts: 120
Joined: Sun Aug 19, 2012 4:52 am
Location: Sweden

Re: Assembly - any use in teaching it?

Sun Feb 10, 2013 10:49 am

DexOS covered it well by explaining "in order to understand structured programming you must know what's under the hood..." Well, not exactly in those words but roughly ;)

This is the whole truth behind why people should still learn assembler!

I never went to university and I dropped out of school very early in order to work instead. All the long night programming assembler for 6502 and 68k gave me such a headstart that I was very sought after in the professional market. (not saying this is the way to do it by the way...)
When we employed new programmers we often had to invest many years in order to get them really productive. They came directly from university and all had degrees but knew very little with regards to real-time programming and fault tolerance.
I was asked to make a course in order to speed up the learning curve and I can still today remember one exercise.

- Whats the difference in using IF, IF ELSIF, and CASE. (yes, we spelled elsif that way in the language we used ;))
Baring in mind that we wrote time critical code and clock cycles were expensive - especially in loops!

Almost everyone attending the course used IF ELSIF since the code looked better and the conditions were few... Wrong!

When written in assembler the if elsif statements generated loads of overhead which added way too many clock cycles where the case statement only generated a few jmp instructions to the various memory addresses it would jump to and by ordering them into the most common jump first we reduced the clock cycles to a bare minimum.

By knowing the expected assembler output whilst writing the code in high level language we could control the code in a much better way!
So by learning assembler we could understand why we write C in a certain way and what to avoid - hence make writing assembler unimportant!

We never used pre-compilers in my days in order to fully control the output but they have become much better today and we have better hardware but why is most modern software so demanding? Well, we reuse so much that we have to import/inherit a lot of dead/unused code in order to implement the most basic thing.

If you want something fast then re-invent the wheel but be aware of the maintenance costs. Code is way more expensive than hardware but often I find that spending more money on the right code will in the end be cheaper.

I wrote assembler on a daily basis for more than 10 years before resorting to higher positions and today I no longer officially write code but I still maintain my knowledge and curiousness by tinkering at home with various projects and knowing assembler is key to debug code.

It was asked who was writing assembler at the job? Previously almost all redundant real-time systems in telecom (MSC, BSC, HLR etc) was written in either assembler or a mid-level language that only generated assembler. Those systems had no OS and were true bare metal. Today we replace code quality with faster hardware and redundant hardware in order to handle crashes...

IMHO everyone that wants to learn how to become a really good programmer must learn assembler in order to understand the code and to debug but will not use it for writing software.
OOD killed programming as far as I'm concerned... :D
Raspberry Pi - finally a worthy replacement for A500!!!

mikerr
Posts: 2768
Joined: Thu Jan 12, 2012 12:46 pm
Location: UK
Contact: Website

Re: Assembly - any use in teaching it?

Sun Feb 10, 2013 11:19 am

It's a balance.

Hard core assembly coders can produce unmaintainable code when they use other languages, and end up rewriting functions all the time "but its faster"
by contrast some OOP/High level language taught programmers produce "pretty" code with an object for everything - but wildly inefficient.

I've had nightmares on both sides when taking over projects.

I think assembly should be taught, but after a high level language - early on though.

I wonder how much "your first language(s)" influence later skills - are we subconsciously translating everything back into that language when coding in others ?
Android app - Raspi Card Imager - download and image SD cards - No PC required !

AMcS
Posts: 184
Joined: Sun Jan 06, 2013 11:23 am
Location: Dublin, Ireland

Re: Assembly - any use in teaching it?

Sun Feb 10, 2013 11:57 am

joan wrote:Who do the people who write assembler actually work for? That is the question!
That sounds suspiciously like the only reason to learn/do something is if it's beneficial in getting a job.

Thing is any programming language a school age child learns now will either be well obsolete by the time they get to university - or if not it'll be "depreciated" or radically changed by the time they graduate. So aiming today to educate someone in skills that will help them to work in a jobs market 10-12 years ahead is apt to fail.

It's arguably better to give the student the opportunity to learn as broadly as possible. I'd disagree with the notion of prescriptive education - the fact that things like BASIC (or at least "structured BASICs like BBC BASIC, Brandy et al) and Assembler don't have their own section in the RaspberryPi forums while Python, Scratch and C get the attention is a bit limiting (who's going to get a job programming in Scratch is never asked I note).

As to Assembler specifically if someone wants to learn it, or might appear "amenable" to it - then let them - facilitate them where possible. In 10-12 years time it'll be just as irrelevant to them getting a job as the others - what it does however is demand care and forethought something sadly lacking (I fear) in those who only know high level, object oriented languages. You get something wrong in Assembler *it bites!*

User avatar
rurwin
Forum Moderator
Forum Moderator
Posts: 4258
Joined: Mon Jan 09, 2012 3:16 pm
Contact: Website

Re: Assembly - any use in teaching it?

Sun Feb 10, 2013 12:12 pm

There's an old saw that states "A good programmer can write FORTRAN code in any language". It generally takes an afternoon to learn the basics of any new language, but rather longer before you are writing in that language and not translating tropes from some other.

I'm with you, mikerr; I believe the first taught language should be high-level, but that assembler in some form should be introduced fairly soon. I don't believe young teenagers should be exposed to ARM assembler, or be expected to use it for extended projects. What they need at that point is an appreciation of how the code they write is executed by the computer. Probably the appreciation of what is, or is not, efficient coding, comes somewhat later, maybe in A-level or undergraduate courses, and introduces a real assembler and complex algorithms. The initial exposure to the assembler concept feeds in to learning about computer architecture, forms a connection between that and high-level languages and lays the foundation for an in-depth treatment later. In the interim it can be used to vaguely explain efficient coding techniques, but a full treatment IMHO, has to wait until later.

Maybe I should re-create my A-level project: a decimal virtual machine, with a decimal instruction code, with an assembler provided.

User avatar
Jim JKla
Posts: 2219
Joined: Sun Jan 29, 2012 11:15 pm
Location: Newcastle upon Tyne UK

Re: Assembly - any use in teaching it?

Sun Feb 10, 2013 12:33 pm

My first computer language was Sinclair Basic but I had to jump to Assembler to get any degree of speed.

My first real language was Geordie but before long I had to learn English that does not stop the Geordie from being useful from time to time. ;)
Noob is not derogatory the noob is just the lower end of the noob--geek spectrum being a noob is just your first step towards being an uber-geek ;)

If you find a solution please post it in the wiki the forum dies too quick

haughtonomous
Posts: 4
Joined: Fri Nov 04, 2011 7:33 pm

Re: Assembly - any use in teaching it?

Sun Feb 10, 2013 2:33 pm

Back at the dawn of time, when I was learning my trade I graduated from a ZX81 to an Acorn Atom, the Atom BASIC interpreter in which had an inline 6502 Assembler. For the fun and the sheer interest of it I spent a great deal of time writing (and examining other peoples') routines in assembler code instead of the easier and much more concise BASIC equivalents, and as a consequence I learned a great deal about how computers actually work, and it also taught me to be very careful in devising code, not to mention the importance of efficient code. Although 6502 assembler has never been of any direct use in my day job, today as a fairly seasoned C# developer I still find it valuable being able to understand what is going on behind my high level OO code.

Teach assembler - it will never be a wasted exercise!

User avatar
johnbeetem
Posts: 945
Joined: Mon Oct 17, 2011 11:18 pm
Location: The Mountains
Contact: Website

Re: Assembly - any use in teaching it?

Mon Feb 11, 2013 8:43 pm

There are a number of good reasons for learning ASM. First, if you're going to call yourself a Computer Scientist, IMO you should know what computers really do, which means you have to know what they're doing at the machine level. IMO an expert in any field should know how things work at least one or two levels below where he or she normally works. For example, a logic designer should be very familiar with MOS transistor circuits so that circuit-level problems such as bus contention and ground bounce are not mysterious, and it really helps to be familiar with MOS device theory so that device-level issues such as MOS saturation mode aren't a total mystery. Quantum mechanics, OTOH, is probably not needed.

I say people who call themselves Computer Scientists should have mastered ASM at some point in their educations. After all, how can you expect someone to write a compiler if he or she hasn't been one for a while? It's like calling yourself a Mathematician without having done epsilon-delta proofs in calculus.

Now if you just want to be a hack programmer and write inefficient web software, you don't need to master ASM. If you're only working at the application program level using a language that totally hides the machine from you, then you don't need to master ASM. However, if you write in C you really do need to have at least a smattering of ASM because C is executed at the machine-language level and some bugs can only be understood at the machine-language level.

I've done a lot of embedded programming, where you're programming at the bare metal. Almost all of the code is in C. But I have needed ASM on occasion:

1. Critical sections: if you have variables shared between multiple processes, or between a main thread and interrupt service routines, you may need to ensure that interrupts do not occur when updating those variables. Calling functions to do this is expensive, while writing inline ASM macros may do the job very efficiently.

2. OTOH, your compiler may decide that ASM macros should follow the same register usage conventions as functions and end up saving and restoring registers that don't need to be. I had a few critical leaf functions I rewrote in ASM so they could make better use of registers and saw a noticable performance improvement.

3. Compilers do occasionally have bugs. Sometimes the easiest way to verify that the compiler has a bug is to list ASM source code generated by the compiler. Sure, you could upgrade the compiler -- and get a different set of bugs.

4. Sometimes a compiler generates "correct" code, but optimizations do unexpected things. I once had an interrupt service routine that swapped the order of execution of some memory accesses and created an incredibly hard-to-reproduce bug. We had forgotten to declare some variables "volatile" so the compiler went and reordered them. However, it wasn't clear what happened until we looked at the ASM.

5. Sometimes you have issues porting code from one machine to another. We had a product that was running fine using 68000 architecture but interrupt handlers failed unpredictably on PowerPC. It turned out the problem was that we had some counters implemented as memory variables. The 68000 could increment or decrement a memory location as a single instruction. The PowerPC -- a RISC machine -- incremented memory using a sequence of instructions: load, inc/decrement register, store. This sequence had to be made non-interruptable to function correctly on PowerPC.

Isn't this fun? Aren't you glad you know ASM?

User avatar
rurwin
Forum Moderator
Forum Moderator
Posts: 4258
Joined: Mon Jan 09, 2012 3:16 pm
Contact: Website

Re: Assembly - any use in teaching it?

Mon Feb 11, 2013 9:27 pm

johnbeetem wrote:The 68000 could increment or decrement a memory location as a single instruction. The PowerPC -- a RISC machine -- incremented memory using a sequence of instructions: load, inc/decrement register, store. This sequence had to be made non-interruptable to function correctly on PowerPC.
And then you move it to a multi-core machine, and even the single increment/decrement instruction with interrupts disabled can fail. That's why the x86 instruction set has the LOCK prefix, and good luck finding a high level language that allows you to specify its use. If you need it, you have to code in assembler.

People keep saying that C is almost assembler. It ain't so, and there's the proof. "volatile" gets you closer to the hardware than most other languages, but sometimes you need to get closer. And just because the language allows you to write efficient looking code, it doesn't mean the code is efficient. I've seen a compiler take "x += y" and calculate the address of x twice, and it was a complex array access so non-trivial. OK, when I switched on optimisation it got it right, but it would have worked just as well with "x = x + y".

User avatar
johnbeetem
Posts: 945
Joined: Mon Oct 17, 2011 11:18 pm
Location: The Mountains
Contact: Website

Re: Assembly - any use in teaching it?

Tue Feb 12, 2013 6:23 pm

rurwin wrote:... I've seen a compiler take "x += y" and calculate the address of x twice, and it was a complex array access so non-trivial. OK, when I switched on optimisation it got it right, but it would have worked just as well with "x = x + y".
Yikes! That's a compiler error. What if the calculation of x has a side-effect, like "*p++ += y" where "p" points to the memory location you want to increment?

Bakul Shah
Posts: 312
Joined: Sun Sep 25, 2011 1:25 am

Re: Assembly - any use in teaching it?

Tue Feb 12, 2013 6:30 pm

johnbeetem wrote:
rurwin wrote:... I've seen a compiler take "x += y" and calculate the address of x twice, and it was a complex array access so non-trivial. OK, when I switched on optimisation it got it right, but it would have worked just as well with "x = x + y".
Yikes! That's a compiler error. What if the calculation of x has a side-effect, like "*p++ += y" where "p" points to the memory location you want to increment?
A compiler is allowed to make that transformation only if it can prove that the semantics are not changed. For that reason "*p++ = *p++ + y" can't be converted to "*p++ += y".

User avatar
johnbeetem
Posts: 945
Joined: Mon Oct 17, 2011 11:18 pm
Location: The Mountains
Contact: Website

Re: Assembly - any use in teaching it?

Tue Feb 12, 2013 7:39 pm

Bakul Shah wrote:
johnbeetem wrote:
rurwin wrote:... I've seen a compiler take "x += y" and calculate the address of x twice, and it was a complex array access so non-trivial. OK, when I switched on optimisation it got it right, but it would have worked just as well with "x = x + y".
Yikes! That's a compiler error. What if the calculation of x has a side-effect, like "*p++ += y" where "p" points to the memory location you want to increment?
A compiler is allowed to make that transformation only if it can prove that the semantics are not changed. For that reason "*p++ = *p++ + y" can't be converted to "*p++ += y".
I'm concerned about the opposite. I want to be sure that the compiler doesn't increment "p" twice when compiling "*p++ += y". It sounds like Rurwin's compiler might do this, depending on optimization options.

tufty
Posts: 1456
Joined: Sun Sep 11, 2011 2:32 pm

Re: Assembly - any use in teaching it?

Tue Feb 12, 2013 8:26 pm

johnbeetem wrote:I'm concerned about the opposite. I want to be sure that the compiler doesn't increment "p" twice when compiling "*p++ += y". It sounds like Rurwin's compiler might do this, depending on optimization options.
Again, Bakul's assertion holds. It would be a bug for a compiler to convert *p++ += y to *p++ = *p++ + y (or vice versa) in any case. It changes the semantics, and is incorrect. The same is not the case for x += y (in most cases).

Return to “Staffroom, classroom and projects”