Keil Factorial Program

김선우·2022년 9월 12일
0

Microprocessors

목록 보기
4/7

다음 내용은 microprocessors class Tut3이다.
1. The factorial program is given as follows:
AREA Prog2, 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 r6, r4, r6 ; perform multiply
BNE loop ; go again if not complete
stop B stop
END

이를 Build 한 후 디버깅 해보면,






The first six machine codes are as follows:
0xE3A0600A
0xE1A04006
0xE2544001
0x10060694
0x1AFFFFFC
0xEAFFFFFE

Machine code를 손으로 계산할 수 있지만,
tedious,
error-prone
한다는 점!
따라서, 우리는 keil과 같은 tool을 사용한다.

아래가 끝까지 F11 눌렀을 때 register r6 value이다.

그 후에 stop debugging을 눌러줘야한다.

1(b) When the initial value of r6 is changed to 12,
the program calculates 12 factorial.
Re-build the new program, and re-run the code.
The value in r6 will be 0x1C8CFC00.
(Note: 12! = 479001600 = 0x1C8CFC00)

mov r6, #10을 mov r6, #12로 바꾸고, 다시 rebuild 한다.

debugging을 한 후 , F11 연타해서 최종 결과를 얻으면 원하는 결과가 나왔음을 확인할 수 있다.

profile
배고파...

0개의 댓글