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

Re: Assembly - any use in teaching it?

Sat Feb 16, 2013 7:46 pm

pygmy_giant wrote:In the future, when people have flying cars, all computers will have dual core FPGAs instead of CPUs - these will be capable of re-configuring each other and the memory which will also be a giant FPGA which will allow them to remember what they were doing before you switched them off when you switch them back on again.

This means that people will be able to download and update their architecture and won't have to bother saving stuff.

You wait and see.
You're right about it happening when (lots of) people have flying cars -- and keep flying pigs as pets as well.

The main thing holding back FPGAs IMO is that none of the FPGA vendors will release their architectures so you're stuck using their tools. This makes reconfigurable computing impractical and makes sure that people who could make advances in reconfigurable computing work on other things instead.

Imagine if Intel and Motorola and ARM etc., etc. had refused to open their architectures and only allowed you to use their compilers. Anyone for PL/M?

JMO/YMMV

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

Re: Assembly - any use in teaching it?

Sat Feb 16, 2013 10:31 pm

TIAMSLA - Perhaps a hybrid aproach with an FPGA layer replacing the board beneath an array of other dedicated silicon parts would be more realistic. Cant think of an application though, other than testing and comparing layouts.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 20753
Joined: Sat Jul 30, 2011 7:41 pm

Re: Assembly - any use in teaching it?

Sun Feb 17, 2013 1:31 pm

johnbeetem wrote:
pygmy_giant wrote:In the future, when people have flying cars, all computers will have dual core FPGAs instead of CPUs - these will be capable of re-configuring each other and the memory which will also be a giant FPGA which will allow them to remember what they were doing before you switched them off when you switch them back on again.

This means that people will be able to download and update their architecture and won't have to bother saving stuff.

You wait and see.
You're right about it happening when (lots of) people have flying cars -- and keep flying pigs as pets as well.

The main thing holding back FPGAs IMO is that none of the FPGA vendors will release their architectures so you're stuck using their tools. This makes reconfigurable computing impractical and makes sure that people who could make advances in reconfigurable computing work on other things instead.

Imagine if Intel and Motorola and ARM etc., etc. had refused to open their architectures and only allowed you to use their compilers. Anyone for PL/M?

JMO/YMMV
Interesting that the Arm compiler from Arm costs a LOT of money - and significantly outperforms (or did a year ago) the GCC compiler in resulting speed of execution and program size. So although Arm do OS the instructions set, it shows that a bit of in house knowledge goes a long way when writing compilers.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Please direct all questions to the forum, I do not do support via PM.

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

Re: Assembly - any use in teaching it?

Sun Feb 17, 2013 5:52 pm

jamesh wrote:Interesting that the Arm compiler from Arm costs a LOT of money - and significantly outperforms (or did a year ago) the GCC compiler in resulting speed of execution and program size. So although Arm do OS [Open Source] the instructions set, it shows that a bit of in-house knowledge goes a long way when writing compilers.
It's hard to optimize for the ARM instruction set. In particular, I've heard that GCC at one time did not do a good job of taking advantage of ARM conditional execution bits and instead generated conditional branches. Recent ARM processors have long pipelines, so conditional branches are very expensive. It's an interesting optimization problem to decide when it's better to use conditional execution. It's obviously good for computing min, max, and absolute value, but the general case may be hard.

It's also interesting to see who the customers are for ARM. Until recently, most ARMs have been in cell phones which are very cost-sensitive. There's a huge advantage in having tightly tuned code that allows you to get away with a cheaper processor and less memory. Also, with a cell phone you're writing one program that runs on one particular processor, so you can tune the code to work optimally with that processor's pipeline. I believe that one of the big things you're getting with ARM compilers is top-notch performance analysis so you can find bottlenecks and fix them. When you're writing code that will run in 10 million cell phones, an expensive ARM compiler pays for itself pretty quickly if it allows you to use a cheaper processor and less memory.

With GCC, you're trying to generate generic ARM code that runs on ARMv5 and newer. I don't know how much it considers the pipeline properties of the specific architecture.

Now that ARM is hitting servers, desktops, and laptops -- in large part thanks to RasPi -- there's an incentive to make GCC generate better ARM code.

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

