Assembly language start!

김선우·2022년 9월 7일
0

Microprocessors

목록 보기
1/7

아래의 예시 코드를 통해 assembly language를 start해보자.
AREA Prog1, CODE, READONLY
ENTRY

MOV r6, #10 ; load 10 into r6
MOV r4, r6 ; copy n into a temp register
loop SUBS r4, r4, #1 ; decrement next multiplier
MULNE r7, r6, r4 ;perform multiply
MOV r6, r7
BNE loop ;go again if not complete
stop B stop ;stop program

END
*위의 blue 글자는 assembler directives 라고 한다.
-> assembler directives: 1) x converted into machine codes
2) x executed by processor.
위의 green 글자는 arm microprocessor의 instructions이다.
Assembler Directives
1. AREA - for assembler to create a block of code in memory.
2. CODE - The block created is a set of instructions
3. READONLY - The block is read-only, which means it cannot be written into.
4. ENTRY - it is the point where the program starts execution.
5. END - End of program, the assembler will ignore all other instructions after the END statement.

따라서, AREA Prog1, CODE, READONLY 는 assembler가 readonly인 Prog1이라는 code block을 create 한다는 뜻이다.

General Form
Source line의 general form은 아래와 같다.
{label} {instruction | directive | pseudo-instruction} {;comment}
-braces는 안붙여도 된다.
-labels는 address를 나타낸다.

위에서 MOV instruction에 대해서 알아보자.
MOV - Move register or constant이다.
따라서, MOV r6, #10은 load 10 into r6이라는 뜻이다.

profile
배고파...

0개의 댓글