Is it possible to program Raspberry Pi in assembly?

You can talk about almost anything that you want to on this board.

Moderator: Moderators

lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: Is it possible to program Raspberry Pi in assembly?

Post by lidnariq »

Espozo wrote:
lidnariq wrote:Modern framebuffers often aren't linear in-order chunks of memory anymore.
How are they then? I thought a framebuffer was just a giant area of memory with each row of pixels onscreen being at a different offset in the framebuffer.
Often, it's tiled. Each square region of memory is rasterized in order in itself, and spitting out a scanline involves jumping around between tiles.

This means that they can use the exact same hardware for VGA/TMDS/LVDS/MIPI playback as they use to blit polygons.
Espozo wrote:Why does the S-DSP have so many?
8 channels and 11 parameters per channel goes pretty far. Plus another 15 DSP parameters for global settings and 12 more specific to the SPC. So 115 total there, plus ~60 for the PPUs, ~30 for the CPU peripherals that are NOT the DMA controller, and another ~90 for the DMA controller ... roughly 300.
User avatar
rainwarrior
Posts: 8732
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Is it possible to program Raspberry Pi in assembly?

Post by rainwarrior »

Bregalad wrote:
rainwarrior wrote:but C++ is very widely used, and very productive language.
Do you account countless time to understand extremely obsure 10-pages long messages form the linker in your measurement of "productivity" ?
Yes, of course. In all programming tasks you have to deal with errors. That's part of the work.

When I say productive I mean people successfully use it to make applications all the time. You can make stuff with it, and there's a large workforce constantly doing so. Whether or not it's the theoretical "best" language is mostly a worthless debate to me, but whether it's a practical one for getting a project done is not at all.

C++ has linker errors, and sometimes they're cryptic, especially when you're inexperienced. Is there some programming language that magically never has cryptic errors? Do you think python runtime exceptions are easier to debug? (I do not.) With a little bit of experience you get used to errors and how to cope with them. Difficult linker errors happen, but with some practice you begin to understand how to solve them and how to avoid them. They are typically a bit of a problem when doing initial setup for a C++ project, but hardly ever a significant amount of ongoing work as it continues.
Bregalad wrote:
rainwarrior wrote:knowing C++ has literally been worth hundreds of thousands of dollars to me.
Well that's great for you, I haven't been so lucky. By the way, considering how insanely complex C++ is, especially the later 11 and 14 versions, by "knowing" it do you do like me and pretend knowing it because you can use it to make your programs, or did you dedicate 10 years of your life studying the dark corners of this language ?
Ok, so maybe putting a ballpark figure on it was a bit over the top, but in terms of 10 years salary it should seem reasonable?

More or less I've been working professionally for 10 years, using C++ on a not quite daily basis. So in that respect yes I've spent that much time studying the language by now, but I hadn't when I started. (I think I'd been using it unprofessionally for another 10 years before then, but I'm not sure how focused that effort was; it was not my primary occupation until then.)

My point was that knowing C++ puts food on my plate. There's a lot of companies right now that need people who can use C++. You don't have to be a 10 year expert to start a job. The major stuff does not take 10 years of study, the rest you can learn incrementally over time as it comes up.


And back to the topic, I was really just trying to express why you won't find a lot of people writing assembly programs for RPi:
  • Most people do not find assembly "easier" than higher level languages (though this board is full of exceptional people in that respect)
  • The traditional efficiency reasons that made assembly dominant 30 years ago do not apply now
I only advocated for C++ as a counter to the idea that someone would benefit from avoiding it, which I disagree with.


As a learning project, trying to do assembly on the RPi is feasible, but very unusual. You're probably not going to find tutorials on the subject, because very few people are doing it. I think you'll find most people are usying Python on it, actually, but what I'm trying to get across is that it will help you learn a lot if you pick something there's an established community of people doing already. Forcing assembly onto this goal will require you to be a lone wolf.
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Is it possible to program Raspberry Pi in assembly?

Post by tepples »

adam_smasher wrote:What you really wanna learn is an OISC assembly language.
For example, the only instruction in a transport-triggered architecture is MOVE. This means its ALU is memory-mapped, not unlike the multiplier in an MMC5 or the multiplier and divider in the S-CPU, letting an engineer customize the ALU without having to customize the core control circuitry. But then watch a 6502 fan write a macro pack that calls moves to and from the ALU's accumulator port LDA and STA and invents an instruction name for the move to each operation's second operand port.
User avatar
rainwarrior
Posts: 8732
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Is it possible to program Raspberry Pi in assembly?

