Baremetal Pascal dev. environment for RPi - Page 1
Forum section: electronics / general

author: Vtile
author_rank: Super Contributor
timestamp: September 18, 2017, 06:51:36 pm
content: I made a quick search on the subject, but couldn't find this on the eevblog so I thought I share. I do not have any connection to Ultibo, other than coding in pascal at times.What I have lazely looked in to it, it seems to be open source. Backed up with commercial entrepreneur.www.ultibo.org- CheersPS. For other OSes than Windows, look for Ultibo wiki for instructions (Linux, macOS, Rasbian)From Ultibo FAQ:Quotehttps://youtu.be/TCfpb8M0WeQEdit2. Barebones to Baremetal .... mixing words this evening.

author: eugenenine
author_rank: Frequent Contributor
timestamp: September 18, 2017, 07:21:48 pm
content: Why do they show a picture of (MS)windows if its for a rpi?

author: Vtile
author_rank: Super Contributor
timestamp: September 18, 2017, 07:25:12 pm
content: Quote from: eugenenine on September 18, 2017, 07:21:48 pmAh, sorry I notice now I have error in the subject. It should indicate that it is FOR not IN RPi. The Ultibo editions of IDE and compiler (free pascal) that is used runs on this case in Windows, but compiles RPi native code.Edit. Hopefully the title / subject is now more informative.

author: brucehoult
author_rank: Super Contributor
timestamp: September 18, 2017, 07:34:23 pm
content: It's nice to see a Pi boot up in a couple of seconds. That's useful.Remarkably, the site, including the FAQ, doesn't mention the BIGGEST prerequisite! "Do I need anything else to get started?" "You’ll need a Raspberry Pi of course and an SD card, other than that everything you need to start creating apps is included in the download."Ahahaha.The author apparently hasn't even noticed that you need a Windows PC. Which I don't have, and have never had.The downloads page has only .exe.

author: Vtile
author_rank: Super Contributor
timestamp: September 18, 2017, 07:35:53 pm
content: Quote from: brucehoult on September 18, 2017, 07:34:23 pmTake the ultibo source and compile it to Linux or other Freepascal & Lazarus supported environments, including amigaOS4 (or what it were).

author: eugenenine
author_rank: Frequent Contributor
timestamp: September 18, 2017, 09:00:21 pm
content: Quote from: brucehoult on September 18, 2017, 07:34:23 pmOr the time to keep a window box running, I gave up on that a long time ago.

author: rstofer
author_rank: Super Contributor
timestamp: September 18, 2017, 11:27:49 pm
content: Very nice!If I can get to the RPi peripherals, I would really like to give it a go.Better yet, the Pascal P4 compiler (original Niklaus Wirth CDC 6400 version) could be ported to the power of the RPi. That would be awesome! It would require 64 bit words to accommodate the original 60 bit set size. Should be doable... Add a few system calls and replicate the entire setup.I have spent time with FreePascal and it works very well. Somewhere around here, I still have Turbo Pascal although I haven't used it since I wrote a MicroMouse program 12 or more years ago.

author: hendorog
author_rank: Super Contributor
timestamp: September 19, 2017, 03:39:00 am
content: Quote from: wilfred on September 18, 2017, 11:37:06 pmYeah it's an odd choice, but I will also make the point that it's a shame that it is an odd choiceIf Borland et-al weren't so flipping incompetent at managing it, I think (Object) Pascal would still be _reasonably_ popular.In its day, Delphi hit a sweet spot of speed vs development productivity.It's (was) much simpler than C++ and was compiled so is much faster than Python for example.

author: rstofer
author_rank: Super Contributor
timestamp: September 19, 2017, 03:40:37 am
content: I have used Fortran quite a bit the last couple of years and it was my first language back in '70. I still prefer it for numeric kinds of things.I don't know anything about BLISS or Simula67 (or Ruby or Perl or Lisp or Forth or....). Modula-2 is ok but I would rather go even further back and take a look at Algol 68.C++ brings nothing to my dance. I like and use C most of the time but I avoid C++ at every opportunity. Just never warmed up to OOP. I don't see the application in embedded programming.In my view, the best book on algorithms and data structures ever written is "Algorithms + Data Structures = Programs" by Niklaus Wirth and it is all done in Pascal. Pascal was developed as a teaching language and in this it excels. Modula 2 is the first upgrade and I believe Oberon is the current flavor. There is an embedded version of Oberon for ARM and I used a version of Pascal with an 8051 clone.There's just something 'pretty' about Pascal. It just flows neatly. Concepts I appreciate but can't explain. I just like code that looks pretty on the page.

