I have code that is not working for the MC68HC12, it takes 0-5V into the

ADC and does some math to convert to revolutions per second and outputs

to 2 LED's. Could someone analyze the code to tell me in general what

might be wrong with the code. Some where I've think I've made a basic

mistake, I have not used the ADC before. I get not display on LED's.

The code, sorry don't know how to wrap the code with formatting.

include 'MC9S12C128.inc'

org $800

movb #$FF, DDRB

movb #$C0, ATDCTL2

movb #$00, ATDCTL3

movb #$00, ATDCTL4

ldaa #1

Wait deca

bne Wait

movb #$20, ATDCTL5

ldab ATDDR0H ;AB will hold the input

loop clra ;clear AA- AB holds converted input

ldab #$80 ;test data -to be commented out

ldx #51 ;relationship between digital number

and BCD

idiv ;as defined in prelab

stx holder ;holder holds the ones place

ldaa #10 ;there will be a remainder. Want at

least 1 decimal point accuracy

mul

ldx #51 ;repeat dividing by 51

idiv

stx holder2 ;holder2 holds the tenths place

ldd holder ;what follows is multiplying both the

ones and teneths place by (18/5)

ldy #18 ;as shown in pre-lab work

emul

std holder

ldd holder2

ldy #18

emul

std holder2

ldd holder

ldx #5

idiv

stx holder

ldd holder2

ldx #5

idiv

stx holder2

ldd holder2 ;we then want to divide holder2

(tenths place) by 10 and add it to holder

ldx #10 ;in order to get 1 number with which

to continue calculation of RSP

idiv

xgdx

addd holder

std Va

ldd #14 ;we want to add 1.4 to Va, per pre-lab

work. divide 14 by 10 to achieve this

ldx #10

idiv

stx holder

std holder2 ;remainder stored in holder2

ldd Va

addd holder

std Va

ldd holder2

ldx #10

idiv

ldd Va

addd 0,x

std Va

ldy #2 ;multiply by 2

emul

std Va

ldd #46 ;multiply by .46 = (46/100)

ldx #100

idiv

stx Va ;Va now contains RPS

ldd Va

cpd #10

bge output1

ldaa #00

output1 ldd Va ;checks value of tens place of RPS

ldx #10

idiv

stx tensplace

ldd tensplace

cpd #1

beq one1

ldd tensplace

cpd #2

beq two1

ldd tensplace

cpd #3

beq three1

ldd tensplace

cpd #4

beq four1

ldd tensplace

cpd #5

beq five1

ldd tensplace

cpd #6

beq six1

ldd tensplace

cpd #7

beq seven1

ldd tensplace

cpd #8

beq eight1

ldd tensplace

beq nine1

ldaa #00

one1 ldaa one ;will load appropriate hex number to

have 7-seg display output

two1 ldaa two ;appropriate number

three1 ldaa three

four1 ldaa four

five1 ldaa five

six1 ldaa six

seven1 ldaa seven

eight1 ldaa eight

nine1 ldaa nine

staa tensplace

ldd Va ;checks value of tens place of RPS

ldx #10

idiv

stx onesplace

ldd onesplace

cpd #1

beq one2

ldd onesplace

cpd #2

beq two2

ldd onesplace

cpd #3

beq three2

ldd onesplace

cpd #4

beq four2

ldd onesplace

cpd #5

beq five2

ldd onesplace

cpd #6

beq six2

ldd onesplace

cpd #7

beq seven2

ldd onesplace

cpd #8

beq eight2

ldd onesplace

beq nine1

ldaa #00

one2 ldaa one ;will load appropriate hex number to

have 7-seg display output

two2 ldaa two ;appropriate number

three2 ldaa three

four2 ldaa four

five2 ldaa five

six2 ldaa six

seven2 ldaa seven

eight2 ldaa eight

nine2 ldaa nine

staa onesplace

movb #$7C, DDRCAN ;configure portcan for output (from

textbook)

movb #$FF, DDRP ;configure portp for output

