2

This is the school homework. I was asked to write a I/O mapping program in assembly.

I am stuck at level 1 where i simply read from keyboard and write to monitor using polling method.

###########################################################
.text 0x00400000

main:
    addi    $s0, $0, 0                      #   save address for transmitter data
    lui     $s0, 0xffff
poll_read:
    lw      $t0, 0($s0)                     #   read transmitter data word
    andi    $t0, $t0, 0x1                   #   keep the 1st bit
    beq     $t0, $0, poll_read              #   not ready, go back
    lw      $t1, 4($s0)                     #   read transmitter control word
    andi    $t1, $t1, 0xff                  #   keep the 1st 8 bits
    addi    $t1, $t1, 1

poll_write:
    lw      $t0, 8($s0)                     #   read receiver data word
    andi    $t0, $t0, 0x1                       #   keep the 1st bit
    beq     $t0, $0, poll_write             #   not ready, go back
    sw      $t1, 0xc($s0)                   #   display monitor
    j       poll_read

The problem is the ready bit for 0xffff 0000 is always 0.

So, I cannot do anything else.

is there some sort of trick for this to work? change some settings?

william
  • 7,284
  • 19
  • 66
  • 106
  • Did you select "Mapped I/O" in PCSpim settings? I've looked over your code and it seems to be correct. But, while the code is correct, the comments are reversed. That is, the comment on your first `lw` is "read transmitter data word". What the comment should say is "read receiver control word". There are some others as well – Craig Estey Feb 22 '16 at 23:38
  • yup.. that's the answer.. i can't believe i spent hours on this.. :( can you write that as an answer so that I can mark it right? Thank you so so much.. :) :) – william Feb 22 '16 at 23:41

1 Answers1

1

You'll have to select "Mapped I/O" in PCSpim settings. According to this: http://www.cs.nott.ac.uk/~psztxa/g51csa/l12-hand.pdf it seems to be required.

I've looked over your code and it seems to be correct.

But, while the code is correct, the comments are reversed. That is, the comment on your first lw is "read transmitter data word". What the comment should say is "read receiver control word". There are some others as well.

Craig Estey
  • 30,627
  • 4
  • 24
  • 48