+ 2

Assembly question about multiple architecture

Hi, I have a few question below, if you are experienced in this theme, please help me about this problems What processor architectures are there? How can developers write assembly code for multiple architectures at once, for example ... Meaning the same application / task. Is the whole code being rewritten to separate architecture types, or exactly how does it work?

1st Mar 2022, 1:40 PM
Domonkos Gyömörey
Domonkos Gyömörey - avatar
10 Respostas
+ 2
you can use NASM to assemble the code for RPi 4. the issue you were having, is about using the right instruction set for ARM 64bit. normally the manufacturer of the cpu releases the manual of the cpu which contains the instructions and their usage and how they affect the registers/flags.
1st Mar 2022, 7:05 PM
Bahhaⵣ
Bahhaⵣ - avatar
+ 2
Hi again :) Assembly language is not portable, each cpu architecture has its own instructions. so for every architecture you have to write its code. about processor architectures there are many, the most popular are: intel 32-bit (x86) and 64-bit (x86-64, IA64, and AMD64). for most handheld devices and embedded systems they use ARM. there are also many versions and variants of ARM. I can't list all of them. in general Processor architectures are classified as either a Reduced Instruction Set Computer (RISC) or as a Complex Instruction Set Computer (CISC). The difference between the two classifications is that RISC architectures have a small number of simple general purpose instructions that each perform one single operation, essentially providing the basic building blocks for computations. CISC architectures , on the other hand, have a large number of more complex instructions, that are each capable of performing multiple internal operations.
1st Mar 2022, 6:24 PM
Bahhaⵣ
Bahhaⵣ - avatar
+ 2
I'd suggest you try something like. LC3 simulator, it has a small number of instructions to familiarize yourself with memory and cpu registers. then you can move to intel 32bit then to 64bit architecture. it also depends on what operating system you are using. LC3 simulator ref: https://castle.eiu.edu/~mathcs/mat3670/index/Webview/pennsim-guide.html or https://github.com/chiragsakhuja/lc3tools
1st Mar 2022, 6:41 PM
Bahhaⵣ
Bahhaⵣ - avatar
+ 2
here are the instructions for the cpu used in raspberry pi 4 : don't be overwhelmed by the size of it. in assembly you can use a small number of instructions to do many things. for example intel's manual is more than 4k pages, but you only use a handful of instructions and registers. https://documentation-service.arm.com/static/613a2c38674a052ae36ca307?token=
1st Mar 2022, 7:15 PM
Bahhaⵣ
Bahhaⵣ - avatar
+ 2
you check the specs of the computer you're using, the cpu type is always mentioned. on Linux you can run: cat /proc/cpuinfo
1st Mar 2022, 7:31 PM
Bahhaⵣ
Bahhaⵣ - avatar
+ 1
Thank you the lot of help
1st Mar 2022, 7:35 PM
Domonkos Gyömörey
Domonkos Gyömörey - avatar
0
If I work with ARMv6 architecture(raspberry pi 4 model b) what compiler can I use, or what do you suggest me for this architecture?
1st Mar 2022, 6:56 PM
Domonkos Gyömörey
Domonkos Gyömörey - avatar
0
Anyway thank you the lot of information about this post
1st Mar 2022, 6:57 PM
Domonkos Gyömörey
Domonkos Gyömörey - avatar
0
Thank you for the comments, tips, for this post
1st Mar 2022, 7:10 PM
Domonkos Gyömörey
Domonkos Gyömörey - avatar
0
Someway can I detect the cpu architecture with a program and after compile the right assembly type?
1st Mar 2022, 7:22 PM
Domonkos Gyömörey
Domonkos Gyömörey - avatar