movb tensplace, PORTP ;place tens-place output code on

portp

movb #$40, PORTCAN ;activate pcan6 so that led will

illuminate with tensplace digit

movb #$30, PORTCAN ;activate pcan5

movb onesplace, PORTP ;illuminate ones-place output code

lbra loop

swi

holder rmb 2

holder2 rmb 2

Va rmb 2

tensplace rmb 1

onesplace rmb 1

zero equ $7E

one equ $30

two equ $6D

three equ $79

four equ $33

five equ $5B

six equ $5F

seven equ $70

eight equ $7F

nine equ $7B

PORTP equ $56

PORTCAN equ $13E

DDRCAN equ $13F

# ADC to LED problem

Started by ●October 5, 2011

Posted by ●October 6, 2011

You have a bunch of problems. Start with

eight1 ldaa #eight

bra nine1b

nine1 ldaa #nine

nine1b staa tensplace

Then study the instruction set some more.

> 6... wrote:

>

> I have code that is not working for the MC68HC12, it takes 0-5V into the

> ADC and does some math to convert to revolutions per second and outputs

> to 2 LED's. Could someone analyze the code to tell me in general what

> might be wrong with the code. Some where I've think I've made a basic

> mistake, I have not used the ADC before. I get not display on LED's.

>

> The code, sorry don't know how to wrap the code with formatting.

>

> include 'MC9S12C128.inc'

> org $800

> movb #$FF, DDRB

> movb #$C0, ATDCTL2

> movb #$00, ATDCTL3

> movb #$00, ATDCTL4

> ldaa #1

> Wait deca

> bne Wait

> movb #$20, ATDCTL5

> ldab ATDDR0H ;AB will hold the input

>

> loop clra ;clear AA- AB holds converted input

> ldab #$80 ;test data -to be commented out

> ldx #51 ;relationship between digital number

> and BCD

> idiv ;as defined in prelab

> stx holder ;holder holds the ones place

> ldaa #10 ;there will be a remainder. Want at

> least 1 decimal point accuracy

> mul

> ldx #51 ;repeat dividing by 51

> idiv

> stx holder2 ;holder2 holds the tenths place

> ldd holder ;what follows is multiplying both the

> ones and teneths place by (18/5)

> ldy #18 ;as shown in pre-lab work

> emul

> std holder

> ldd holder2

> ldy #18

> emul

> std holder2

> ldd holder

> ldx #5

> idiv

> stx holder

> ldd holder2

> ldx #5

> idiv

> stx holder2

> ldd holder2 ;we then want to divide holder2

> (tenths place) by 10 and add it to holder

> ldx #10 ;in order to get 1 number with which

> to continue calculation of RSP

> idiv

> xgdx

> addd holder

> std Va

> ldd #14 ;we want to add 1.4 to Va, per pre-lab

> work. divide 14 by 10 to achieve this

> ldx #10

> idiv

> stx holder

> std holder2 ;remainder stored in holder2

> ldd Va

> addd holder

> std Va

> ldd holder2

> ldx #10

> idiv

> ldd Va

> addd 0,x

> std Va

> ldy #2 ;multiply by 2

> emul

> std Va

> ldd #46 ;multiply by .46 = (46/100)

> ldx #100

> idiv

> stx Va ;Va now contains RPS

>

> ldd Va

> cpd #10

> bge output1

> ldaa #00

> output1 ldd Va ;checks value of tens place of RPS

> ldx #10

> idiv

> stx tensplace

> ldd tensplace

> cpd #1

> beq one1

> ldd tensplace

> cpd #2

> beq two1

> ldd tensplace

> cpd #3

> beq three1

> ldd tensplace

> cpd #4

> beq four1

> ldd tensplace

> cpd #5

> beq five1

> ldd tensplace

> cpd #6

> beq six1

> ldd tensplace

> cpd #7

> beq seven1

> ldd tensplace

> cpd #8

> beq eight1

> ldd tensplace

> beq nine1

> ldaa #00

