MOS 6502

(MOS 테크놀로지 6502에서 넘어옴)

MOS 6502MOS 테크놀로지사의 8비트 MPU이다. 모토로라의 6809계열의 CPU로 분류되며 명칭 또한 인텔 계열이 CPU(중앙 처리 장치)라는 단어를 사용한 데 반해, 모토로라 계열은 MPU(Main Processing Unit)라는 용어를 사용한다.

6502 칩

프로세서 레지스터 개수가 인텔 계열의 CPU에 비해 적으나, 제로 페이지라는 메모리 에리어 중 특수한 영역을 임시 기억공간으로 활용하여 프로세서 레지스터 부족분을 메운다. 입출력을 위한 주소 공간이 별도로 준비되어 있지 않기 때문에 메인 메모리의 일정 부분을 입출력으로 사용하는 메모리 맵 입출력 방식으로 동작한다.

예제 코드

; TOLOWER:;; Convert a null-terminated character string to all lower case.; Maximum string length is 255 characters, plus the null term-; inator.;; Parameters:;; SRC - Source string address; DST - Destination string address;        ORG $0080;0080 00 04 SRC .WORD $0400 ;source string pointer ($40)0082 00 05 DST .WORD $0500 ;destination string pointer ($42);0600 ORG $0600 ;execution start address;0600 A0 00 TOLOWER LDY #$00 ;starting index;0602 B1 80 LOOP LDA (SRC),Y ;get from source string0604 F0 11 BEQ DONE ;end of string;0606 C9 41 CMP #'A' ;if lower than UC alphabet...0608 90 06 BCC SKIP ;copy unchanged;060A C9 5B CMP #'Z'+1 ;if greater than UC alphabet...060C B0 02 BCS SKIP ;copy unchanged;060E 09 20 ORA #%00100000 ;convert to lower case;0610 91 82 SKIP STA (DST),Y ;store to destination string0612 C8 INY ;bump index0613 D0 ED BNE LOOP ;next character;; NOTE: If .Y wraps the destination string will be left in an undefined; state. We set carry to indicate this to the calling function.;0615 38 SEC ;report string too long error &...0616 60 RTS ;return to caller;0617 91 82 DONE STA (DST),Y ;terminate destination string0618 18 CLC ;report conversion completed &...0619 60 RTS ;return to caller;                       .END

같이 보기