author: thermistor-guy
author_rank: Frequent Contributor
timestamp: September 19, 2017, 05:02:43 am
content: Quote from: rstofer on September 19, 2017, 03:40:37 amAlgol68 is available for Linux, so it should build on an rpi (for example):https://jmvdveer.home.xs4all.nl/algol.html

author: krho
author_rank: Regular Contributor
timestamp: September 19, 2017, 05:24:33 am
content: Quote from: rstofer on September 19, 2017, 03:40:37 amI've know Delphi/Pascal before I entered the collige and there they forced Oberon on us. I mus say that its rules are :emoji that pukes.

author: legacy
author_rank: Super Contributor
timestamp: September 19, 2017, 06:30:05 am
content: Pascal -> Modula2 -> OberonOn the Evolution Line

author: legacy
author_rank: Super Contributor
timestamp: September 19, 2017, 07:06:22 am
content: Another device where I appreciate FreePascal is the pretty old GBAGameBoyAdvance, based on ol StrongARM. It's good, and nice!

author: Vtile
author_rank: Super Contributor
timestamp: September 19, 2017, 07:42:53 am
content: I think the pascal here deserves a small explanation. It is indeed one of the "old languages", just like is C-language, in fact the C-language is only a few years younger. Indeed pascal at first were academic "teaching language", but early on converted to more usefull general language in hands of more engineering minded people. The general usability of it shows in the fact that the whole developing toolchain of freepascal compiler and Lazarus IDE are written and build with pascal itself (a few million lines of code). Also Wozniaks first Apple computers were using OSes written in one extented Pascal dialects (Apple Pascal). The pascal have long track record of doing stuff, most notably the early Borland era from 80's through early millenium (Borland Turbo Pascal and Delphi), until the mastermind behind the Borland compilers were hired by MS (reasons, IDK).Indeed the (Object) Pascal is a bit of "odd child" these days, but it is still living just under the mainstream languages with boutique level backing (compared to mainstream languages, which do have huge corporative support / maintenance / development ), it tells something for its usability.This Ultibo seems to be modification of standard Freepascal & Lazarus toolschain, which by nature is cross-compiling environment that can target (and run) awfully lot of processors and OSes. The Pascal used today is mainly Borland based Object Pascal (Both Turbo&Delphi flavours).One of the best features (for me atleast) is that the strong(ish) typing leads to compiler that is fast and catch most of the silly programming errors in build phase.

author: rstofer
author_rank: Super Contributor
timestamp: September 19, 2017, 03:15:51 pm
content: Five minutes with Lazarus IDE and it's time to click the Uninstall button. On Win 10, I get a detached Messages window, a detached Editor window and the Lazarus toolbar at the top with no apparent way to put the pieces together as I would have with Eclipse. They're all just flopping in the breeze with my desktop showing through. I suppose there is some reason for this but my attention span is too short to figure it out.I can use FPC with Eclipse although I might not have all the features of Lazarus in terms of generating forms.

author: Yansi
author_rank: Super Contributor
timestamp: September 19, 2017, 03:27:22 pm
content: Quote from: rstofer on September 19, 2017, 03:15:51 pmThats because you know zero to nothing how Delphi have worked. So stop bitching, it is behaving correctly. The top panel with menus and components, left the object inspector, and the source codes and the form designer if you hit F12. Sigh!

author: krho
author_rank: Regular Contributor
timestamp: September 19, 2017, 03:47:10 pm
content: as @Yansi said. This is the best behavior of Delphi. Later on when they joined everything together it just becomes a mess. and you have no place anymore.You need to learn a few shortcuts to bring the inspector and some other window to front sometimes otherwise it stays out of the way 99% of the time Without collapsing the docks and all this "shit"

author: rstofer
author_rank: Super Contributor
timestamp: September 19, 2017, 05:16:33 pm
content: Quote from: Yansi on September 19, 2017, 03:27:22 pmAbsolutely correct!I could never afford to buy Delphi and I don't recall that it was ever 'free'. I stopped after Turbo Pascal and Borland Pascal back a long time ago.Looking at the prices for Embarcadero Delphi shows it is still out of my reach. There seems to be a Starter version that is free. I haven't pursued it...

