|
Different assemblers can have different assembler syntax
For writting ARM assembler programs, you can use the ARM assembler or the GNU assembler - each have a different syntax.
Here's what an ARM assembler program looks like (you don't need to understand the code, just observe the difference between the way things are expressed):
; Simple ARM syntax example
;
; Iterate round a loop 10 times, adding 1 to a register each time.
AREA ||.text||, CODE, READONLY, ALIGN=2
main PROC
MOV w5,#0x64 ; W5 = 100
MOV w4,#0 ; W4 = 0
B test_loop ; branch to test_loop
loop
ADD w5,w5,#1 ; Add 1 to W5
ADD w4,w4,#1 ; Add 1 to W4
test_loop
CMP w4,#0xa ; if W4 < 10, branch back to loop
BLT loop
ENDP
END
|
This is how the same assembler program looks like in GNU assembler syntax:
// Simple GNU syntax example
//
// Iterate round a loop 10 times, adding 1 to a register each time.
.section .text,"x"
.balign 4
main:
MOV w5,#0x64 // W5 = 100
MOV w4,#0 // W4 = 0
B test_loop // branch to test_loop
loop:
ADD w5,w5,#1 // Add 1 to W5
ADD w4,w4,#1 // Add 1 to W4
test_loop:
CMP w4,#0xa // if W4 < 10, branch back to loop
BLT loop
.end
|
The programs looks similar, but the difference in comment syntax will prevent the program to be compiled using a different assembler !!!
(Yes, it's a pain)