Path: news1.icaen!news.uiowa.edu!news.physics.uiowa.edu!math.ohio-state.edu!cs.utexas.edu!cpk-news-hub1.bbnplanet.com!news.bbnplanet.com!europa.clark.net!news.maxwell.syr.edu!visi.com!not-for-mail From: nathan@visi.com (Nathan Mates) Newsgroups: comp.sys.apple2.programmer Subject: Re: mvn Date: 17 Apr 1997 07:35:08 GMT Organization: Vector Internet Services, Inc. Lines: 37 Message-ID: <5j4jrc$gs6$1@darla.visi.com> References: <5j4g0e$10q$1@enyo.uwa.edu.au> NNTP-Posting-Host: thumper.visi.com In article <5j4g0e$10q$1@enyo.uwa.edu.au>, Joseph Turner wrote: >Hi all, I have a question regarding the MVN instruction. [snip] >ldx #$2000 >ldy #$2000 >lda #$7cff >MVN $01,$E1 (source, destination syntax for assembler) Ok, if you're using Orca/M (I think you are based on past posts; not totally sure), that code will slam around stuff in bank 0. This is because the mvn (and mvp) instruction has an implicit 'use the bank byte of the operands'. Yeah, counterintuitive after sitting around in the miniassembler, etc. So, your mvn line of code should look like: "mvn $010000,$E10000' (or anything else after the 01 and e1 since it's ignored. "ldx #0 ldy #0 lda #$7D00-2 mvn $012000,$e12000" will generate code to slam stuff around starting at the start of the bank, another reason why Orca/M syntax is counterintuitive. Next, if you read a reference on the 65816, the mvn/mvp instructions set the data bank register to the destination bank of the mvn/mvp. Thus, after doing the code right as suggested above, the bank will be $e1. Either wrapper the mvn with a phb/plb (recommended, more correct) or do a phk/plb (lazy asm-only form if you know that b==k at all normal times in your code) after the mvn. Nathan Mates -- <*> Nathan Mates http://www.visi.com/~nathan/ <*> # What are the facts? Again and again and again-- what are the _facts_? # Shun wishful thinking, avoid opinion, care not what the neighbors # think-- what are the facts, and to how many decimal places? -R.A. Heinlein Path: news1.icaen!news.uiowa.edu!news.physics.uiowa.edu!math.ohio-state.edu!uwm.edu!newsfeeds.sol.net!europa.clark.net!cpk-news-hub1.bbnplanet.com!news.bbnplanet.com!ais.net!visi.com!not-for-mail From: nathan@visi.com (Nathan Mates) Newsgroups: comp.sys.apple2.programmer Subject: Re: mvn Date: 17 Apr 1997 08:36:34 GMT Organization: Vector Internet Services, Inc. Lines: 36 Message-ID: <5j4nei$kr1$1@darla.visi.com> References: <5j4g0e$10q$1@enyo.uwa.edu.au> <5j4jrc$gs6$1@darla.visi.com> <5j4m00$39m@chronicle.concentric.net> NNTP-Posting-Host: thumper.visi.com In article <5j4m00$39m@chronicle.concentric.net>, ERICLOB wrote: [Re: using mvn to copy from 012000.7CFF to E12000...] >> So, your mvn line of code should look like: "mvn $010000,$E10000' >And shouldn't you be using MVP to move the data to a higher bank of >memory? Bank numbers have no effect on the choice of mvn/mvp; both can handle any set of banks for src and dest just fine. How the differ is the method they copy data. Mvn starts at the specified address and copies up from there, mvp starts at the specified address and copies down from there. If you've calculated your parameters correctly, and your start/dest ranges do not overlap, there is no functional difference between mvn and mvp. However, when they overlap, if you don't want to replicate the overlap, you have to consider which way the copy goes. Consider the case of moving 254 bytes of memory from $2000 to $2002 in the same bank. If you copy (16 bits wide) $2000 -> $2002, $2002 -> $2004, you're going to fill the whole range with whatever 16-bit value was at $2000. However, if you copy $20FC -> $20FE, $20FA -> $20FC, etc, the original pattern is left intact. Thus, you'd want to use mvp here, with src=$20FC, dest=$20FE, len=$FE. Copy the other way, $2002 to $2000, use mvn to do this correctly, with src=$2002, dest=$2000, len=$FE. Nathan Mates -- <*> Nathan Mates http://www.visi.com/~nathan/ <*> # What are the facts? Again and again and again-- what are the _facts_? # Shun wishful thinking, avoid opinion, care not what the neighbors # think-- what are the facts, and to how many decimal places? -R.A. Heinlein