author: legacy
author_rank: Super Contributor
timestamp: September 19, 2017, 05:26:37 pm
content: Quote from: rstofer on September 19, 2017, 05:16:33 pmWrongDelphi for Windows v1 and v2 were released for free in 2006.Do you want a copy? Let me know (it comes set in UK language)It's currently installed on a Windows95 emulator under my IRIX on my SGI workstation (UNIX).while TurboPascal v7 + TurboVision are installed under IBM-DOS-v7 on my RISCOS v4.39 RISCPC machine (Strong ARM 200Mhz based).Of course they are not installed on my job-laptop because they are not used for business.

author: legacy
author_rank: Super Contributor
timestamp: September 19, 2017, 05:33:03 pm
content: Oh, about that: RISCPC runs on modern RPI, and it costs ~50 euro.It's faster than linux since it's lighter (even if ... less robust )anyway, it also comes with a super fast dos-emulator (optimized for RISCOS)which may allow people to install TurboPascal-v7 into a DOS virtual machine.Just an idea

author: rstofer
author_rank: Super Contributor
timestamp: September 19, 2017, 07:11:05 pm
content: Quote from: legacy on September 19, 2017, 05:26:37 pmThat explains it! I stopped looking some time in the early to mid '90s. Never gave it another thought until today.Thanks for the kind offer but I think I have enough irons in the fire.

author: NorthGuy
author_rank: Super Contributor
timestamp: September 19, 2017, 08:12:50 pm
content: Delphi had a wonderful compiler. But it was bundled with over-bloated VCL library and very buggy IDE, so no one has noticed.

author: Vtile
author_rank: Super Contributor
timestamp: September 19, 2017, 08:37:35 pm
content: Ok this have now derailed from OT a bit, but the FPC should be Turbo Pascal 6* and Delphi 6* compatible and in several platforms. Freepascal is better documented, but the VCL equivalent library is a bit raw in edges.In my mind the Ultibo is a nice project an allow easy jumping to baremetal programming with ease as there is option to use the readily made key HW libraries like communication and consoles. This with easy to write language and error trapping fast compiler. Just the parts one wants when someone wants to start to learn baremetal programming and the language also is capable of full blown system as the speed is good. Only theoretically slightly slower ** than C and many times more memory efficient.* from memory.. The delphi VCL have a few places where it is not 100% for multiplatform reasons. FPC also do have freevision library and multiplatform textmode IDE (borland clone) build in if the Lazarus suxs.** as pascal might be less optimised in speedtests, because of not being mainstream and kewl.

author: eugenenine
author_rank: Frequent Contributor
timestamp: September 19, 2017, 08:42:26 pm
content: Pascal isn't a bad language, I've used it here and there.I see Ultibo does support more than windows but you have to dig for it. That information needs put on the download page so it doesn't look like its just windows only, thats a big turn off for any project as i don't have the resources to maintain a windows system.

author: hendorog
author_rank: Super Contributor
timestamp: September 19, 2017, 08:49:26 pm
content: Quote from: NorthGuy on September 19, 2017, 08:12:50 pmActually the VCL was a quite revolutionary feature of Delphi, and was optional.You could write tiny bare metal apps without the VCL if you chose.Or you could compile it all into a single exe/dll for easy deployment.Or you could separate the library from the exe and have a small exe and a single large library which you deployed once (this might have been in a later version)When Delphi came out it was competing against VB. While VB was easy to use, it was very limited in comparison - with it's VBX (later OCX) based library. Delphi had performance and flexibility in the same class as C, and ease of use in the same class as VB.The chief architect of the VCL went to Microsoft and became the chief architect of C#, he was no mug.

author: NorthGuy
author_rank: Super Contributor
timestamp: September 19, 2017, 09:00:47 pm
content: Quote from: hendorog on September 19, 2017, 08:49:26 pmI still do, without VCL or IDE. Works quite well.

author: hendorog
author_rank: Super Contributor
timestamp: September 19, 2017, 09:47:59 pm
content: Quote from: NorthGuy on September 19, 2017, 09:00:47 pmSo how do you define bloat??Unused parts of the VCL were/are removed by the linker which is about as good as it gets.Certainly way better than VB or Java/.NET etc, and IIRC at the time there was nothing available for C/C++ that came anywhere near the usability and productivity of the VCL.I guess you could argue it wasn't designed optimally to ensure that nothing was accidentally linked in when it wasn't strictly required. Perfection is an honourable goal but rarely realised I guess...

