Shop OBEX P1 Docs P2 Docs Learn Events
Problem with Test instruction used to ina — Parallax Forums

Problem with Test instruction used to ina

Christof Eb.Christof Eb. Posts: 1,107
edited 2006-12-11 11:48 in Propeller 1
Hello,
during some experiments with adc, I tried:
test ina,inpin wz

to find the value of a certain pin and influence the zero flag. The code did not work.
Then I used:
mov help,ina 'read the input bit
test help,inpin wz

An this works.
What is the reason?
Christof

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2006-12-09 17:00
    Chip discussed the use of certain special registers (like ina) in another thread. Basically, these must be used only in the source field of an instruction. If you use them in the destination field, you actually access the "shadow" memory location rather than the special register. This is true of all the read-only special registers like ina, cnt, par, etc.
  • Christof Eb.Christof Eb. Posts: 1,107
    edited 2006-12-09 17:24
    Thanks, Mike, I will try to find Chip's thread about it.
    And I tried:
    test inpin,ina wz
    which works.(!!)
    Christof
  • cgraceycgracey Posts: 14,133
    edited 2006-12-09 19:04
    Also, the PHSA and PHSB registers must be read as source registers, otherwise you'll read back the value that you last wrote to them.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Chip Gracey
    Parallax, Inc.
  • Paul BakerPaul Baker Posts: 6,351
    edited 2006-12-09 21:40
    Yup, I made that mistake a few days ago, I figured since you could read and write to PHSA/B you could do wrlong phsa, hubmemory; but that doesn't work, it just kept writing -4 to main memory which was my initialization value.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • Christof Eb.Christof Eb. Posts: 1,107
    edited 2006-12-11 11:48
    Hello parallax-people

    I think, it would be good, to get a warning from the assembler!!

    Can you implement that?

    Christof
Sign In or Register to comment.