Re: Assembly - any use in teaching it?

Sun Feb 17, 2013 6:01 pm

jamesh wrote:We use large FPGA devices when developing the next generation GPU chips. The whole GPU is testing in FPGA (the boxes are really quite large ie they have wheels, as we need somewhat more than 200k gates) prior to tapeout so we know they 'work' before spending $750k on masks etc.
If you're only 200K gates, can't you get by with a single FPGA chip nowadays? For example, a Spartan-3A XC3S400A has "400K gates" and is a modest part -- there are much bigger parts "for a few dollars more". My guess is that you probably need more RAM than fits in the FPGA. Or maybe you're still using an FPGA emulator box with parts from several generations ago?

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 20753
Joined: Sat Jul 30, 2011 7:41 pm

Re: Assembly - any use in teaching it?

Sun Feb 17, 2013 7:01 pm

johnbeetem wrote:
jamesh wrote:We use large FPGA devices when developing the next generation GPU chips. The whole GPU is testing in FPGA (the boxes are really quite large ie they have wheels, as we need somewhat more than 200k gates) prior to tapeout so we know they 'work' before spending $750k on masks etc.
If you're only 200K gates, can't you get by with a single FPGA chip nowadays? For example, a Spartan-3A XC3S400A has "400K gates" and is a modest part -- there are much bigger parts "for a few dollars more". My guess is that you probably need more RAM than fits in the FPGA. Or maybe you're still using an FPGA emulator box with parts from several generations ago?
I wrote "somewhat more than 200k gates". It's actually considerably more, but I'm not allowed to say how many. The box the FPGA's live in is about 75cm cube. You can use it as a seat. It might be an old one. Guy on desk next to me has another device, which is about the size of a desktop.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Please direct all questions to the forum, I do not do support via PM.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 20753
Joined: Sat Jul 30, 2011 7:41 pm

Re: Assembly - any use in teaching it?

Sun Feb 17, 2013 7:10 pm

johnbeetem wrote:
jamesh wrote:Interesting that the Arm compiler from Arm costs a LOT of money - and significantly outperforms (or did a year ago) the GCC compiler in resulting speed of execution and program size. So although Arm do OS [Open Source] the instructions set, it shows that a bit of in-house knowledge goes a long way when writing compilers.
It's hard to optimize for the ARM instruction set. In particular, I've heard that GCC at one time did not do a good job of taking advantage of ARM conditional execution bits and instead generated conditional branches. Recent ARM processors have long pipelines, so conditional branches are very expensive. It's an interesting optimization problem to decide when it's better to use conditional execution. It's obviously good for computing min, max, and absolute value, but the general case may be hard.

It's also interesting to see who the customers are for ARM. Until recently, most ARMs have been in cell phones which are very cost-sensitive. There's a huge advantage in having tightly tuned code that allows you to get away with a cheaper processor and less memory. Also, with a cell phone you're writing one program that runs on one particular processor, so you can tune the code to work optimally with that processor's pipeline. I believe that one of the big things you're getting with ARM compilers is top-notch performance analysis so you can find bottlenecks and fix them. When you're writing code that will run in 10 million cell phones, an expensive ARM compiler pays for itself pretty quickly if it allows you to use a cheaper processor and less memory.

With GCC, you're trying to generate generic ARM code that runs on ARMv5 and newer. I don't know how much it considers the pipeline properties of the specific architecture.

Now that ARM is hitting servers, desktops, and laptops -- in large part thanks to RasPi -- there's an incentive to make GCC generate better ARM code.
A Nokia project I worked on used RVDS (The Arm supplied dev kit). I think a more recent project I've been working on (not Nokia) uses gcc, but not sure.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Please direct all questions to the forum, I do not do support via PM.

rplantz
Posts: 66
Joined: Sun Jul 01, 2012 2:38 am

Re: Assembly - any use in teaching it?

Sat Mar 16, 2013 6:05 pm

Interesting thoughts in this thread. I was an assembly language programmer for a dozen years before going into teaching computer science at a university in 1983. I did that for 21 years, teaching assembly language and many other topics. The "highest level" class I taught was systems analysis.

I wrote a textbook, Introduction to Computer Organization with x86-64 Assembly Language and GNU/Linux (first seven chapters available free at bob.cs.sonoma.edu), that shows my take on the importance of teaching assembly language:
1. You should avoid writing in assembly language, except when it's necessary to solve the problem.
2. You cannot know when it's necessary without having at least a general idea of how assembly language works.
3. In any field, having at least a rough understanding of how things work at the next lower level makes you better in that field. For example, a pianist does not need to know how to build a piano, but understanding how they work probably makes for a better pianist.
4. The easiest way to learn something new is to build on what you already know.
Another reason for studying assembly language is that a student will never know whether he or she likes it or not until he or she learns it. Exploring new things, in my view, is one of the most important aspects of education.

With these points in mind, in my book I:
1. Introduce a programming concept in C.
2. Look at the assembly language generated by the compiler and discuss how it works.
3. Show and discuss how I would implement it directly in assembly language.
4. Use a very small subset of the instruction set, just enough to implement the particular concept under discussion.
5. Avoid the complications of I/O by using the C standard library (printf, scanf) for terminal I/O.

Although my book is aimed at university students with an introductory programming course already completed, I believe it could also serve as a "primer" for those who already know the concepts in another architecture but wish to learn 64-bit x86 (Changed from "ARM" on 3/18/13. I am starting an RPi (ARM) version of my book, hence my error).

By the way, several people in this thread have suggested learning these concepts in a simplified "toy" architecture. I once taught a systems programming class based on an idealized, contrived architecture. Students were very bored, knowing that they would never see such a machine. My approach is to use simple examples, which employ a subset of the instruction set on a real machine. We all know that the x86-64 is ugly, but it has mov, cmp, add, sub, etc., and these are sufficient to illustrate what I believe to be the important concepts.

I am very interested in porting my book to the Raspberry Pi environment. I am trying to decide the best way to do this. My current book is probably a bit too much for many kids who will be using the RPi. One thought is to distill out the main programming parts of the book, rewrite them in html, and post them on my website. Any thoughts about this would be greatly appreciated.
Last edited by rplantz on Mon Mar 18, 2013 2:51 pm, edited 1 time in total.

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

Re: Assembly - any use in teaching it?

Mon Mar 18, 2013 5:08 am

Very interesting post rplantz, i have not read your book, but will take a look.
I like the "Use a very small subset of the instruction set", as i used a sub set of the x86 instruction set, to code my x86 OS, which included everything from gui, to full tcp/ip stack, i thought it would be easier for people to understand how it works.

I will take a look at your book and will try to add my thoughts on the matter.
Batteries not included, Some assembly required.

rplantz
Posts: 66
Joined: Sun Jul 01, 2012 2:38 am

Re: Assembly - any use in teaching it?

Mon Mar 18, 2013 3:00 pm

DexOS wrote:I will take a look at your book and will try to add my thoughts on the matter.
Thank you, DexOS. Please note that I made a mistake when I said that my current book could serve as a "primer" to learning ARM. I should have said 64-bit x86. I have just started writing a version of my book for the RPi, which will use the same principles to introduce the ARM instruction set, hence my mistake.

I look forward to hearing any comments you have.

BTW, the format of my new book will probably be very different. My current one is written in LaTeX, which makes beautiful pdf and print, but it's less accessible. I'm experimenting with writing the new one in restructuredtext and using sphinx to process this source into html, epub, and pdf. This will limit the typography.

mvbii
Posts: 1
Joined: Wed Jun 12, 2013 8:34 am

Re: Assembly - any use in teaching it?

Wed Jun 12, 2013 9:25 am