>

> one1 ldaa one ;will load appropriate hex number to

> have 7-seg display output

> two1 ldaa two ;appropriate number

> three1 ldaa three

> four1 ldaa four

> five1 ldaa five

> six1 ldaa six

> seven1 ldaa seven

> eight1 ldaa eight

> nine1 ldaa nine

> staa tensplace

>

> ldd Va ;checks value of tens place of RPS

> ldx #10

> idiv

> stx onesplace

> ldd onesplace

> cpd #1

> beq one2

> ldd onesplace

> cpd #2

> beq two2

> ldd onesplace

> cpd #3

> beq three2

> ldd onesplace

> cpd #4

> beq four2

> ldd onesplace

> cpd #5

> beq five2

> ldd onesplace

> cpd #6

> beq six2

> ldd onesplace

> cpd #7

> beq seven2

> ldd onesplace

> cpd #8

> beq eight2

> ldd onesplace

> beq nine1

> ldaa #00

>

> one2 ldaa one ;will load appropriate hex number to

> have 7-seg display output

> two2 ldaa two ;appropriate number

> three2 ldaa three

> four2 ldaa four

> five2 ldaa five

> six2 ldaa six

> seven2 ldaa seven

> eight2 ldaa eight

> nine2 ldaa nine

> staa onesplace

> movb #$7C, DDRCAN ;configure portcan for output (from

> textbook)

> movb #$FF, DDRP ;configure portp for output

> movb tensplace, PORTP ;place tens-place output code on

> portp

> movb #$40, PORTCAN ;activate pcan6 so that led will

> illuminate with tensplace digit

> movb #$30, PORTCAN ;activate pcan5

> movb onesplace, PORTP ;illuminate ones-place output code

> lbra loop

>

> swi

>

> holder rmb 2

> holder2 rmb 2

> Va rmb 2

> tensplace rmb 1

> onesplace rmb 1

> zero equ $7E

> one equ $30

> two equ $6D

> three equ $79

> four equ $33

> five equ $5B

> six equ $5F

> seven equ $70

> eight equ $7F

> nine equ $7B

> PORTP equ $56

> PORTCAN equ $13E

> DDRCAN equ $13F

>

>

>

eight1 ldaa #eight

bra nine1b

nine1 ldaa #nine

nine1b staa tensplace

Then study the instruction set some more.

> 6... wrote:

>

> I have code that is not working for the MC68HC12, it takes 0-5V into the

> ADC and does some math to convert to revolutions per second and outputs

> to 2 LED's. Could someone analyze the code to tell me in general what

> might be wrong with the code. Some where I've think I've made a basic

> mistake, I have not used the ADC before. I get not display on LED's.

>

> The code, sorry don't know how to wrap the code with formatting.

>

> include 'MC9S12C128.inc'

> org $800

> movb #$FF, DDRB

> movb #$C0, ATDCTL2

> movb #$00, ATDCTL3

> movb #$00, ATDCTL4

> ldaa #1

> Wait deca

> bne Wait

> movb #$20, ATDCTL5

> ldab ATDDR0H ;AB will hold the input

>

> loop clra ;clear AA- AB holds converted input

> ldab #$80 ;test data -to be commented out

> ldx #51 ;relationship between digital number

> and BCD

> idiv ;as defined in prelab

> stx holder ;holder holds the ones place

> ldaa #10 ;there will be a remainder. Want at

> least 1 decimal point accuracy

> mul

> ldx #51 ;repeat dividing by 51

> idiv

> stx holder2 ;holder2 holds the tenths place

> ldd holder ;what follows is multiplying both the

> ones and teneths place by (18/5)

> ldy #18 ;as shown in pre-lab work

> emul

> std holder

> ldd holder2

> ldy #18

> emul

> std holder2

> ldd holder

> ldx #5

> idiv

> stx holder

> ldd holder2

> ldx #5

> idiv

> stx holder2

> ldd holder2 ;we then want to divide holder2

> (tenths place) by 10 and add it to holder

