ARM Technical Support Knowledge Articles

RUNNING CODE FROM IDATA

Applies to: C166 C Compiler

Answer


Information in this article applies to:


QUESTION

I'm using the Siemens 80C166/C167 and I want to copy code (that changes bus modes) from ROM to the on-chip RAM and execute it there. How can I do this?

ANSWER

The following code example executes code in the on-chip RAM to switch CPU modes from 8 to 16 bit and/or mux to non-mux. According to Siemens specification, this must be exectuted in on-chip RAM. The code copied can only contain relative addressing.

;----------------------------------------------------------
; This copies the mode switch subroutine to internal RAM
; (it must be executed there as per Siemens spec)
;
; The following code is written into internal RAM
;
;$FC2E:
;  AND P2,01FFh                 ; set output port on PRO166/7
;  MOV SYSCON,  04FFh           ; set CPU mode
;  NOP                          ; give it time to settle (REQUIRED)
;  RET                          ; return to external memory execution
;----------------------------------------------------------

                MOV     R6,#0FC2EH              ; destination in on-chip RAM

                MOV     R5,#0E066H              ; Opcode: AND P2,
                MOV     [R6],R5
                ADD     R6,#02H

                MOV     R5,# 0001111111111111b  ; Data: Port 2 non-mux,16-bit, norom
                MOV     [R6],R5
                ADD     R6,#02H

                MOV     R5,#086E6H              ; Opcode: MOV SYSCON,
                MOV     [R6],R5
                ADD     R6,#02H

                MOV     R5,#04FFH               ; Data: Fast 16-bit non-mux
                MOV     [R6],R5
                ADD     R6,#02H

                MOV     R5,#0CCH                ; Opcode: NOP
                MOV     [R6],R5
                ADD     R6,#02H

                MOV     R5,#0CBH                ; Opcode: RET
                MOV     [R6],R5

                CALLA   cc_UC,0FC2Eh            ; execute snippet in internal RA

MORE INFORMATION

SEE ALSO

Article last edited on: 2005-06-01 12:56:21

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential