Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Program to display student number

  1. May 25, 2008 #1
    Hey there guys, how is everyone,

    I am doing a computer engineering module at uni and have an assignement to produce a program on thrsim11 software to display my student number 1 digit at a time on a seven segment display. I have written a basic test program to do this but I am having trouble getting the numbers to display correctly. I know the hexpat data is correct as I have tested it but when i run the program all the segments on the LED light up and then turn off after the loop has finished. Would someone look over my code and tell me if I am going about this the right way or am I totally off course. Any advice or help would be greatly appreciated

    Cheers guys !! sorry for the bad formatting

    prb equ $1004 Peripheral port B
    ddrb equ $1006 Data direction register B
    prc equ $1003 Peripheral port C
    ddrc equ $1007 Data direction register C
    delay equ $bd4 value for 1 second time delay
    program equ $00a0 start address of program
    reset equ $fffe reset vector
    eod equ $23 end of data

    org $0000
    hexpat fcb $3f,$03 hexpat 0-9
    fcb $5b,$4f
    fcb $66,$6d
    fcb $7d,$07
    fcb $7f,$6f
    studnumber fcc '0085755#'

    org program
    ldaa #$ff all port B line output
    staa ddrb set port B lines
    ldaa #$01 pc0 line output
    staa ddrc set port C lines

    ldy #studnumber point index register Y to first student number digit
    next ldab 00,y load first digit into Accum B
    cmpb #eod compare EOD marker
    beq stop if EOD stop program
    andb $0f convert to binary
    ldx #hexpat point indx reg X to hexpat
    abx add offset ie add accum B to index reg X
    ldaa 00,x get hexpat into accum a

    staa prb output display word
    ldaa #$00 get enable word
    staa prc enable the display
    ldab #$01 counter for loop 2
    loop2 ldx #delay counter for 1 second delay
    loop1 dex decrement counter 1
    bne loop1
    decb decrement counter 2
    bne loop2 display (1 X 10 sec)
    ldaa #$01 get disable word
    staa prc disable display
    iny increment index Y to point to next digit
    bra next repeat process until EOD
    stop jmp stop end of program

    org reset
    fdb start set reset vector to start
    Last edited: May 25, 2008
  2. jcsd
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?
Draft saved Draft deleted