게시판 즐겨찾기
편집
드래그 앤 드롭으로
즐겨찾기 아이콘 위치 수정이 가능합니다.
ARM 어셈블리 명령어에 대해 궁금한 점이 있습니다.
게시물ID : programmer_6214짧은주소 복사하기
작성자 : mutee
추천 : 0
조회수 : 1179회
댓글수 : 2개
등록시간 : 2014/10/28 02:50:47
어떠한 레지스터에 mov명령어를 통해 상수값을 넣으려면 "쉬프트된 8비트 상수값"을 넣어야 된다고 합니다.

예를 들어 0xc21, 0x101같은건 illegal하지만 0xff0, 0x1c00, 0xc20같은건 괜찮다 이거죠.

There are quite a few traps for the unwary - apart from the shift in thought process needed to code assembler, of course. The first of these is that loading a value into a register requires some thought. You can only load values with "mov" that are shifted 8 bit values - 0xff0, 0x1c00, but not 0x101, for example. There is a psuedo opcode to get around this easily - "ldr r1, =0x101" for example - but it may bite you if you didn't know this. The error would look like this "Error: invalid constant (101) after fixup", just in case you were wondering.

The most common example of this is the mov instruction, which only allows numbers which can be represented as an 8 bit number, shifted left by an even number. For example c2116 = 1100 0010 00012 and so cannot be represented in a mov, but c2016 = 1100 0010 00002 = 1100 00102 << 4, and so is valid in a mov. Much the same rules apply to most constants in functions. Remember, to load in any constant, use ldr r0,=value.

위 글은 이 규칙에 대한 설명인데 제 머리론 잘 이해가 되지 않는군요.
대안으로 ARM에서 LDR을 이용한 방법도 설명해놓긴 했지만 이 부분을 제대로 이해 못하고 넘어가면 안될 것 같아서요.
저는 0xE0A8F라는 값을 꼭 넣어보고 싶은데 위 룰에 걸려서 아무것도 못하고 있네요..ㅜㅜ

0xc21 ->        1100 0010 0001 (no)
0xc20 ->        1100 0010 0000 (yes)
0x101 ->        0001 0000 0001 (no)
0xff0 ->        1111 1111 0000 (yes)
0x1c00 -> 0001 1100 0000 0000 (yes)
전체 추천리스트 보기
새로운 댓글이 없습니다.
새로운 댓글 확인하기
글쓰기
◀뒤로가기
PC버전
맨위로▲
공지 운영 자료창고 청소년보호