| 12345678910111213141516171819202122232425262728 |
- Code:
- XDEF Entry
- XREF __SEG_END_SSTACK
- Constants: Section
- ARRAY dc.b $EB,$77,$7B,$7D,$B7,$BB,$BD,$D7,$DB,$DD,$E7,$ED,$7E,$BE,$DE,$EE,$00
- INDEX ds.w 1
- val ds.b 1
- Code: Section
- Entry:
- LDX #ARRAY ;start X at begging of array
- LDY #ARRAY ;this will allow us to subtract and find the index
- Main:
- LDAA 1,X+ ;load the first byte into acc. A
- CMPA #$00 ;the value was not found
- BEQ NotFound
- CMPA val ;check if A is equal to the value
- BNE Main ;repeat the loop if it is not
- CMPA val ;check if A is equal to the value
- BEQ Found
- Found:
- TFR X,D ;store the value of x in acc. D
- SUBD #ARRAY ;subtract the the value of the start of the array from D
- NotFound:
- STAA #$FF
|