I first learned PDP-8 assembler (key in the boot loader, then start up your KSR33 to load the assembler and your code), Next I convinced my boss that I thought I could control the first desktop laser printer from an 8080 instead of all the random logic we were designing. So I got them to spring for serial # 2 of the Intel Intelec 8080 development system (it actually had a sticker over the 8008, I think it cost $25,000 in the late '70's) I wrote a 4 k operating system for the laser printer that could print WYSIWYG form an Alto workstation (guess you see where I was working). The Alto was mostly programmed in BCPL (PARC basically copied the Data General minicomputer design and that was the main-board for Alto ( i can't remember whether they did it with permission or not; probably not) After that we built the first electronic copier, it had 2 DG mini's, a huge 300 MB parallel Control Data Disk and we scanned and printed at 480 bits per inch (someone thought 4x FAX was a good thing to do). IT was programmed in BCPL (which I wrote thousands of lines of code to test and verify operation.) I then moved to C and finally the Xerox Mesa programming language. I grew up as a programmer from the bottom up. I think it made me a better programmer. It also male me a better manager later because I understood how difficult programming was and I knew who to believe his/her estimates and I also knew whose estimates I had to triple or more. I've been teaching at community colleges for the past 13 years and I was going to years propose an assembly language class using the Raspberry PI and some sort of X86 assembler. Anyone knowing anyone who is doing this in a CC setting?. Comments and criticisms would be appreciated. I think it's the right thing to do for my students.

rplantz
Posts: 66
Joined: Sun Jul 01, 2012 2:38 am

Re: Assembly - any use in teaching it?

Wed Jun 12, 2013 2:48 pm

mvbii wrote:I first learned PDP-8 assembler (key in the boot loader, then start up your KSR33 to load the assembler and your code), ...
Ah, yes, I recall keying in the boot loader for Data General's first diskette OS on a Nova 3. It was three instructions:

Code: Select all

Reset disk to track zero, sector zero
Read one block from disk
Jump here
The first block contained a program that read the second stage of the boot process into memory, plus one instruction that wrote over the "jump here" to jump to the newly loaded second stage.
I've been teaching at community colleges for the past 13 years and I was going to years propose an assembly language class using the Raspberry PI and some sort of X86 assembler. Anyone knowing anyone who is doing this in a CC setting?. Comments and criticisms would be appreciated. I think it's the right thing to do for my students.
Well, this is precisely my goal in writing a version of my book for the Raspberry Pi. I haven't gotten very far yet (I'm retired from teaching so taking life a little more relaxed these days) but I'm using Raspberian. That allows me to use the gnu programming environment. If you look over my current x86-64 book, you will see that instead of taking the bare-metal approach you and I grew up with, I take the top-down, what's under the hood approach.

BTW I interviewed at PARC in the late 70s. That's when I first saw a mouse and an email system. I recall a secretary stepping into the office and handing the interviewer a paper note. When she left he said, "She's new here. We don't use paper anymore." I think the laser printer led to using more paper, not less. ;)

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?

Fri Jun 21, 2013 11:23 am

I'm interested in being able to activate part of GCSE Computer Science on addressing. See attached slide:
Image

It strikes me that a great way to do this would be via assembler. In context of the thread title - assembly is very useful.

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

Re: Assembly - any use in teaching it?

Sat Jun 22, 2013 5:04 pm

Good idea, but that slide is so far obsolete it's pointless. Fixed segment/offset addressing like that was only ever used up to the 80286. Since then segments were first 64k, so the offset could be 64k and adding 1 to the segment addressed a different 64k, and lately 4GB -- the whole of memory. No other processor family ever used segments at all. In fact segments, being variable size, were a dead-end; they are too expensive to administrate. Everyone else, and even Intel from the 80386 on, uses fixed size pages. Intel only continues to support segments as an additional level of memory management because getting rid of them would break compatibility at a very fundamental level.

And just to nit-pick, a byte is not sufficient space to hold a character, it is 8 bits. You are correct in that that was the original meaning, but it remained at 8 bits even when IBM, who invented the term, tried to make it 9 bits. These days characters tend to be 16 bits.

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?

Sun Jun 23, 2013 7:23 am

Thanks for that. It's tricky sometimes setting these things up when there's no one around physically to proof your work, when its unfamiliar territory (memory addressing) and there is nothing out there suitable for a 14 y/o audience.

I knew I wasn't 100% about the offset thing...
In future if there's other things like that I'm not completely sure about will post up for review if that's ok.

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?

Sun Jun 23, 2013 8:15 am

rurwin wrote: And just to nit-pick, a byte is not sufficient space to hold a character, it is 8 bits. You are correct in that that was the original meaning, but it remained at 8 bits even when IBM, who invented the term, tried to make it 9 bits. These days characters tend to be 16 bits.
a= (ascii) 97 = 0b1100001

