Heater
Posts: 10312
Joined: Tue Jul 17, 2012 3:02 pm

Re: Assembly - any use in teaching it?

Sat Jul 06, 2013 5:48 pm

Interesting thread. I have not read all of it as it's getting rather long. So sorry if what I say has come up previously:

1) Assembly language, or should I say knowing a machine architecture and instruction set, is not "just another tool". It is the tool. Everything else rests on it. It's not like making a choice between C or Pascal or Python.

2) As such teaching assembler is important. I'm sure there will people wanting to invent new languages, compilers and tools in the future. They will need to be familiar with such things.

3) Assembler is not so hard. Kids were getting to grips with Z80 or 6502 assembler back in the 1980's. Why not now?

4) I don't know so much about ARM assembler but if I was in a position to teach some assembler I would do it with something like a Propeller MCU from Parallax Inc. It is about the simplest most elegant assembly language ever. Being an MCU there is an immediate connection between outputting to a port and seeing that LED light up, which is always a good start.

User avatar
morphy_richards
Posts: 1603
Joined: Mon Mar 05, 2012 3:26 pm
Location: Epping Forest
Contact: Website

Re: Assembly - any use in teaching it?

Thu Sep 05, 2013 9:37 am

I'm going to have a go at this with my GCSE class in next weeks practical.
The theory lesson this week will consist of an introduction to the ALU, logical operators and a binary half adder.
We will also cover registers, controller and buses.

Next week I'm planning a practical using RISCOS to reinforce the theory. Something along the lines of how a compiler converts simple lines like / and what the processor actually does with lines like...

Code: Select all

If A !=  B {}

Code: Select all

C=A+B
etc

...by getting the students to reconcile this with the ALU logic and arithmetic functions and memory addressing they have learned about.

This is well out of my field of expertise. I vaguely remember doing some 8086 assembler in 1996, but should be able to muddle something together by next week.

Does anyone have any suggestions?

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

Re: Assembly - any use in teaching it?

Sun Sep 15, 2013 7:03 am

morphy_richards wrote:how a compiler ... This is well out of my field of expertise ... Does anyone have any suggestions?
Read Abdulaziz Ghuloum's An Incremental Approach to Compiler Construction. It's remarkably simple - a compiler is merely (sequence of) a source->source transform(s).

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

Re: Assembly - any use in teaching it?

Mon Sep 16, 2013 8:24 pm

I know that I have a different view than most, this said:
For me assembler is easier to implement, debug, and understand later (or if written by another) than most HLLs. Further I see more and more kids between 10 and 14 doing assembler projects with out any introduction to an HLL (and before any one sais it YES C IS AN HLL), I have even seen a couple of articles on kids that have designed there own simple CPU and written an assembler, Monitor, and simple operating system for them in Machine Language with some Assembly.

So why is there this perception of Assembler being difficult? It seems that kids pick it up more quickly than C.

Personaly I think that the problem is preconception. Once you have been told that it is harder for long enough you believe it so deeply that when you learn it you naturally resist do to the existing mental bariers, and your preconception keeps you from ever having an easy time of it. To my point is the fact that these kids that have not yet been taught that Asm is supposed to be dificult find Asm to be simple and intuitive. And I find this to be so as well, and I learned asm young.
The Raspberry Pi is an ARM computer, that runs many Operating Systems, including Linux, RISC OS, BSD, Pi64, CP/M as well as many more.
Soon to add AROS to the list of operating systems.

neuromancer
Posts: 8
Joined: Fri Sep 21, 2012 7:47 pm
Location: Bedford
Contact: Website

Re: Assembly - any use in teaching it?

Wed Sep 18, 2013 8:52 pm

polas wrote:As a follow on from the BASIC thread, an interesting debate has been going on about the merits of teaching assembly language - which isn't entirely off topic because some flavours of BASIC readily support mixing this in amongst the higher level code.

Whilst it can on the one hand provide a more complete view of how machines work and code is executed, do people think there is there really sufficient merit to teach programming in depth at the lower levels?

Bearing in mind that a good proportion of those people learning to code on the RPi today will become tomorrow's software engineers, and likely be programming in some higher level language; Do people think that by learning assembly code these people would have a significant advantage over those who come straight in at the higher level?

Or alternatively, could teaching at this lower level in fact ever be harmful to one's ability to formulate and write maintainable, efficient solutions to problems?
Well back in the 70's in my CSE! class the first language taught was CECIL which was effectively a training version of Assembly

psutton
Posts: 169
Joined: Thu Jan 12, 2012 10:45 pm
Location: Devon
Contact: Website

Re: Assembly - any use in teaching it?

Mon Sep 23, 2013 11:49 am

polas wrote:As a follow on from the BASIC thread, an interesting debate has been going on about the merits of teaching assembly language - which isn't entirely off topic because some flavours of BASIC readily support mixing this in amongst the higher level code.