author: NorthGuy
author_rank: Super Contributor
timestamp: September 19, 2017, 10:21:52 pm
content: Quote from: hendorog on September 19, 2017, 09:47:59 pmVCL was a huge library which wasn't very well thought out. It didn't really provide any benefits compared to using plain Windows API, and sometimes even made such use more difficult. The only benefit was visual design which looks great at first, but then you would notice it didn't scale well across screen resolutions and font sizes, so the benefit was dubious. However, to make VCL compliant with the visual design they added lots of stuff, which increased the amount of compiled code and slowed down execution. I don't know if they fixed all the problems later, I stopped using VCL long time ago. Of course, it still was much better than VB, not to mention Java.The Pascal compiler which shipped with Delphi had no connection to VCL. It was very efficient, worked fast and produced very good code. I don't think FPC is nearly as good. However, anyone using Delphi would rather think of it as Visual IDE and VCL rather than a Pascal compiler.As a language, Pascal is good. I would rate it better than C/C++, and I don't really understand why OP says it is slower than C. Unfortunately, there's no standard in Pascal and compilers are not common, so often you're stuck with C.I think bare-bone RPi programmed with Pascal is a great idea.

author: hendorog
author_rank: Super Contributor
timestamp: September 19, 2017, 10:50:41 pm
content: Quote from: NorthGuy on September 19, 2017, 10:21:52 pmAh yes - the changing DPI/font sizes was an issue I remember.I never found changing the screen resolution to be a problem, on the contrary it was very good, and compare to the many Microsoft developed apps still won't let you resize a dialog to make a tiny list box bigger. If they did let you resize then the list box would stay small.On Delphi it was trivial to do without butchering the layout by using the anchoring system and panels.I think you are a bit harsh on using the API directly. I can still remember the culture shock when everyone discovered that a few line C program in DOS changed to a 200 line C program in WindowsWith Delphi that came back to a few lines of code again - with the flexibility of using the API if you wanted to.Remember back then the Windows API wasn't very well understood (pre widespread internet), Companies weren't very open and didn't share much information, and you needed the Programming Windows book to be able to get anywhere. Remember the secret API's that MS kept to themselves to make their software work better.The problem with that great compiler was that it became a weight around Borland's neck. They thought that was their golden goose - so they refused to open source it. They never made enough money from it because not enough people were using it.Had they done so - and charged no royalties, instead charging only for the IDE - they could have increased market share, and I believe they could have survived.

author: eugenenine
author_rank: Frequent Contributor
timestamp: September 19, 2017, 10:57:28 pm
content: 200 lines?I bought Borland C++ 4.0 for Windows (3.1) with my student discount ($129 instead of $459 or something like that). It took my system several minutes to compile their simple hello world dialog box example and it was something like 20k lines.

author: hendorog
author_rank: Super Contributor
timestamp: September 19, 2017, 11:15:47 pm
content: Quote from: eugenenine on September 19, 2017, 10:57:28 pmHaha, I was struggling to remember and didn't want to exaggerate - I do think it was about 200 or 250 lines of code minimum to display a window using Windows API only. It was far too scary for me at the time anyway, hence I abandoned Borland C++ and moved to Delphi when it came out, and I started developing for Windows. I probably would have used VB instead, but it was super expensive and I couldn't afford it.The example might include a heap of extra stuff like toolbars, status bars, menus etc? Pre-compiled headers to the rescue

author: hendorog
author_rank: Super Contributor
timestamp: September 19, 2017, 11:34:50 pm
content: Quote from: wilfred on September 19, 2017, 11:06:18 pmYou are likely correct - I doubt it will excite the masses, as pascal just isn't cool enough anymore.Bringing it back OT though I'd say someone might be interested in this concept because it is simpler than an OS + blah blah, and therefore easier to learn/be productive with. @Vtile covered it quite well I thought.It kinda reminds me of the old 8bit home PC's like the Amstrad/C64/BBC so it's interesting from that angle - i.e. no 'ceremony' programming...Looking ahead, there are many apps in the world which run on an OS on a VM on hardware. Conceptually the OS could go away and the app could run on the VM directly. So from that perspective this is interesting also.

author: NorthGuy
author_rank: Super Contributor
timestamp: September 20, 2017, 12:09:19 am
content: Quote from: wilfred on September 19, 2017, 11:06:18 pmDiscussing relics is not such a bad idea. If you don't remember the past, how you can learn from it? For example, we have just discussed how moving from DOS to Windows made simple programs more difficult - things were easier without Windows. Similarly going bare-metal might be easier than working with OS. And, IMHO, Pascal might be a better choice for the novice than C.Popularity is changing. And old things often get popular again. Who knows - may be Pascal is the next big thing.