> ldx #10 ;in order to get 1 number with which

> to continue calculation of RSP

> idiv

> xgdx

> addd holder

> std Va

> ldd #14 ;we want to add 1.4 to Va, per pre-lab

> work. divide 14 by 10 to achieve this

> ldx #10

> idiv

> stx holder

> std holder2 ;remainder stored in holder2

> ldd Va

> addd holder

> std Va

> ldd holder2

> ldx #10

> idiv

> ldd Va

> addd 0,x

> std Va

> ldy #2 ;multiply by 2

> emul

> std Va

> ldd #46 ;multiply by .46 = (46/100)

> ldx #100

> idiv

> stx Va ;Va now contains RPS

>

> ldd Va

> cpd #10

> bge output1

> ldaa #00

> output1 ldd Va ;checks value of tens place of RPS

> ldx #10

> idiv

> stx tensplace

> ldd tensplace

> cpd #1

> beq one1

> ldd tensplace

> cpd #2

> beq two1

> ldd tensplace

> cpd #3

> beq three1

> ldd tensplace

> cpd #4

> beq four1

> ldd tensplace

> cpd #5

> beq five1

> ldd tensplace

> cpd #6

> beq six1

> ldd tensplace

> cpd #7

> beq seven1

> ldd tensplace

> cpd #8

> beq eight1

> ldd tensplace

> beq nine1

> ldaa #00

>

> one1 ldaa one ;will load appropriate hex number to

> have 7-seg display output

> two1 ldaa two ;appropriate number

> three1 ldaa three

> four1 ldaa four

> five1 ldaa five

> six1 ldaa six

> seven1 ldaa seven

> eight1 ldaa eight

> nine1 ldaa nine

> staa tensplace

>

> ldd Va ;checks value of tens place of RPS

> ldx #10

> idiv

> stx onesplace

> ldd onesplace

> cpd #1

> beq one2

> ldd onesplace

> cpd #2

> beq two2

> ldd onesplace

> cpd #3

> beq three2

> ldd onesplace

> cpd #4

> beq four2

> ldd onesplace

> cpd #5

> beq five2

> ldd onesplace

> cpd #6

> beq six2

> ldd onesplace

> cpd #7

> beq seven2

> ldd onesplace

> cpd #8

> beq eight2

> ldd onesplace

> beq nine1

> ldaa #00

>

> one2 ldaa one ;will load appropriate hex number to

> have 7-seg display output

> two2 ldaa two ;appropriate number

> three2 ldaa three

> four2 ldaa four

> five2 ldaa five

> six2 ldaa six

> seven2 ldaa seven

> eight2 ldaa eight

> nine2 ldaa nine

> staa onesplace

> movb #$7C, DDRCAN ;configure portcan for output (from

> textbook)

> movb #$FF, DDRP ;configure portp for output

> movb tensplace, PORTP ;place tens-place output code on

> portp

> movb #$40, PORTCAN ;activate pcan6 so that led will

> illuminate with tensplace digit

> movb #$30, PORTCAN ;activate pcan5

> movb onesplace, PORTP ;illuminate ones-place output code

> lbra loop

>

> swi

>

> holder rmb 2

> holder2 rmb 2

> Va rmb 2

> tensplace rmb 1

> onesplace rmb 1

> zero equ $7E

> one equ $30

> two equ $6D

> three equ $79

> four equ $33

> five equ $5B

> six equ $5F

> seven equ $70

> eight equ $7F

> nine equ $7B

> PORTP equ $56

> PORTCAN equ $13E

> DDRCAN equ $13F

>

>

>

Posted by ●October 7, 2011

Thank you for the input.

--- In 6..., mjhuslig@... wrote:

>

> You have a bunch of problems. Start with

>

> eight1 ldaa #eight

> bra nine1b

> nine1 ldaa #nine

> nine1b staa tensplace

>

> Then study the instruction set some more.

>

> > 6... wrote:

> >

> > I have code that is not working for the MC68HC12, it takes 0-5V into the