I am sure this is the case with RISC/OS / bbc basic

Whilst it can on the one hand provide a more complete view of how machines work and code is executed, do people think there is there really sufficient merit to teach programming in depth at the lower levels?

if you're in a school then maybe suggest running this as an after school club and invite anyone else from local schools to attend, I think that individual schools may have one or two, interested but if you combine everyone in one group you may have a nice group to work with.

Bearing in mind that a good proportion of those people learning to code on the RPi today will become tomorrow's software engineers, and likely be programming in some higher level language; Do people think that by learning assembly code these people would have a significant advantage over those who come straight in at the higher level?

Or alternatively, could teaching at this lower level in fact ever be harmful to one's ability to formulate and write maintainable, efficient solutions to problems?

Not sure at school / college we had hex input boards and looked at machine code, or certainly did when I did a btec first level course in about 1993. It is a different way to approach it, it may not suit everyone and some may drop out but as long as they see it as they have tried it , rather than them feeling they have failed

User avatar
Emanuele
Posts: 174
Joined: Wed Aug 03, 2011 5:28 pm
Contact: Website

Re: Assembly - any use in teaching it?

Wed Sep 25, 2013 11:26 pm

As stated already, I think that Assembly nowadays has its place mostly at University/Secondary level.

The concepts that assembly can help you to grasp and that almost every programmer should know can really be learned in a few sittings. No need to teach it "in depth".

I'm of course biased, but Assembly can be very easy. Assembly 6502 just is. Lots of us learned it as kids. Just try it for yourself, go here: http://jbit.sourceforge.net/doc/tutorial_en.html and here: http://jbit.sourceforge.net/webapp/1.2/ (IE8+ min., IE9 recommended). If you do like what you see, maybe you can even help me and tell me if this: http://sourceforge.net/projects/jbit/fi ... b/download works on a real Raspberry Pi before I release it.

And no, learning assembly will not damage your brain.

psutton
Posts: 169
Joined: Thu Jan 12, 2012 10:45 pm
Location: Devon
Contact: Website

Re: Assembly - any use in teaching it?

Thu Sep 26, 2013 8:46 am

Well back in the 70's in my CSE! class the first language taught was CECIL which was effectively a training version of Assembly[/quote]


You may be interested in what Gordon Henderson has written then, CECIL interpreter for his return to basic interpreter

https://projects.drogon.net/?s=CESIL&x=20&y=17

Hope this helps

SiriusHardware
Posts: 494
Joined: Thu Aug 02, 2012 9:09 pm
Location: UK

Re: Assembly - any use in teaching it?

Thu Oct 10, 2013 5:12 pm

joan wrote:I'd like to know the percentage of software engineers who have ever needed to use assembler for speed reasons. In my own experience that sort of need disappeared decades ago.
I just had to do it about a month ago to get a PIC microprocessor to pretend to be a static RAM fast enough to be read by a visual display unit. Every attempt to write it in 'C' produced too many instructions per step.

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

Re: Assembly - any use in teaching it?

Thu Oct 10, 2013 9:38 pm

I've needed it recently to implement semaphores, because C doesn't give access to locked exchange instructions.

The last time I remember definitely needing it for speed was back with a real IBM PC/AT, which couldn't talk to a 19200 baud UART fast enough without being programmed in assembler. (Using interrupts in DOS, for such trivial work, was generally more trouble than it was worth.) I have used it since for optimising frequently used sections of code, but those have only been to improve throughput generally, not to do something that high-level code was incapable of.

I have recently had to implement stuff that was so fast that even assembler was too slow. In that case I configured an FPGA to be a simple 8-bit computer with specialised instructions, and I programmed that in assembler. So not only did I need to program in assembler, I also needed to understand the process enough to be able to design the instruction set too.

I've probably said before on this thread, that I believe assembler should be taught. However I think the first assembler to be taught should be a simplified one, such as CESIL. Although I think CESIL misses a trick by not having a real machine-code emulator behind it. Maybe it should be base ten instead of base two. In fact my A-level project back in 1979 was to build just such an emulator together with two assemblers and a full set of pupil worksheets. Once the basic understanding of assembler is gained, learning a real assembler is probably still a more advanced topic, suitable for degree or at least advanced A level.

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

Re: Assembly - any use in teaching it?

Fri Oct 11, 2013 1:52 am

Mini SubManual ahead:
Heater wrote:Interesting thread. I have not read all of it as it's getting rather long. So sorry if what I say has come up previously:

1) Assembly language, or should I say knowing a machine architecture and instruction set, is not "just another tool". It is the tool. Everything else rests on it. It's not like making a choice between C or Pascal or Python.

2) As such teaching assembler is important. I'm sure there will people wanting to invent new languages, compilers and tools in the future. They will need to be familiar with such things.

