I am starting to write a assembly program for a mc68hc12. I will be reading a 8 bit signed number into PortA and outputting the results to 7 segment LED's, common anode. I will be using Port P to ouput the segments and PortCan to control the LED's displayed. I assume I need 4 LED's, 1 for the sign and 3 LEDs for the max number of 128. If I hard wired the data in I get something like below. How would I go about pulling the data in from a port and then displaying the number on a set of LED's?

org $1000
        ldaa #$ff
        staa DDRP
        ldaa #$7c
        staa DDRCAN
forever ldy #display
next    ldaa 0,y
        staa PORTP
        ldaa PROTCAN
        anda #$83
        staa PROTCAN
        ldaa 1,y
        oraa PORTCAN
        staa PORTCAN

;a delay subroutine here to would cycle back to forever

display
       fcc  $30,$40
       fcc  $6d,$20
       fcc  $79,$10
       fcc  $33,$08
       fcc  $5b,$04

Thanks

I am starting to write a assembly program for a mc68hc12. I will be reading a 8 bit signed number into PortA and outputting the results to 7 segment LED's, common anode. I will be using Port P to ouput the segments and PortCan to control the LED's displayed. I assume I need 4 LED's, 1 for the sign and 3 LEDs for the max number of 128. If I hard wired the data in I get something like below. How would I go about pulling the data in from a port and then displaying the number on a set of LED's?

org $1000
        ldaa #$ff
        staa DDRP
        ldaa #$7c
        staa DDRCAN
forever ldy #display
next    ldaa 0,y
        staa PORTP
        ldaa PROTCAN
        anda #$83
        staa PROTCAN
        ldaa 1,y
        oraa PORTCAN
        staa PORTCAN

;a delay subroutine here to would cycle back to forever

display
       fcc  $30,$40
       fcc  $6d,$20
       fcc  $79,$10
       fcc  $33,$08
       fcc  $5b,$04

Thanks

If you know what the port is (e.g. 0x60 is the keyboard on a computer) you can use in.

It's used like this (AT&T syntax):

inb 0x60, %eax

which would store the data from the keyboard in eax. You'll probably want to store it elsewhere, though.

Hope this helps.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.