> > ADC and does some math to convert to revolutions per second and outputs

> > to 2 LED's. Could someone analyze the code to tell me in general what

> > might be wrong with the code. Some where I've think I've made a basic

> > mistake, I have not used the ADC before. I get not display on LED's.

> >

> > The code, sorry don't know how to wrap the code with formatting.

> >

> > include 'MC9S12C128.inc'

> >

> >

> > org $800

> > movb #$FF, DDRB

> > movb #$C0, ATDCTL2

> > movb #$00, ATDCTL3

> > movb #$00, ATDCTL4

> > ldaa #1

> > Wait deca

> > bne Wait

> > movb #$20, ATDCTL5

> > ldab ATDDR0H ;AB will hold the input

> >

> > loop clra ;clear AA- AB holds converted input

> > ldab #$80 ;test data -to be commented out

> > ldx #51 ;relationship between digital number

> > and BCD

> > idiv ;as defined in prelab

> > stx holder ;holder holds the ones place

> > ldaa #10 ;there will be a remainder. Want at

> > least 1 decimal point accuracy

> > mul

> > ldx #51 ;repeat dividing by 51

> > idiv

> > stx holder2 ;holder2 holds the tenths place

> > ldd holder ;what follows is multiplying both the

> > ones and teneths place by (18/5)

> > ldy #18 ;as shown in pre-lab work

> > emul

> > std holder

> > ldd holder2

> > ldy #18

> > emul

> > std holder2

> > ldd holder

> > ldx #5

> > idiv

> > stx holder

> > ldd holder2

> > ldx #5

> > idiv

> > stx holder2

> > ldd holder2 ;we then want to divide holder2

> > (tenths place) by 10 and add it to holder

> > ldx #10 ;in order to get 1 number with which

> > to continue calculation of RSP

> > idiv

> > xgdx

> > addd holder

> > std Va

> > ldd #14 ;we want to add 1.4 to Va, per pre-lab

> > work. divide 14 by 10 to achieve this

> > ldx #10

> > idiv

> > stx holder

> > std holder2 ;remainder stored in holder2

> > ldd Va

> > addd holder

> > std Va

> > ldd holder2

> > ldx #10

> > idiv

> > ldd Va

> > addd 0,x

> > std Va

> > ldy #2 ;multiply by 2

> > emul

> > std Va

> > ldd #46 ;multiply by .46 = (46/100)

> > ldx #100

> > idiv

> > stx Va ;Va now contains RPS

> >

> > ldd Va

> > cpd #10

> > bge output1

> > ldaa #00

> >

> >

> > output1 ldd Va ;checks value of tens place of RPS

> > ldx #10

> > idiv

> > stx tensplace

> > ldd tensplace

> > cpd #1

> > beq one1

> > ldd tensplace

> > cpd #2

> > beq two1

> > ldd tensplace

> > cpd #3

> > beq three1

> > ldd tensplace

> > cpd #4

> > beq four1

> > ldd tensplace

> > cpd #5

> > beq five1

> > ldd tensplace

> > cpd #6

> > beq six1

> > ldd tensplace

> > cpd #7

> > beq seven1

> > ldd tensplace

> > cpd #8

> > beq eight1

> > ldd tensplace

> > beq nine1

> > ldaa #00

> >

> > one1 ldaa one ;will load appropriate hex number to

> > have 7-seg display output

> > two1 ldaa two ;appropriate number

> > three1 ldaa three

> > four1 ldaa four

> > five1 ldaa five

> > six1 ldaa six

> > seven1 ldaa seven

> > eight1 ldaa eight

> > nine1 ldaa nine

> > staa tensplace

> >

> > ldd Va ;checks value of tens place of RPS

> > ldx #10

> > idiv

> > stx onesplace

> > ldd onesplace

> > cpd #1

> > beq one2

> > ldd onesplace

> > cpd #2

> > beq two2

> > ldd onesplace

> > cpd #3

> > beq three2

