# Homework assignment 1 for CSCI 255 -- Spring 2000

- Due: Friday, 7 April, 12:00 noon

This is the first in a series of three small PIC programming assignment.
You may do this problem set in groups of three. Turn in *one*
assignment for the group. Include the names of all group members.

## The problem

You are to implement an ancient function for the PIC12C671. Your function
will receive an eight-bit number, `x`, in PIC register
`20h` and also "return" a result in the same register. If
`x` is even, your function should return `x`/2. If
`x` is odd, your function should return 3*`x`+1. Here's a
C++ function for this task:

long nextnum(long x) {
if (x % 2 == 1)
x = 3*x + 1 ;
else
x = x/2 ;
return(x) ;
}

If you need to refresh your knowlege on of PIC assembler code, review CSCI 255
lab 3. By the way, since there is no multiplication or divide
operations on the PIC, you'll have to use add and shift.

## Turning in

When you have finished your program, FTP the code into your UNCA CSCI
account as `csci/255/home1.asm`.

Return
to the CSCI 255 index

Return to
the UNCA Computer Science home page