You are naive with regards to assemblers, apparently, by your oen admission.
Assemblers are different than compilers, that go at great length to accomodate a standard language.
If you have a standard ISO c program chances are that it will run as is on different systems. Adding more of a utility to a program you will discover that you need a standard library that will e.g. read files that are vastly different from MS-Windows to Linux.
Even so, if you are presented with a standard program that runs on Linux, you will be at a loss using it on MS-Windows. You will have to learn how to use a compiler on MS-Windows. This could take up one hour, for very experienced people, to one week, or even a year.
The situation with assemblers is worse. Suppose you have understood the machine instructions well enough to craft a program. You will encounter the problem that although Intel has specified the instructions, few assemblers or only the Intel supplied assembler can handle your source. In fact every single assembler program creates its own dialect for Intel instructions (and there is a separate universe for ARM instructions.)
Notorious is that GNU insisted on calling the AX register %ax.
Then there is are the assembler directives. You pointed out "global" and "section". They are invented from whole cloth by the inventor of the assembler. As luck may have it there are certain convertions, but they are not much use to you, being inexperienced.
In my experience you can port a program in assembler and find 6000 errors in 13000 lines. This can be caused e.g. by different comment conventions, renaming registers, insisting that instruction are lower case, or the order of operands.
So you are surprised by finding that "global" is not understood? The first thing to get a manual for that as you are using and discover that "global" is not in there.
That is on top of the problem to run the assembler and use it to make a program, probably a separate link step. That is the difficulty that was familiar with running the c-compiler with a standard library, but on steroids.
If you plan to go on with learning assembly in this way you are advised to
goto
https://github.com/below/HelloSilicon
where there is a whole course, specifically targeting the Apple M1.
I cannot stress this enough, assembly language is specific, general advise doesn't cut it.
Buy the $50 book, study it, and go step by step.
An alternative is to use an embedded assembler. The idea is that you code a small snippet of code in an interpreter with a high level language.
You still have to be aware of register usage within that high level language.
This is done in C but the simplest is Forth.
I have written a dialect of Forth.
https://github.com/albertvanderhorst/ciforth
Within the AMD_64 release you can find the source code of an assembler in the library and an example how to use that to add e.g. floating point instructions to the high level interpreter.
CODE F+ FADDP, ST1| NEXT, END-CODE
You see here that the single, high-level instruction, F+ is defined, the code to add two floating pointer numbers.
CODE is invoking the assembler and END-CODE end this. You are talking to the interpreter of the high level language before and afterwards.
The assembler itself understands F+ FADDP, ST1| . NEXT, is a shorthand for instructions that are always the same and instructs the interpreter to go on with the next instruction.
That only illustrates the simplest possible use of assembly language for AMD_86 Unfortunately the example is not available for the ARM language, although ciforth has a 64 bits ARM compiler for Linux.
as --version
to find out what assembler is being used. – Donalt.
and the first two lines should have.global
and.section
. That is of course unrelated to the 32 vs 64 bit issue. – Donaltswi
instruction (it's calledsvc
there). You will need to obtain an arm64 tutorial. Do not try to port your ARM tutorial to ARM64 while following it. As for the toolchain, you somehow managed to install an x86 toolchain. Try to obtain an ARM toolchain. – Chromatophore