> > ldd onesplace

> > cpd #4

> > beq four2

> > ldd onesplace

> > cpd #5

> > beq five2

> > ldd onesplace

> > cpd #6

> > beq six2

> > ldd onesplace

> > cpd #7

> > beq seven2

> > ldd onesplace

> > cpd #8

> > beq eight2

> > ldd onesplace

> > beq nine1

> > ldaa #00

> >

> > one2 ldaa one ;will load appropriate hex number to

> > have 7-seg display output

> > two2 ldaa two ;appropriate number

> > three2 ldaa three

> > four2 ldaa four

> > five2 ldaa five

> > six2 ldaa six

> > seven2 ldaa seven

> > eight2 ldaa eight

> > nine2 ldaa nine

> > staa onesplace

> >

> >

> > movb #$7C, DDRCAN ;configure portcan for output (from

> > textbook)

> > movb #$FF, DDRP ;configure portp for output

> > movb tensplace, PORTP ;place tens-place output code on

> > portp

> > movb #$40, PORTCAN ;activate pcan6 so that led will

> > illuminate with tensplace digit

> > movb #$30, PORTCAN ;activate pcan5

> > movb onesplace, PORTP ;illuminate ones-place output code

> > lbra loop

> >

> > swi

> >

> >

> >

> > holder rmb 2

> > holder2 rmb 2

> > Va rmb 2

> > tensplace rmb 1

> > onesplace rmb 1

> > zero equ $7E

> > one equ $30

> > two equ $6D

> > three equ $79

> > four equ $33

> > five equ $5B

> > six equ $5F

> > seven equ $70

> > eight equ $7F

> > nine equ $7B

> > PORTP equ $56

> > PORTCAN equ $13E

> > DDRCAN equ $13F

> >

> >

> >

> >

> >

> >

> >

> >

> >

> >

>

--- In 6..., mjhuslig@... wrote:

>

> You have a bunch of problems. Start with

>

> eight1 ldaa #eight

> bra nine1b

> nine1 ldaa #nine

> nine1b staa tensplace

>

> Then study the instruction set some more.

>

> > 6... wrote:

> >

> > I have code that is not working for the MC68HC12, it takes 0-5V into the

> > ADC and does some math to convert to revolutions per second and outputs

> > to 2 LED's. Could someone analyze the code to tell me in general what

> > might be wrong with the code. Some where I've think I've made a basic

> > mistake, I have not used the ADC before. I get not display on LED's.

> >

> > The code, sorry don't know how to wrap the code with formatting.

> >

> > include 'MC9S12C128.inc'

> >

> >

> > org $800

> > movb #$FF, DDRB

> > movb #$C0, ATDCTL2

> > movb #$00, ATDCTL3

> > movb #$00, ATDCTL4

> > ldaa #1

> > Wait deca

> > bne Wait

> > movb #$20, ATDCTL5

> > ldab ATDDR0H ;AB will hold the input

> >

> > loop clra ;clear AA- AB holds converted input

> > ldab #$80 ;test data -to be commented out

> > ldx #51 ;relationship between digital number

> > and BCD

> > idiv ;as defined in prelab

> > stx holder ;holder holds the ones place

> > ldaa #10 ;there will be a remainder. Want at

> > least 1 decimal point accuracy

> > mul

> > ldx #51 ;repeat dividing by 51

> > idiv

> > stx holder2 ;holder2 holds the tenths place

> > ldd holder ;what follows is multiplying both the

> > ones and teneths place by (18/5)

> > ldy #18 ;as shown in pre-lab work

> > emul

> > std holder

> > ldd holder2

> > ldy #18

> > emul

> > std holder2

> > ldd holder

> > ldx #5

> > idiv

> > stx holder

> > ldd holder2

> > ldx #5

> > idiv

> > stx holder2

> > ldd holder2 ;we then want to divide holder2

> > (tenths place) by 10 and add it to holder

> > ldx #10 ;in order to get 1 number with which

> > to continue calculation of RSP