author: rstofer
author_rank: Super Contributor
timestamp: September 20, 2017, 01:14:20 am
content: The thing I liked about Pascal was the compiler itself. I had source for UCSD Pascal and the compiler followed exactly the syntax diagram for the language. As a compiler project, it was easy to understand. The UCSD version, like the ETF version, emitted P-code and all that was required for porting was to implement a new P-code interpreter. This wasn't very hard.Then UCSD decided to get out of the software business, cancelled all the outstanding licenses and turned the project over to a company that began charging for the package. Bummer...At one point, maybe 12 years back, I was implementing the Pascal run-time interpreter in an FPGA. I basically built on what was documented of the P4 (ETF) compiler. I didn't quite tumble to how to handle floating point and system routines. Today I would just use some kind of TRAP mechanism for those routines.

author: eugenenine
author_rank: Frequent Contributor
timestamp: September 20, 2017, 01:30:02 am
content: Pascal started as an educational language and the rpi started out to be for the educational space so I think its a good fit.

author: Vtile
author_rank: Super Contributor
timestamp: September 20, 2017, 11:25:14 am
content: I'm honestly lost with you gents. One argues historics, one with ms OS, one argues that marketing by language choise sucs.Make a better one yourself then, so we can start to pick it apart.

author: Vtile
author_rank: Super Contributor
timestamp: September 20, 2017, 01:39:57 pm
content: Yes the overall success depents certain things, but succesfull or not the Ultibo is usefull and easy way to start with baremetal programming of RPi. It doesn't make it any lesser if this project happens to die in a few years (aka not being the next big thing). The gained skills and experience do not die and most of gained knowledge will be language indepentend. More so exposure to Wirthian languages (Ada, Pascal variants, scripting languages, industry specifics etc.) is always good, since they aren't going anywhere in a few decades.

author: BradC
author_rank: Super Contributor
timestamp: September 20, 2017, 01:52:05 pm
content: Quote from: wilfred on September 20, 2017, 12:00:30 pmExcept that a freepascal arm target has existed for years, and this environment exists *now*. People have been pontificating about a micro-Python or embedded python environment for years.I've been programming in freepascal for something near 20 years now. The direct RPi port sounds kinda neat. If nothing else, users of other languages can use this as a springboard to leverage an understanding of the bare metal requirements.Don't get me wrong, I like python. But native compiled & optimised beats out interpreted (even when the interpreted is boiled down to compiled bytecode) in my book for any embedded system.Of course my opinion is worth what you paid for it.

author: eugenenine
author_rank: Frequent Contributor
timestamp: September 20, 2017, 07:22:19 pm
content: Quote from: Vtile on September 20, 2017, 11:25:14 amWell, I know I don't come over well but mine was meant as constructive. it looks interesting so I hate to see it die because of lack of openness. I've used and supported open source projects for a long time and when the open part is buried deep down and the close part on the second page it tends to hurt projects.

author: hendorog
author_rank: Super Contributor
timestamp: September 20, 2017, 08:16:12 pm
content: Quote from: Vtile on September 20, 2017, 11:25:14 amMostly I think we were all just having a bit of a yarn about the good old daysPontificating about stuff late into the night is the essence of engineering isn't itI do think its a cool project and I will probably have a play with it - still doesn't mean it will be a great popular success. It's really hard to hit a winner with something like this nowadays.I do think the point made by @eugenenine about using them in education is a very good one.