3) Assembler is not so hard. Kids were getting to grips with Z80 or 6502 assembler back in the 1980's. Why not now?
And ARM assembly is a thousand times simpler and more eloquent than those :) .
4) I don't know so much about ARM assembler but if I was in a position to teach some assembler I would do it with something like a Propeller MCU from Parallax Inc. It is about the simplest most elegant assembly language ever. Being an MCU there is an immediate connection between outputting to a port and seeing that LED light up, which is always a good start.
If you like Propeller assembly you will love ARM assembly.

Where do you think that having every instruction be conditional came from? It is from the ARM.

Also on the ARM most instructions support a shift with zero overhead. And only the arm can do that as far as I know.

And the ARM allows you to specify if the flags are effected (sound famillier).

And here is the entire ARM instruction set(Ok there are a few not listed that have to do with things like floating point, and thumb.):

Code: Select all

AND   ;Bitwize and.
EOR   ;Bitwize Exclusive or.
SUB   ;Subtract.
RSB   ;Reverse Subtract.
ADD   ;Add.
ADC   ;Add with carry.
SBC   ;Subtract with carry.
RSC   ;Reverse subtract with carry.
TST   ;Test bits (AND result not written).
TEQ   ;Test for equilivence (EOR result not written).
CMP   ;Compare.
CMN   ;Compare Negated.
ORR   ;Bitwize OR.
MOV   ;Copy data between registors, or an immed to reg.
BIC   ;Bit Clear.
MVN   ;MOV negated.
MUL   ;Multiply.
MLA   ;Multiply and acumulate.
B     ;Branch.
BL    ;Branch and link.
CDP   ;Coprocessor Data Op.
LDC   ;Load from Coprocessor.
LDM   ;Load Multiple Registoes.
LDR   ;Load Register.
LDRB  ;Load Byte to Register.
MCR   ;Coprocessor Registor Transfer (CP to ARM).
MRC   ;Coprocessor Registor Transfer (ARM to CP).
MRS   ;Move Status to Register.
MSR   ;Move Register to status.
STC   ;Coprocessor data transfer.
STM   ;Store Multiple registers.
STR   ;Store register.
STRB  ;Store byte from Register.
SWI   ;Software Interupt.
SWP   ;Swap Register With Mem.
As you can see there are 36 ARM instructions. I do not count THUMB, and floating point is technicaly a coprocessor.

Also there are a few psudo instructions supported by most Assemblers for convenience:

Code: Select all

ADR
ADRL
Shifts are defined by the operand postfixes ROR, RRX, ASL, ASR, LSL, and LSR.

And the condition codes are:

Code: Select all

EQ  ;Equal.
CS  ;Carry set.
CC  ;Carry Clear.
MI  ;Minus.
PL  ;Plus.
VS  ;Overflow set.
VC  ;Overflow Clear.
HI  ;Higher.
LS  ;Lower or same.
LT  ;Less than.
GT  ;Greater than.
LE  ;Less than or equal.
AL  ;Always.
There are 16 user accassable registers, labeled R0 through r15, with R15 being the program counter.

So as you can see it probably would not take you long to learn the ARM. There are few addressing modes making it even simpler, and like the Propeller all instructions are exactly 32bits.
The Raspberry Pi is an ARM computer, that runs many Operating Systems, including Linux, RISC OS, BSD, Pi64, CP/M as well as many more.
Soon to add AROS to the list of operating systems.

andieshandyhandies
Posts: 1
Joined: Sun Sep 04, 2016 10:35 am

Re: Assembly - any use in teaching it?

Mon Sep 05, 2016 9:18 pm

LSL - Left Shift Logical?

When I was 14 the nearest I got to a computer was Teach Yourself Machine Code and similar books from the library.

I did a year and a bit writing Plan assembler using Driver on an ICL190? which was for a online order entry system. About 1975-6. We had to go to the sales office to use a terminal as well. The lad thought the programs were in his terminal!

We had to wait an hour for the Systems programmer to do her 20mins link and test before us developers had a go. She was an Operators partner and had to go and cook his tea. Hand coding screens in Hex was always exciting. Unpaid of course.

I have ordered a RPi 3 to play with. Ordered SH copper heatsinks today to cut up for the SOC. Jbtek énclosure'.

I am coming up to real retirement. I did say I would write an operating system in my retirement. Or dabble in an aspect I suppose. As there are lots of Pis I expect there will be enough help along which ever way I go.

Andrew

W. H. Heydt
Posts: 9266
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: Assembly - any use in teaching it?

Tue Sep 06, 2016 2:39 am

Another necro'd thread from 2013.

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

Re: Assembly - any use in teaching it?

Tue Sep 06, 2016 7:41 am

I'm locking this. It was long enough the first time

Return to “Staffroom, classroom and projects”