I am taking a class for ARM processors, and we are doing some Assembly code. I am not asking for code to be written for me, but more of an file formatting question. The assignment is to create simple math code functions in a single file.
Part of the assignment states: Use the .global directive to define your function names and start your code with:
.global .section .text :
So my code is:
.global _start
_start:
mov r0, #-5
mov r1, #10
.global max
.section .text
max:
cmp r0, r1 //Compare r0 and r1
movlt r0, r1 // If r1 > r0, set r0 to r1
bx lr //return from function call
.global min
.section .text
min:
cmp r0, r1 // Compare r0 and r1
movgt r0, r1 // If r1 < r0, set r0 to r1
bx lr // Return from function call
.global abs
.section .text
abs:
cmp r0, #0 //Compare r0 and 0
rsblt r0, r0, #0 // if less than 0 then -r0
bx lr // Return from function call
Is this the proper way to put multiple functions in one assembly code file?
I've tried different ways like putting the function names inline .global _start with a comma between each like
.global _start, max, min, abs and it compiles.
I also tried just having one .section .text and it also compiled.
I just don't know what the professor is asking for, and I may ask for clarification.
Thanks!
.text, no need to say it again;.global/.globloften allows multiple identifiers. But it is up to you as to what style you want to have in your source code.