flat assembler
Message board for the users of flat assembler.

Index > Non-x86 architectures > How to start in ARM assembly?

Author
Thread Post new topic Reply to topic
system error



Joined: 01 Sep 2013
Posts: 670
system error 25 Dec 2016, 18:20
I am interested in starting a new experience in ARM assembly next year. Totally clueless questions;

1. What hardware do I need? Can I run it on my PC? Do I need an emulator like QEMU because I don't have Android Phones. My current phone is smart enough to have a small flashlight led attached to it. Useful though.
2. Do I need specialized SDK similar to Win Phone/CE SDK?
3. I read that there are too many ARM 'families' out there. Which one should I start with If I were to take the 64-bit path?

I got more questions but I'll ask later.
Post 25 Dec 2016, 18:20
View user's profile Send private message Reply with quote
system error



Joined: 01 Sep 2013
Posts: 670
system error 25 Dec 2016, 18:28
Ok like for example I want to print a "hello world" to screen. Whose screen because my screen resolution is 1600 x something wide. That screen or emulated screen or real android phones screen?
Post 25 Dec 2016, 18:28
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20303
Location: In your JS exploiting you and your system
revolution 25 Dec 2016, 18:29
system error wrote:
1. What hardware do I need?
Anything that is not locked down would be a good start. Many cellphones do not allow you to directly run assembly code so check before you buy.
system error wrote:
2. Do I need specialized SDK similar to Win Phone/CE SDK?
Maybe, if you want to interact with the OS. If you want bare-metal then you'll need more than an SDK, you'll need full system info.
system error wrote:
3. I read that there are too many ARM 'families' out there. Which one should I start with If I were to take the 64-bit path?
That will mostly depend upon the board you buy/have. You won't really be able to buy a CPU of your choice, you have to buy the whole board with CPU/SOC included. Well, that is unless you are planning to make a million or so units then you can buy your own CPU/SOC but that is a whole different thing.
Post 25 Dec 2016, 18:29
View user's profile Send private message Visit poster's website Reply with quote
system error



Joined: 01 Sep 2013
Posts: 670
system error 25 Dec 2016, 18:35
And my PC don't have touch screen either. If I were to run my code in an emulator, don't I need a touch device for that?

This is important because I'm considering to sell my laptop for some android smartphone. But before I do that, I need to test it first, at least in emulated environment. I am not rich you know.
Post 25 Dec 2016, 18:35
View user's profile Send private message Reply with quote
system error



Joined: 01 Sep 2013
Posts: 670
system error 25 Dec 2016, 18:42
revo, I'm having trouble understanding your explanations, or may be I am too clueless to get it. To cut it short,

What do you personally use to code ARM?
What is your recommendations for a clueless low-budget peasant like me?
Post 25 Dec 2016, 18:42
View user's profile Send private message Reply with quote
system error



Joined: 01 Sep 2013
Posts: 670
system error 25 Dec 2016, 18:52
I read things on the internet, but still don't get the bigger picture though.
Post 25 Dec 2016, 18:52
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20303
Location: In your JS exploiting you and your system
revolution 25 Dec 2016, 18:53
system error wrote:
What do you personally use to code ARM?
fasmarm, of course. And notepad2 to edit the sources. But then I don't program for phones or any consumer gear.
system error wrote:
What is your recommendations for a clueless low-budget peasant like me?
Some other users here have bought second hand equipment (Gameboy? Nintendo?) and written code for them. There are topics with code posted and some info on how to get it all up and running.
Post 25 Dec 2016, 18:53
View user's profile Send private message Visit poster's website Reply with quote
system error



Joined: 01 Sep 2013
Posts: 670
system error 25 Dec 2016, 18:56
But how do you test your source without the CPU?
Post 25 Dec 2016, 18:56
View user's profile Send private message Reply with quote
sleepsleep



Joined: 05 Oct 2006
Posts: 12742
Location: ˛                             ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣Posts: 0010456
sleepsleep 25 Dec 2016, 19:40
system error wrote:
1. What hardware do I need? Can I run it on my PC? Do I need an emulator like QEMU because I don't have Android Phones. My current phone is smart enough to have a small flashlight led attached to it. Useful though.

you could use qemu, https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Virtual_ARM_Linux_environment for a start

i would suggest using router with USB, flash with openwrt or etc firmware, they are less expensive and available in every pc shop or reuse old tp-link is fine too, try tp-link brand, they are the cheapest afaik,