Although I see your point, I will take care to be more precise with definitions.

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

Re: Assembly - any use in teaching it?

Sun Jun 23, 2013 8:52 am

Half a byte is .... a nybble !

Yes, it really is - always gives me a chuckle, that does :)
Android app - Raspi Card Imager - download and image SD cards - No PC required !

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

Re: Assembly - any use in teaching it?

Sun Jun 23, 2013 12:52 pm

ASCII has had it's day. So have Latin-1, Latin-2, etc which came after it. Eight-bit characters are a nightmare when it comes to internationalisation. Every string I use these days, that is meant for human interaction, is in Unicode. The older machine protocols are still 7-bit ASCII, but even that is changing quickly.

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?

Sun Jun 23, 2013 3:14 pm

That would not have even occured to me ...
I was finding the 8 bit (okay 7) encoding a useful way of giving some context...
Ie. If 1 byte is a single letter of the alphabet then how many could potentially be referenced by a 64 bit address?

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 Jun 23, 2013 5:10 pm

Too many to worry about. ;)
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
morphy_richards
Posts: 1603
Joined: Mon Mar 05, 2012 3:26 pm
Location: Epping Forest
Contact: Website

Re: Assembly - any use in teaching it?

Sun Jun 23, 2013 6:14 pm

Ridiculously Big Numbers, a great way of bringing out the inner geek in kids plus a bit of a warning that this course is going to involve doing some harder than average sums. :)

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

Re: Assembly - any use in teaching it?

Sun Jun 23, 2013 10:00 pm

Maybe an interesting and useful approximation exercise.
How many bits do you need? The original Manchester computers used 5-bit Baudot, but that needed a shift character to get both letters and numbers with a decent amount of punctuation.
The machine I used at university used 6-bit codes, which is enough for upper-case letters, numbers and all the punctuation for English.
ASCII uses 7 bits, and handles upper and lower case, and 33 control codes in addition to numbers and punctuation.
To handle all the accented characters in languages that use the latin characters needs more than 8 bits, maybe nine or ten would suffice.
But to handle every character in every script ever used by humans* requires less than 18 bits.

The first 127 codes in Unicode are compatible with ASCII, and I think the first 256 match Latin-1.

Big numbers: Devise a way to make a googol understandable. For example, from memory: take a cube 1.5km on a side and fill it with ping-pong balls. Turn every ping-pong ball into a "known universe", and you would have enough space to store a googol matchsticks. (The universe has probably grown since I calculated that, and I didn't take hexagonal-close-packing into account.)

----
* For example: http://www.alanwood.net/unicode/phaistos-disc.html
Your font probably does not support those characters, but they are nevertheless in the character set. My font does have these, which are a little less obscure: http://www.alanwood.net/unicode/byzanti ... mbols.html

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?

Mon Jun 24, 2013 8:59 am

rurwin wrote: Big numbers: Devise a way to make a googol understandable. For example, from memory: take a cube 1.5km on a side and fill it with ping-pong balls. Turn every ping-pong ball into a "known universe", and you would have enough space to store a googol matchsticks. (The universe has probably grown since I calculated that, and I didn't take hexagonal-close-packing into account.)
And I thought 18,446,744,073,709,551,615 was quite a lot!

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

Re: Assembly - any use in teaching it?

Tue Jul 02, 2013 6:02 pm

mvbii wrote:I first learned PDP-8 assembler (key in the boot loader, then start up your KSR33 to load the assembler and your code)
I'm sure you mean ASR-33. PDP-8 ASM requires a certain amount of masochism, but a KSR-33 is a bit much ;)

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

Re: Assembly - any use in teaching it?

Wed Jul 03, 2013 6:06 am

johnbeetem wrote:
mvbii wrote:I first learned PDP-8 assembler (key in the boot loader, then start up your KSR33 to load the assembler and your code)
I'm sure you mean ASR-33. PDP-8 ASM requires a certain amount of masochism, but a KSR-33 is a bit much ;)
Tru dat.

When I was younger, and approximately as broke as I am now, I recovered a 33-RO from a junk sale and interfaced it up for use as a printer. Attached it to my microtan-65, IIRC. It shook the goddamned house.

Return to “Staffroom, classroom and projects”