PicoWeb Pcode Instruction Definitions (v1.34)

All pcode instructions take one of the following forms:

opcode

 

opcode

p1

opcode

p1,p2

opcode

p1,p2,p3

where:

opcode

pcode opcode listed in one of the PicoWeb pcode instruction tables

p1-p3

pcode operand (p1, p2, p3) shown in the PicoWeb pcode instruction tables

All pcode operands (p1, p2, p3) may be expressed in one of seven different forms, one normal form, three different indirect forms, and three different string literal forms, as follows:

p

effective operand is 16-bit value p (normal form)

[p]

effective operand is 16-bit word stored beginning at SRAM address p

[byte p]

effective operand is 8-bit byte stored at SRAM address p

[swap p]

effective operand is 16-bit word at SRAM address p with high/low bytes swapped

"..."

effective operand is address of character string ("...") in the current code segment (.cseg or .eseg)

cseg "..."

effective operand is address of character string ("...") in program memory (.cseg)

eseg "..."

effective operand is address of character string ("...") in external SEEPROM memory (.eseg)

Warning: If any of the indirect operand forms are used in a given pcode instruction instance, then the size of any (and all) immediate (i.e., imm operands) operands used in that pcode instruction instance is reduced from 16 bits to 14 bits.

Notes regarding the PicoWeb pcode tables which follow:

 

PicoWeb Pcode General Purpose Instructions

Opcode

p1

p2

p3

Description

Operation

Flags

paddwi

a

imm

 

Add immediate to word

* a = * a + imm

Z,C,N

pandwi

a

imm

 

Logical AND word immediate

* a = * a & imm

Z,N

pbegin

     

Begin executing pcode

rcall pcode

 

pbitwi

a

imm

 

Bit test word immediate.

* a & imm

Z

pcall

addr

   

Call pcode routine

push ppc onto pcode return stack; ppc = addr

 

pclrw

a

   

Clear word

* a = 0

 

pcmpbi

a

imm

 

Compare byte immediate

a[0] - low(imm)

Z,C,N

pcmpn

a

b

n

Compare two buffers in SRAM

for (i=0; i<n; ++i) a[i] - b[i];

Z

pcmpwi

a

b

 

Compare word immediate.

* a - imm

Z,C,N

pcomw

a

   

Ones complement word.

* a = 0xFFFF - * a

Z,C,N

pdecw

a

   

Decrement word

* a = * a - 1

Z,C,N

pdiv

a

b

c

Unsigned 16-bit divide, 32-bit result

* a = * b / * c;

* (a+2) = * b % * c;

 

pend

     

Stop executing pcode

.dw 0

 

pincw

a

   

Increment word

* a = * a + 1

Z,C,N

pjump

addr

   

Unconditional jump within pcode

ppc = addr

 

pjumpeq

addr

   

Jump within pcode if equal

if (Z == 1) ppc = addr

 

pjumplo

addr

   

Jump within pcode if lower

if (N == 1) ppc = addr

 

pjumpne

addr

   

Jump within pcode if not equal

if (Z == 0) ppc = addr

 

pmemcpy

a

b

n

SRAM memory copy

for (i=0; i<n; ++i) a[i] = b[i];

 

pmovb

a

b

 

Move byte

a[0] = b[0]

 

pmovbi

a

imm

 

Move byte immediate

a[0] = low(imm)

 

pmovwi

a

imm

 

Move word immediate

*a = imm

 

pmul

a

b

c

Unsigned 16-bit multiply, 32-bit result

*a = (*b ´ *c) & 0xFFFF;

*(a+2) = (*b ´ * c) >> 16

 

pnegw

a

   

Two’s complement word

* a = 0 - * a

Z,C,N

pret

     

Return from pcode routine

ppc = pop pcode return stack

 

pshnw

a

n

 

Logical shift 16-bit word n bits

if (n > 0) * a = (* a << low(n))