Post by rainwarrior »

tepples wrote:
rainwarrior wrote:(For anybody that's about to make a pedantic distinction: knowing C is a good stepping stone to learning C++.)
I too learned C before C++, but not everyone agrees.
I didn't actually learn C before C++, technically, but I don't think learning programming languages is a linear process. I strongly disagree with the premise of that lecture you linked that learning C first retards or corrupts your learning of good C++. Good OOP practice can be learned before, after, or in tandem with C, and these skills take take time and effort to acquire. Being a bad C++ coder is a step in the process of becoming a good one, and every language you learn helps learning others in some way.
User avatar
Drew Sebastino
Formerly Espozo
Posts: 3496
Joined: Mon Sep 15, 2014 4:35 pm
Location: Richmond, Virginia

Re: Is it possible to program Raspberry Pi in assembly?

Post by Drew Sebastino »

lidnariq wrote:~90 for the DMA controller
Oh... yeah, I'm an idiot; I didn't take into consideration that every DMA channel has its own copy of registers, so yeah, I can see the S-DSP taking the majority.
lidnariq wrote:Often, it's tiled. Each square region of memory is rasterized in order in itself, and spitting out a scanline involves jumping around between tiles.This means that they can use the exact same hardware for VGA/TMDS/LVDS/MIPI playback as they use to blit polygons.
Interesting... Is it in squares for VGA/TMDS/LVDS/MIPI for (lossy) compression of the signal? If it isn't evident by now, I really don't know what I'm talking about. :lol:
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: Is it possible to program Raspberry Pi in assembly?

Post by lidnariq »

Espozo wrote:I didn't take into consideration that every DMA channel has its own copy of registers, so yeah, I can see the S-DSP taking the majority.
In hindsight that's pretty clearly 40% for APU, 40% for CPU (DMA is part of the CPU), 20% for PPU. But my point was really "SNES as a whole has 10x as many as the NES", not "The APU by itself has >5x as many registers as the NES" (and anyway it has actually ≈4x instead of >5x)
Espozo wrote:Is it in squares for VGA/TMDS/LVDS/MIPI for (lossy) compression of the signal?
I don't actually know. I think it's because there was a decision to move the video scaler from inside the monitor to inside the GPU. (In a laptop, the boundary was already super fuzzy). Treating the output stage as a special case of "draw a scaled polygon" means that you can easily handle rotation/scaling/keystone correction at an earlier stage, and hopefully result in higher quality.
User avatar
Drew Sebastino
Formerly Espozo
Posts: 3496
Joined: Mon Sep 15, 2014 4:35 pm
Location: Richmond, Virginia

Re: Is it possible to program Raspberry Pi in assembly?

Post by Drew Sebastino »

lidnariq wrote:In hindsight that's pretty clearly 40% for APU, 40% for CPU (DMA is part of the CPU), 20% for PPU. But my point was really "SNES as a whole has 10x as many as the NES", not "The APU by itself has >5x as many registers as the NES" (and anyway it has actually ≈4x instead of >5x)
Well, yeah.
lidnariq wrote:I think it's because there was a decision to move the video scaler from inside the monitor to inside the GPU.
I'm assuming this never actually took place, because I've used TVs with such underpowered processors that it feels like there is a third of a second of input lag. What kind of hardware does the average 1080p TV have, or would it vary to much to accurately guess? Is it just some off the shelf ARM processor?
User avatar
pubby
Posts: 583
Joined: Thu Mar 31, 2016 11:15 am

Re: Is it possible to program Raspberry Pi in assembly?

Post by pubby »

I'm assuming this never actually took place, because I've used TVs with such underpowered processors that it feels like there is a third of a second of input lag.
It's just bad programming with too many buffers and pipeline steps.
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: Is it possible to program Raspberry Pi in assembly?

Post by lidnariq »

Espozo wrote:I'm assuming [moving the video scaler from inside the monitor to inside the GPU] never actually took place, because I've used TVs with such underpowered processors that it feels like there is a third of a second of input lag. What kind of hardware does the average 1080p TV have, or would it vary to much to accurately guess? Is it just some off the shelf ARM processor?
What? It's in every laptop. Probably most cell phones. As a result, it's in your desktop GPU also, because laptops are where the volume market is.

Whatever flat panel LCD monitor you have probably has its own scaler also.

While it's possible that the device inside your television might use an older style in-order framebuffer, honestly the lag is there because they have no reason to avoid it. It's simply not something that's important to the mass market. And it does let them do some limited acausal image processing, which they think looks/sells better.
Oziphantom
Posts: 1565
Joined: Tue Feb 07, 2017 2:03 am

Re: Is it possible to program Raspberry Pi in assembly?

Post by Oziphantom »

lidnariq wrote:The NES has quite possibly the simplest programmer's interface in a mass produced full-featured computer (by which I mean "a device with input from dedicated multikey input device and outputs to a screen") to ever have existed.

With only 30ish total configuration registers to describe its total functionality, various Dubious Choices are practical (such as Bregalad's insistence that it is obfuscatory to name those registers instead of just using addresses) in ways that would be laughable on practically every other computer.
I'm going to say the C64, while it does have more registers at 110, it also has a Kernal which will set up the machine to a known state and then let you take over if you want, or you can go purest bare metal and do everything yourself, or just call the Kernal when you need it. Everything is in a flat memory model, there is no you need to write this register twice to make it set some hidden internal thing, no magic write to this register and it will DMA sprite data to and from here, no separated memory model of CODE here and PPU data over there and you can't see it. Everything is in the CPU space and you can change whatever you want whenever you want. And it has built in Character Font.
Oziphantom
Posts: 1565
Joined: Tue Feb 07, 2017 2:03 am

Re: Is it possible to program Raspberry Pi in assembly?

Post by Oziphantom »

Bregalad wrote:
Python is very worth knowing as well; widely used and productive in appropriate applications. Surprised by the suggestion about Pascal, but maybe you operate in circles where it is more commonly used. I'd definitely learn it if it was in my path. I can't think of a programming language I've ever regretted learning.
I'm in the process of learning Python those days. This makes me never want to code in C++ ever again, (and probably neither C, although it's not as bad because at least the feature creep is limited). It really shows how it's better when they thought of the language as a whole from the start instead of piling up new features on existing grammar that was never meant to support them in the 1st place.
oh please... Python is a "oh look a shiny lets chase it" language if I ever saw one... I mean to be clear here which Python are you learning 2.x or 3.x ? now is it append on a list adds the items in the list to the list or is += that does it, or do you append if you already have it in a list but += if you don't have it in a list to make sure it gets added as a single item into the existing list? The Class is a tack on, not really a feature of the language its more "we can abuse this to do X", enums are hack of a hack, isinstance is a global function not a member function, len is also a global. How do you make an iterator, you just throw an exception when you are done... so if you want to trap exceptions to find a bug well you get one every loop because somebody decided to use an "exception" for something that is a foregone conclusion and also the whole programming paradigm of the language...

c++17 still builds c++89 get new version of VS or GCC hit build carry on ;) Yes C++ has some tacked on things, metatemplates for example. but you can easily just ignore them and carry on.
Oziphantom
Posts: 1565
Joined: Tue Feb 07, 2017 2:03 am

