rddead
rddead

Reputation: 103

Incrementing port bits in assembly

As part of a project, I've been asked to write a program to take input from P1 and output it to P2. The obvious method is to just say

ORG 000H

MOV C, P1.0
MOV P2.0, C
MOV C, P1.1
MOV P2.1, C

...

And so on. But I want to do this with a loop by incrementing the port bits. How would I do that?

Upvotes: 0

Views: 1075

Answers (2)

RedSmolf
RedSmolf

Reputation: 380

There is a 'MOV direct, direct' instruction. In the manual I have OP 0x85 is MOV directly addressed data to a directly addressed location... i.e. MOV P0, P1

Upvotes: 2

Elijan9
Elijan9

Reputation: 1294

The 8051 instruction set does not provide such a bit-move instruction with intermediate source/destination. The MOV <dest-bit>, <srcibit> instruction only allows fixed values. See: 8051 MOV instruction

You can of course copy the complete (byte) content of P1 to P2 directly. Furthermore the 8051 byte-move instruction does provide an intermediate move via @R1 or @R2 that you could increment in a loop if you'd like to copy multiple ports.

Upvotes: 2

Related Questions