author: rstofer
author_rank: Super Contributor
timestamp: September 21, 2017, 12:54:09 am
content: I kept reading about Ultibo and it caused me to re-evaluate Lazarus. OK, I can get along with it... I think it is important to open the Lazarus (Ultibo Edition) rather than Lazarus (Undocked). Duh...There is a metric buttload of code provided with Ultibo. Much of it originated in the Linux world, primarily the device drivers. Watch the USB video to see how mass storage works. I'm not sure if/how HID works.I watched all 6 episodes and the more I saw, the more impressed I got. So, I reinstalled it. There is a lot of low level capability in Ultibo.I haven't tried the networking example (simple web page with OFF-ON buttons to control LED on Pi. This is a simple example but it shows the scale of the code supplied. Networking, web serving, GPIO control, etc. I'm going to run this tomorrow.Did I mention support for multiple CPUs?https://ultibo.org/wiki/Architecture#Multiple_CPUs

author: thermistor-guy
author_rank: Frequent Contributor
timestamp: September 21, 2017, 02:50:48 am
content: Quote from: rstofer on September 21, 2017, 12:54:09 amI'm very interested in a bare-metal dev. system for the rpi.My local network has a few rpi to perform various networking tasks. My (semi- but increasingly) automated test equipment setup uses rpi for running test scripts and gathering data.So the idea of embedding the same hardware platform in custom-built test equipment, if/when needed, has a lot of appeal. The "metric buttload" of code is a plus, for getting something working quickly. I'm easy-going about exactly what block-structured imperative language the system uses - Pascal is fine.Thanks to Vtile for starting this thread.

author: brucehoult
author_rank: Super Contributor
timestamp: September 21, 2017, 08:16:12 am
content: Quote from: wilfred on September 21, 2017, 12:14:24 amI programmed in Pascal for most of the 80s (Apple ][ UCSD, PDP-11 NBS Pascal and OMSI Pascal, VAX Pascal, Macintosh Object Pascal). I switched to C++ in 1989 and have never gone back. Pascal vs C is a non-issue, they both do the same thing. Object Pascal is close to equivalent to Objective C (not quite). C++ is in a league of its own.By far the biggest practical advantage the C family has over Pascal for real world work is the powerful (but horrific!) preprocessor. Which you could steal and use as an external tool with Pascal code too. "Real" Pascals have some kind of conditional compilation, but it's not as powerful.QuoteMore like 50 or 60 years old, and predating the internet by a long way!Right from the start, computers have been much faster than I/O, so almost any program that is dominated by I/O could reasonably be written in an interpreted language. That includes the vast majority of business software, but not scientific.Early computers had really awful instruction sets and very limited memory. The simple compilers they could run generated huge and bad code, and assembler often wasn't much better. Well designed bytecode was much more compact, and a program didn't have to be very big to get back the space overhead of the interpreter.Mainframes eventually got nice instruction sets (IBM 360 is pretty good, even by modern standards), but then early minicomputers, early microprocessors after them, had really shit instruction sets. It's hard enough at first to fit in enough circuitry to make something that works at *all*. In microprocessors this was the case up to and including the Z80 and 6502.A great example of the utility of interpreters on such crude machines is Wozniak's "Sweet16" for the Apple ][. It is implemented in 372 bytes of 6502 code in ROM and provides a 16 bit virtual machine with 16 mostly 1 byte instructions and 16 registers (stored in addresses 0x0000 - 0x001F). No other memory is needed for the interpreter.Wozniak provides an example of Sweet16 interacting with native code:Code:300 B9 00 02 LDA IN,Y ;get a char303 C9 CD CMP #"M" ;"M" for move305 D0 09 BNE NOMOVE ;No. Skip move307 20 89 F6 JSR SW16 ;Yes, call SWEET 1630A 41 MLOOP LD @R1 ;R1 holds source30B 52 ST @R2 ;R2 holds dest. addr.30C F3 DCR R3 ;Decr. length30D 07 FB BNZ MLOOP ;Loop until done30F 00 RTN ;Return to 6502 mode.310 C9 C5 NOMOVE CMP #"E" ;"E" char?312 D0 13 BEQ EXIT ;Yes, exit314 C8 INY ;No, cont.From 30A to 30F is 6 bytes of Sweet16 interpreted code. The rest is 6502 code. Without Sweet16 a direct translation to 6502 of the copy loop would be something like this (using the same memory locations for src, dst and len as the Sweet16 code does):Code:LDY #0L0: LDA ($02),YSTA ($04),YINC $02BNE .+2INC $03INC $04BNE .+2INC $05LDA $06BNE .+2DEC $07DEC $06LDA $06ORA $07BNE L0This is 32 bytes of code instead of 6 (really 9, including 3 bytes to call Sweet16). The native code runs about ten times faster than the Sweet16. This is often not important for most of the program.(You can do better than this by keeping the low byte of length in the Y register and not actually modifying the low byte of the src and dst pointers. But not much better. The fastest solution requires self-modifying code)Modern instruction sets allow much more compact code, with the current champions being Thumb2 and RISCV, and i386, MSP430, SuperH not that far behind. Over a whole program (not just one isolated loop), Thumb2 is about as compact as any interpreted bytecode, while running at native speed.

author: legacy
author_rank: Super Contributor
timestamp: September 21, 2017, 09:08:31 am
content: Quote from: brucehoult on September 21, 2017, 08:16:12 amSince the preprocessor is not a part of the language, by definition is an external tool that does "pre"-processing, then it means that the language has a huge defects in its foundations!Then, and now. C, C++. We are still sitting on the border of hell

author: Vtile
author_rank: Super Contributor
timestamp: September 21, 2017, 09:45:08 am
content: Google "Free pascal preprocessor"

author: legacy
author_rank: Super Contributor
timestamp: September 21, 2017, 11:11:59 am
content: Reducing the preprocessing to something likethismay be acceptable.But people MUST understand how many disasters are caused by the abuse of cpp in C!and don't repeat the root of mistakes on Pascal!

author: brucehoult
author_rank: Super Contributor
timestamp: September 21, 2017, 11:20:33 am
content: Quote from: legacy on September 21, 2017, 09:08:31 amIt's not true. Go and read the ANSI C standard. One of the first things it specifies is the exact sequence of steps to be used in processing the source file, including jobs done by the preprocessor such as removing comments, inserting the contents of #include files and so forth.The preprocessor features operate at a different level of abstraction to the parser, or even the lexer, but they are absolutely part of the C language. There has never been a C compiler that does not include preprocessing (at least since C and Unix first escaped from AT&T). I note that the BCPL manual from 1967 specifies the availability and features of the required preprocessor.It happens that the preprocessor is often implemented as a stand-alone program in a pipeline, or that even if it is built into the C compiler it can be instructed to write out the results of pre-processing and then stop. This makes the C preprocessor usable by other languages -- including Pascal -- but doing so is not a standard thing in those languages.

author: brucehoult
author_rank: Super Contributor
timestamp: September 21, 2017, 11:24:21 am
content: Quote from: Vtile on September 21, 2017, 09:45:08 amMany Pascal implementations provide preprocessing facilities (typically conditional compilation). Apple Pascal in the 1980s did.However it is not standardised across compilers like C is.

author: legacy
author_rank: Super Contributor
timestamp: September 21, 2017, 11:41:36 am
content: Quote from: brucehoult on September 21, 2017, 11:20:33 amNo matter if the hipster ANSI-doc tells you how you have to write #define #if #else #include blablablaWith "language" we meanlanguage-constructs, ways to express what we need, and if you need to use an external "SED", then ... it means there is a defect in the language!In fact CPP does the same job as SED: it replaces a pattern of text with a pattern of text with neither the intelligence nor the information to understand what it is replacing ... it's just a dummy puppet-tool, which is *THE* point, and it clearly means that the language has a defect since it is not able to express your needs without the help of an external tool!e.g. #define constantreallywhich is the type? which is the range?What The Freak is this?the ANSI doc says it's ... a dummy pattern of text to be replaced with a dummy pattern of textOh, Cool!There is information lost in the middle of them, with the consequence of disasters! Even an external LINT (which takes the source already pre-processed and it analyzes it before the compiler cc1) is a defect!!

author: brucehoult
author_rank: Super Contributor
timestamp: September 21, 2017, 12:19:38 pm
content: Quote from: legacy on September 21, 2017, 11:41:36 amI think you mean "yuppie". ANSI C has been around a lot longer than hipsters. And it's very un-hippie.QuoteNo one denies that the C preprocessor is like a very sharp knife -- as are many other features of C such as pointer/array equivalence, lack of bounds checking, type casts that operate at the bit representation level. You just need to take appropriate care. Which, sadly, not everyone does.

author: medical-nerd
author_rank: Regular Contributor
timestamp: September 21, 2017, 12:21:13 pm
content: Many thanks for posting this, I've been building a retro platform with isa cards on an industrial backplane to use the Dig64 cards I have:http://www.farnell.com/datasheets/88563.pdfRunning DOS, windows 95 and Turbo Pascal 7.0.I now have a reason to buy a raspberry pi to play with.I've used Linux since kernel 0.99 but using it in simple embedded systems didn't interest me, bare metal with pascal does!!Cheers

author: legacy
author_rank: Super Contributor
timestamp: September 21, 2017, 12:51:07 pm
content: Quote from: brucehoult on September 21, 2017, 12:19:38 pmNo, we don't need to recycle the C language and its philosophy again and again!We need to change people's head, or better still, we'd best give people a head up!

author: legacy
author_rank: Super Contributor
timestamp: September 21, 2017, 01:05:11 pm
content: The C language as well as its preprocessor promotes "ambiguity", one of the most undesirable property of programming language grammar, as it significantly complicates the job of a compiler-writer as well as the life of users!Oberon, Modula2 as well as Pascal are focused on "interfaces" and "being modular", while the the C language (no matter if C++, C++11, C+=whatever) still suffers of some bad design points, such as argument type transposed between function and call, functions that may be passed one argument but expected three, and too junk off the stack, variable used before being set without a warm, ambiguity in pointers...Too bad! Does people really need to care about that? Do they need "validating-software" like MISRA-LINT?Well .... for sure even if you could make your programming language 100% reliable, you would still be pray to catastrophic bugs in the algorithm, thus the algorithm and data are THE MOST important thing tobe focused on, no matter which language you want to use to express the algorithm, but ...But! the syntax of C declarations is a truly mess that permeates the use of the entire language, and it's no exaggeration to say that C is significantly and needlessly complicated because of the awkward manner of combining types.On the pragmatic side, the economics of software is such that the earlier in the development cycle a bug is found, the cheaper it is to fix. So, it's a good investment to have a language or a tool do the job to find problems rather than the debugger; but Better a debugger finds the problems than an internal test group. The worst option of all is to leave the problems to be found by customers.This one, the last one in my lines, is one of *the* reason why we use Ada in avionics

author: C
author_rank: Super Contributor
timestamp: September 21, 2017, 09:23:59 pm
content: A lot of problems talked about here is due to poor compilers.Way back in the 70's & 80's HP used pascal internally. Due to the fact that HP wrote the compiler, they could make great changes to how it worked. Some here might not know that back then HP made it's own silicon, HP created processors.One example is HP PASCAL/64000. This was a Pascal with additions & changes to assist in bare-metal development. From the programmer's side, a processor change was just changing the first line of a program so that proper compiler back-end could be selected for code generation.. The back-end of compiler generated an IL that had had 4 objects. In source the statement "A := B + C" became " ADD, Destination, Source1, Source2". This simple change allowed better translation from IL to processor instructions.Another example is the HP series 200 computer line. This was the replacement of the HP9825 which used a HP created 16 bit processor whit a system around the Motorola 68000. HP Pascal was the foundation that created the software needed. The first was the HP9826. The 9825 used a language called "HPL" so a need to continue to run these programs on replacement was needed. HP Pascal created the HPL work-a-like that was much faster. HP Pascal created the Pascal based system for this series. HP Pascal also created the HP Basic system.so that the series 200 could start replacing the 9835 & 9845 computers.The Compiler I used as an end user was almost the same as the compiler used internal to HP, The internal pascal had and option to allow better system programming called "MODCAL", My compiler would not set the flag to enable this extension.One thing "MODCAL" allowed was a pascal program to connect to different blocks of code in a very simple way under program control. This is a basic need of any OS but here could also function as overlays if you had the "MODCAL" option.The other big change was MODULE'S.Each MODULE was compiled separately. This allowed many things. The Module header could be used by other modules when compiled with no need for the full module source code or the binary. Many people could work on separate Modules at same time., The Module header could be used before the complete module source existed & could be used to generate the assembly language interface code needed for modules written is assembly. A pascal program was also a module. A simple idea that is very powerful.So HP back then created many systems with Pascal as a foundation.Some here do not like a compiler that generates Pcode or byte code. This should be and option for any compiler. If you take the blinders off, again a very powerful capability that some want to throw in the trash. When the Pcode or Byte code interpreter is written in Pascal, you could have pascal scripts used in a program. With a change you could run many Pcode streams at same time by time sharing the processing.So put on your thinking cap.By being able to compile modules separately, Compile times decrease & code creation becomes faster & easer and is checked at pascal source level for errors..If you had started with a great pascal, I think most would see the huge problems that C and C like languages create.Need to remember the starting point, C was designed to replace an Assembler. Pascal was designed from high level point of view.The options should not be a choice of ONE.It is not that hard to have a compiler generate more then one type of output, you just need a way of telling the compiler.The lack of input to compiler is preventing the assistance a compiler could do just due to a little lack of input.It's, Don't fix the source of the problems, but create a hack to work around the problem.Today with the computers we are using, the editor should be doing language source checking in the editor leaving the compiler to just generate the code.

author: Vtile
author_rank: Super Contributor
timestamp: September 21, 2017, 11:02:58 pm
content: That were interesting piece of history, like some parts of some other posts.It seems there is possibility to use RPi with Rasbian as development host or what it is called. How nerdy!Here are the instuctions.https://ultibo.org/wiki/Building_for_Raspbian

author: Vtile
author_rank: Super Contributor
timestamp: September 22, 2017, 12:30:46 am
content: Here is more interesting information from Raspberry forums. It seems Ultibo is first dev. system to allow OpenGL and what not without true OS.:https://www.raspberrypi.org/forums/viewtopic.php?f=72&t=193560&sid=23f70d3919ed023ea9ed6dd947ba87bc

author: hendorog
author_rank: Super Contributor
timestamp: September 22, 2017, 08:38:10 pm
content: Quote from: Vtile on September 22, 2017, 12:30:46 amNice!I think Ultibo just went from an interesting curiosity to something much more important for quite a few people