Re: Is it possible to program Raspberry Pi in assembly?

Post by Oziphantom »

Espozo wrote:
adam_smasher wrote:OISC
Wtf? :lol:
lidnariq wrote:Modern framebuffers often aren't linear in-order chunks of memory anymore.
How are they then? I thought a framebuffer was just a giant area of memory with each row of pixels onscreen being at a different offset in the framebuffer.
This is true and not true.

PowerVR based GPUs use "tiled" rendering, this means the GPU makes buckets and once a bucket has enough changes it will then process that "tile" and update the screen. This allows it to save on power, which is nice for batteries and for Thermals. So anything that is basically a mobile phone has this type of GPU, the Pi is basically a like a mobile phone. the Dreamcast has a PowerVR GPU and the PS2 has a similar architecture and its like lots and lots of little triangles.

On a windows PC with a Geforce anything... its has the bandwidth, thermal and power that you can just throw a 1080p linear frame buffer down the bus each frame and be done with it.
User avatar
Bregalad
Posts: 8056
Joined: Fri Nov 12, 2004 2:49 pm
Location: Divonne-les-bains, France

Re: Is it possible to program Raspberry Pi in assembly?

Post by Bregalad »

Espozo wrote:Why does the S-DSP have so many?
Most of the S-DSP is actually a matrix, 8x10 registers which are identical for all 8 sound channels. Only a handful of registers are common to all channels, and many of those actually have one bit per channel. Ignoring the dupplicate between sound channels, the S-DSP has maybe 20-30 registers at most.
I don't know, maybe there's actually an interesting point to made that C is the "unhappy medium", too many abstractions over the hardware for...something... but simultaneously too few abstractions to make things easy.
I fully agree with this statement. C is not useful to do anything high-level quickly. And it's not good at optimizing for hardware level either - the only reason it optimizes to decent codes is because HUGE amount of effort went into doing this, not because the language facilitates it.
Do you think python runtime exceptions are easier to debug? (I do not.)
I am not yet experienced enough in python to answer, but so far the errors were a stack trace with the exact line of where the error happened, with a comprehensible error message. It would be hard to imagine anything more practical.
My point was that knowing C++ puts food on my plate. There's a lot of companies right now that need people who can use C++.
Well that's great for you. If my boss, or your boss, or anyone else's boss, asks for a project to be written in C++ because it's a project requirement or whatever reason, that's fine. I wouldn't care having a job where I had to code in C++ only, if I'm being paid. However, we're talking about free time, homebrew project. There's zero reason to force you to use a painful language just because it's used in the industry - at home you're doing this for fun and want to maximize the efficiency you get out of your sparce free-time. C++ is a poor choice in my opinion, here, but if you're using it at work it helps you to be fluent because of habbit - but rememer, it's not the case of everyone else !
oh please... Python is a "oh look a shiny lets chase it" language if I ever saw one... I mean to be clear here which Python are you learning 2.x or 3.x ? [...]
I'm learning 3.x, and also, I never pretend Python was perfect or anyhting, just like it fixes a LOT of problem C++ had. I lack experience to juge the language, maybe I'll come some time later saying that it's a piece of shit, I don't know. At first glance it looks infinitely superior to C++, getting rid of limitations that were imposed by the language for no real reason other than backwards compatibility with the earlier C, which in itself came with many issues.