or you could buy raspberry pi 3 and load it with windows 10 iot or linux arm, could explore both experiences

https://developer.microsoft.com/en-us/windows/iot/docs/kitsetuprpi
Post 25 Dec 2016, 19:40
View user's profile Send private message Reply with quote
system error



Joined: 01 Sep 2013
Posts: 670
system error 25 Dec 2016, 20:02
Setting up Qemu on Linux now... Thanks for the links. Now it's starting to make sense.
Post 25 Dec 2016, 20:02
View user's profile Send private message Reply with quote
MatQuasar



Joined: 25 Oct 2023
Posts: 105
MatQuasar 01 Mar 2024, 13:10
Sorry for hijacking this thread instead of starting a new topic.

This is my "Hello, world" Linux program in both ARM 32-bit and x86:
Code:
ARM (32-bit)                   x86 (32-bit)
   mov r0, #1           <----> mov ebx, 1
   ldr r1, =message     <----> mov ecx, message
   ldr r2, =len         <----> mov edx, len
   mov r7, #4           <----> mov eax, 4
   swi 0                <----> int 0x80

   mov r7, #1           <----> mov eax, 1
   swi 0                <----> int 0x80
    


I understand that ARM is a load / store architecture, hence the needs of LDR.
Post 01 Mar 2024, 13:10
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20303
Location: In your JS exploiting you and your system
revolution 01 Mar 2024, 15:19
"len" is a constant.
Code:
mov r2,len    
Post 01 Mar 2024, 15:19
View user's profile Send private message Visit poster's website Reply with quote
bzt



Joined: 09 Nov 2018
Posts: 77
bzt 12 May 2024, 22:33
system error wrote:
1. What hardware do I need? Can I run it on my PC? Do I need an emulator like QEMU because I don't have Android Phones.
Probably Raspberry Pi, cheap and likely the most well documented, easily hackable with a huge and helpful community.
Also works with qemu on your PC, see qemu-system-aarch64 -M raspi3b
system error wrote:
2. Do I need specialized SDK similar to Win Phone/CE SDK?
RPi comes with Linux (RaspiOS), so you can use the usual toolchain (on the ARM board), and FASMARM works too out-of-the-box (on your PC as a cross-compiler).
system error wrote:
3. I read that there are too many ARM 'families' out there. Which one should I start with If I were to take the 64-bit path?
Anything that claims to be ARMv8 and up. But yes, there are quite a lot, but the worst part is, there are even more incompatible SoC platforms (an ARM CPU in itself can't do much, you will need other chips as well, like an interrupt controller, a timer, input/output peripherals, etc. etc. etc. and with ARM this latter part isn't standardized at all. Basically it's as many standards as many vendors. RPi uses the Broadcom SoC, or BCM2711).

Here's a good tutorial, with lots of details, and easy to follow step-by-step explanations: https://github.com/bztsrc/raspi3-tutorial (also includes Makefiles to run the results in qemu).
For FASMARM examples specifically, take a look at https://github.com/PeterLemon/RaspberryPi (not much explanation, just Assembly code. The kernel7.asm is for ARMv7 (32-bit), and kernel8.asm is for ARMv8 (64-bit)).

Although keep in mind, that a simple "Hello world" is quite complicated and platform specific, it's not as easy as on x86 where you just write the characters and color codes at B8000h. What you'll need to do:
1. get the framebuffer address, pitch, packed pixel format (platform specific, on RPi you have to construct a MailBox message to the VideoCore GPU)
2. load somehow a bitmap font
3. render the glyphs yourself pixel by pixel to the framebuffer
As an example, take a look here (although C, but easy to follow, uses Linux's console font) or here (Assembly only, not much comments about the "why", just "how", but still good resource).

Because this is so complex, I suggest to program the UART instead first, and send characters to the serial line, that's several magnitude easier. If you add -serial stdio flag to qemu, then you'll see the the characters on the same terminal window that you have used to start qemu.

But if you're just interested in ARM Assembly, and not low-level ARM Assembly programming, then probably all you need is RaspiOS, and a FASMARM compatible source with format ELF64, and use the svc instruction to invoke Linux system calls. Downside that this probably won't work on qemu, or it's going to be painfully laggy at least.

Hope this helps,
bzt
Post 12 May 2024, 22:33
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.