user1845029
user1845029

Reputation: 1125

Check if a 16 bit value is greater than 1000 RISC Picoblaze

I'm converting a 16 bit number into decimal to display on four led display.

I want to check if a 16 bit value is greater 1000. Currently I have this implemented but sometimes it does not output the correct value, and I can't figure out why.

  ;s2 is MSB and s3 LSB 
  minus_100_hbyte:;Minus one hundred
           COMP s2, $01 
       JUMP C, minus_100

    ADD s6, $01 ;increment 100 counter
        SUB s3, $64 ;100 in decimal
        SUBC s2,  $00

        JUMP minus_100_hbyte

   minus_100:;Minus one hundred
           COMP s3, $64
       JUMP C, minus10

       ADD s6, $01 ;increment 100 counter
           SUB s3, $64
           SUBC s2,  $00

           JUMP minus_100

Upvotes: -1

Views: 274

Answers (1)

turboscrew
turboscrew

Reputation: 676

This is the first time ever that I hear about picoblaze, but...

What is this for: "COMP s2, $01"? I thought you wanted to compare against 1000 decimal?

1000 decimal is 03e8 hex.

Maybe something like this (not very elegant though - the assembly is new to me)?

comp s2, $03
jump nc greater_than_1000
jump nz less_than_1000
comp s3, $e8
jump nc less_than_1000
jump nz greater_than_1000
less_than_1000:
...
greater_than_1000:
...

Upvotes: 1

Related Questions