The fact 3.x is not backwards compatible with 2.x is actually a good thing and show courrage from the development team actually. C++ is bad because it's a pile of stuff designed with backwards compatibility in mind, in the end it becomes too messy. By admitting "we've handled it wrong in 2.x, let's fix it", they restart anew and don't keep things the wrong way.
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Is it possible to program Raspberry Pi in assembly?

Post by tepples »

Bregalad wrote:Most of the S-DSP is actually a matrix, 8x10 registers which are identical for all 8 sound channels.
There aren't subtle differences like on the 2A03 APU, whose sweep unit's carry behavior differs between its two pulse channels, are there?
Bregalad wrote:I wouldn't care having a job where I had to code in C++ only, if I'm being paid. However, we're talking about free time, homebrew project. There's zero reason to force you to use a painful language just because it's used in the industry - at home you're doing this for fun
Until an employer decides whether the skills you show are a good match for a position by looking at what technologies are used in your hobby projects with source code published on Savannah, GitHub, or SourceForge.
Bregalad wrote:The fact 3.x is not backwards compatible with 2.x is actually a good thing and show courrage from the development team actually.
I think a lot of the hate for 3.x was because 3.0 through 3.2 had no easy way to share a Windows PC with 2.6/2.7. Side-by-side installation of Python 2 and 3 was practical on a FreeBSD or GNU/Linux PC, as those use #!/usr/bin/env python3 at the top to specify a Python version. But Windows associated the .py and .pyw extensions with only one interpreter. This was fixed with the implementation of PEP 397 in Python 3.3 and later, where .py and .pyw are associated with a shim program py.exe that looks at the first line of a file to determine which interpreter to run.
User avatar
Bregalad
Posts: 8056
Joined: Fri Nov 12, 2004 2:49 pm
Location: Divonne-les-bains, France

Re: Is it possible to program Raspberry Pi in assembly?

Post by Bregalad »

tepples wrote: There aren't subtle differences like on the 2A03 APU, whose sweep unit's carry behavior differs between its two pulse channels, are there?
As far as I know, the only difference is that the first channel (I don't know wether it should be called channel 0 or channel 1) cannot have pitch modulation.
Until an employer decides whether the skills you show are a good match for a position by looking at what technologies are used in your hobby projects with source code published on Savannah, GitHub, or SourceForge.
I do not think knowing C++ and being proficient in another language is worse than being proficient in C++ only. The fact your tools are related to gaming is probably a worse signal than the language you use to write them.
Post Reply