Pic programming question

Hi

I am just getting into assembler pic programming, could someone answer me a quick question, MOVLW and MOVF, do they copy or move i want to now if i move the contents of w into a file will it also stay in w and vice a versa.

John

Reply to
JSW
Loading thread data ...

Yes, the value in W will not change. Same if you moved the value of a file register into W (provided it isn't a special function register).

Reply to
Gary Kato

why do most instruction sets call these operations "MOVE", when they're more like COPY? MOVE would be more like a FIFO.

--
	mac the naïf
Reply to
Alex Colvin

->>if i move

->>the contents of w into a file will it also stay in w and vice a versa.

-

->Yes, the value in W will not change. Same if you moved the value of a file

->register into W (provided it isn't a special function register).

-

-why do most instruction sets call these operations "MOVE", when they're

-more like COPY? MOVE would be more like a FIFO.

It's an assembly language convention from the early days. MOVE has always been non destructive to the source.

BAJ

Reply to
Byron A Jeff

Interesting question. I think when MOVE or MOV first became popular, the Windows (Mac?) dichotomy of Move vs. Copy hadn't been in people's minds. The early assembly languages usually used Load and Store instructions: you load into a register and store from a register. That is a nice distinction when going to/from memory, but doesn't make quite as much sense when going from register to register. I guess that is why the generic Move became popular.

As a side light, the PDP-8 minicomputer's only store instruction also cleared the accumulator! I guess you could call that a true move instruction, but DEC called it DCA - Deposit AC in memory and clear AC. Instead of a load, they simply had a TAD - two's complement add operand to accumulator. There were clear instructions and complement instructions, but no subtract -- a truly Reduced Instruction Set Computer!

Aside from those early days, instruction sets don't have a move in the sense that it leaves the source, EXCEPT for stack oriented architectures. That operation, though, is usually call a Stack Pop (which Motorola called "PULL" on some processors), not Move.

Thad

Reply to
Thad Smith

Thanks for your replies. Sorry for seeming a bit stupid, but just so I can get it 100% in my head can I ask you all another question?

MOVLW 6 MOVWF NUM1

MOVF NUM1,W ;I know that this moves 6 into W but does it also leave 6 in NUM1?

The reason I need to be 100% is because I want to continue using NUM1 knowing it has the value of 6 so I can compare it with a few different values.

Cheers JOHN

Reply to
JSW

I first became aware of MOVE instead of LOAD instructions with the PDP-11 instruction set. The assembly language style used there was referred to within DEC as "Nicaud notation" after the prominent Swiss (I think) computer scientist who invented it. AFAIK this was also the first widespread use of parentheses, at-sign and + and - to indicate operand addressing modes. When the 8080 came out with its backward operand order for MOV instructions, I heard an amusing story. Supposedly the original internal version of the assembly language used LD and STO, but then some marketing person thought that MOV was sexier. Since this was decided at the last minute, there was only time to change the instruction name but not the operand order in the assembler. There were of course still remnants of LD and STO in instructions like SHLD and LHLD.

Jim McGinnis

Reply to
Jim McGinnis
-

-Thanks for your replies.

-Sorry for seeming a bit stupid, but just so I can get it 100% in my head can

-I ask you all another question?

Ask away.

-

-MOVLW 6 ; Puts 6 into W

-MOVWF NUM1 ; Copies W (which has 6) into NUM1

-

-MOVF NUM1,W ;I know that this moves 6 into W but does it ;also leave 6 in NUM1? YES. Copies NUM1 into W

-The reason I need to be 100% is because I want to continue using NUM1

-knowing it has the value of 6 so I can compare it with a few different

-values.

That's exactly how it works. No move instruction modifies the source.

BAJ

Reply to
Byron A Jeff

Moves (copies? loads?) the literal value of 6 into the W register. The literal value of 6 retains its previous value. ;-)

Copies the contents of the W register into file location NUM1. The W register retains its previous value.

Assuming nothing else has been done, the W register already *has* the value 6. So the instruction is redundant. However, in any case, the value currently stored in file location NUM1 is copied into the the W register. The file location NUM1 retains its previous value.

Regards,

-=Dave

--
Change is inevitable, progress is not.
Reply to
Dave Hansen

That might explain some of the differences in the Z80 assembler instructions. Although pretty much everything became a load, never mind the destination. (Zilog's team were rogues from Intel, who later left Zilog but came back... A regular silicon-soap-opera: The Chips of Our Lives.)

--
Ron Sharp.
Reply to
Android Cat

Hmm, I'm not sure about that story. It would surprise me if anyone actually thinks MOV is sexy. I think it was to highlight the difference between MOV (reg to reg) and LD/ST (which were reg to/from mem). Makes it a tad bit easer on the programmer to find the instructions that access memory. Although MOV could indirectly address memory, the address first had to be loaded into H/L first.

Reply to
Gary Kato

Intel's rivals at that time (Motorola, TI, GI and National) were all working on chips that more closely resembled at least the style of the PDP-11. Compared to the older IBM-style assembly language, the PDP-11's really was sexy. Obviously changing the name of the 8080's data transfer instructions didn't alter its essential design, but it would have been the kind of thing a marketeer could ask for.

Reply to
Jim McGinnis

... snip ...

IIRC the LOD mmemnonic was used for the 8008, which was architecturally similar. The LD mnemnonic was used by Zilog in their expanded set for the Z80.

--
Chuck F (cbfalconer@yahoo.com) (cbfalconer@worldnet.att.net)
   Available for consulting/temporary embedded and systems.
     USE worldnet address!
Reply to
CBFalconer

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.