lab_4-3.asm 694 B

12345678910111213141516171819202122232425262728
  1. Code:
  2. XDEF Entry
  3. XREF __SEG_END_SSTACK
  4. Constants: Section
  5. ARRAY dc.b $EB,$77,$7B,$7D,$B7,$BB,$BD,$D7,$DB,$DD,$E7,$ED,$7E,$BE,$DE,$EE,$00
  6. INDEX ds.w 1
  7. val ds.b 1
  8. Code: Section
  9. Entry:
  10. LDX #ARRAY ;start X at begging of array
  11. LDY #ARRAY ;this will allow us to subtract and find the index
  12. Main:
  13. LDAA 1,X+ ;load the first byte into acc. A
  14. CMPA #$00 ;the value was not found
  15. BEQ NotFound
  16. CMPA val ;check if A is equal to the value
  17. BNE Main ;repeat the loop if it is not
  18. CMPA val ;check if A is equal to the value
  19. BEQ Found
  20. Found:
  21. TFR X,D ;store the value of x in acc. D
  22. SUBD #ARRAY ;subtract the the value of the start of the array from D
  23. NotFound:
  24. STAA #$FF