else * a = (* a >> low(n));

 

psubwi

a

imm

 

Subtract word immediate

* a = * a - imm

Z,C,N

pwdr

     

Watchdog timer reset

wdr

 

pxorwi

a

imm

 

Exclusive OR word immediate

* a = * a ^ imm, set flags with low(* a)

Z,N

Notes:

 

PicoWeb Pcode Input/Output Instructions

Opcode

p1

p2

p3

Description

Operation

Flags

pcrlf

     

Print CR,LF

printf("\r\n")

 

phexbi

a

   

Print hex byte immediate

printf("%02x", (a & 0xFF))

 

pprint

s

   

Print string

printf("%s", s)

 

pprintb

s

a

n

Print bytes in hex with string

if (s != 0) printf("%s", s);

for (i=0; i<n; ++i) printf("%02x", a[i]);

 

pprintv

s

imm

 

Print string with 16-bit hex value

if (s != 0) printf("%s", s) else putchar(‘ ‘);

printf("%04x", imm);

 

pputc

imm

   

Print character immediate

putchar(imm & 0xFF);

 

pputcb

a

   

Print character

putchar(a[0] & 0xFF);

 

pser_getc

a

   

Check/get serial port character

if (character ready) a = getchar(), Z = 0

else Z = 1;

Z

pser_mode

bin

   

Flush and set serial port mode

Flush any buffered characters, then if (bin = 0) set normal mode; else set pass-all (binary) mode

 

pser_putc

imm

   

Write immediate byte to serial port

Wait for a "transmit done" indication on serial port, then write low(imm) to UART

 

pspace

     

Print a space

putchar(‘ ‘)

 

Notes:

 

PicoWeb Pcode Network Instructions

Opcode

p1

p2

p3

Description

Operation

Flags

paddn

a

b

n

Add n-byte integers (network byte ordering)

CF = 0; for (i=low(n)/2-1; i¹ 0; i-=1) * (a+2*i) = swap(swap(* (a+2*i)) + swap(* (b+2*i)) + CF);

 

pf2x

off

func

n

Output bytes to Ethernet transmit buffer starting at byte off with checksum

for (i=0; i<n; ++i) Xmit[off + i] = func(); where func returns 16-bit word in X register. A 16-bit network checksum accumulated into "chkacc".

 

pi2x

off

imm

 

Output immediate 16-bit word to Ethernet transmit buffer at byte off

Xmit[off] = imm

 

pprinta

s

eadd

n

Print bytes from Ethernet receive buffer with label

if (s != 0) printf("%s=", s);

for (i=0; i<n; ++i) putchar(Recv[eadd + i]);

 

pprintr

s

off

n

Print words in hex from current receive buffer with label

if (s != 0) printf("%s=", s); for (i=0; i<2*n; ++i) printf("%02x", Recv[off + i]);

 

pprintt

s

off

n

Print words in hex from current transmit buffer with label

if (s != 0) printf("%s=", s); for (i=0; i<2*n; ++i) printf("%02x", Xmit[off + i]);

 

pr2s

a

off

n

Move bytes from current Ethernet receive buffer to memory

for (i=0; i<n; ++i) a[i] = Recv[off + i];

 

pr2x

off1

off2

n

Move bytes from current Ethernet receive buffer to Ethernet transmit buffer.

for (i=0; i<n; ++i) Xmit[off1 + i] = Recv[off2 + i];

 

ps2x

off

a

n

Move bytes from memory to Ethernet transmit buffer

for (i=0; i<n; ++i) Xmit[off + i] = a[i];

 

px2s

a

off

n

Move bytes from Ethernet transmit buffer to memory

for (i=0; i<n; ++i) a[i] = Xmit[off + i];

 

pz2x

off

n

 

Write zero bytes to transmit buffer

for (i=0; i<n; ++i) Xmit[off + i] = 0;

 

Notes:

10/23/99 11:28 AM