> > idiv

> > xgdx

> > addd holder

> > std Va

> > ldd #14 ;we want to add 1.4 to Va, per pre-lab

> > work. divide 14 by 10 to achieve this

> > ldx #10

> > idiv

> > stx holder

> > std holder2 ;remainder stored in holder2

> > ldd Va

> > addd holder

> > std Va

> > ldd holder2

> > ldx #10

> > idiv

> > ldd Va

> > addd 0,x

> > std Va

> > ldy #2 ;multiply by 2

> > emul

> > std Va

> > ldd #46 ;multiply by .46 = (46/100)

> > ldx #100

> > idiv

> > stx Va ;Va now contains RPS

> >

> > ldd Va

> > cpd #10

> > bge output1

> > ldaa #00

> >

> >

> > output1 ldd Va ;checks value of tens place of RPS

> > ldx #10

> > idiv

> > stx tensplace

> > ldd tensplace

> > cpd #1

> > beq one1

> > ldd tensplace

> > cpd #2

> > beq two1

> > ldd tensplace

> > cpd #3

> > beq three1

> > ldd tensplace

> > cpd #4

> > beq four1

> > ldd tensplace

> > cpd #5

> > beq five1

> > ldd tensplace

> > cpd #6

> > beq six1

> > ldd tensplace

> > cpd #7

> > beq seven1

> > ldd tensplace

> > cpd #8

> > beq eight1

> > ldd tensplace

> > beq nine1

> > ldaa #00

> >

> > one1 ldaa one ;will load appropriate hex number to

> > have 7-seg display output

> > two1 ldaa two ;appropriate number

> > three1 ldaa three

> > four1 ldaa four

> > five1 ldaa five

> > six1 ldaa six

> > seven1 ldaa seven

> > eight1 ldaa eight

> > nine1 ldaa nine

> > staa tensplace

> >

> > ldd Va ;checks value of tens place of RPS

> > ldx #10

> > idiv

> > stx onesplace

> > ldd onesplace

> > cpd #1

> > beq one2

> > ldd onesplace

> > cpd #2

> > beq two2

> > ldd onesplace

> > cpd #3

> > beq three2

> > ldd onesplace

> > cpd #4

> > beq four2

> > ldd onesplace

> > cpd #5

> > beq five2

> > ldd onesplace

> > cpd #6

> > beq six2

> > ldd onesplace

> > cpd #7

> > beq seven2

> > ldd onesplace

> > cpd #8

> > beq eight2

> > ldd onesplace

> > beq nine1

> > ldaa #00

> >

> > one2 ldaa one ;will load appropriate hex number to

> > have 7-seg display output

> > two2 ldaa two ;appropriate number

> > three2 ldaa three

> > four2 ldaa four

> > five2 ldaa five

> > six2 ldaa six

> > seven2 ldaa seven

> > eight2 ldaa eight

> > nine2 ldaa nine

> > staa onesplace

> >

> >

> > movb #$7C, DDRCAN ;configure portcan for output (from

> > textbook)

> > movb #$FF, DDRP ;configure portp for output

> > movb tensplace, PORTP ;place tens-place output code on

> > portp

> > movb #$40, PORTCAN ;activate pcan6 so that led will

> > illuminate with tensplace digit

> > movb #$30, PORTCAN ;activate pcan5

> > movb onesplace, PORTP ;illuminate ones-place output code

> > lbra loop

> >

> > swi

> >

> >

> >

> > holder rmb 2

> > holder2 rmb 2

> > Va rmb 2

> > tensplace rmb 1

> > onesplace rmb 1

> > zero equ $7E

> > one equ $30

> > two equ $6D

> > three equ $79

> > four equ $33

> > five equ $5B

> > six equ $5F

> > seven equ $70

> > eight equ $7F

> > nine equ $7B

> > PORTP equ $56

> > PORTCAN equ $13E

> > DDRCAN equ $13F

> >

> >

> >

> >

> >

> >

> >

> >

> >

> >

>