making a jump dictionary

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello:

I have an application which is taxing my meager skills (using indexes). Basically I have a list of "words" in my dictionary & a small buffer of text to match against. Basically I want to find if the text in the buffer is in the dictionary (thus valid). If it is in the dictionary I also
want to execute a similar named routine. So if "stop" is detected a separate routine labeled "stop:" in the program will be executed.

example:
.dseg
.org 0x100 test_txt .byte 12 ;Word to be checked can be 12 bytes long

.org 0x200
dictionary .db "stop"
.db "start"
.db "reset"
.db "shout"
.db "laugh"
.db "HELP!"
......
stop: rjmp stop......
start: rjmp start.....
Any thought or hints would be GREATLY appreciated

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This sounds similar to the way an assembler determines if a variable has been defined and, if so, what to do. Do a Google search on "hash table".

Dave

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This code aint working, but something close should do the work?

ldi	zh, high(dictionary*2)
ldi	zl, low (dictionary*2)

lpm	r0, z+
lpm	r1, z+

;do some compares

;when hit
lpm	r0, z+
lpm	r1, z+
mov	zl, r0
mov	zh, r1
ijmp	
; should jump to (z), Ive never tried it tho...


HELP:
start:
stop:

dictionary:
.db "stop", low(stop), high(stop)
.db "start", low(start), high(start)
.db "HELP!", low(HELP), high(HELP)
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
dictionary: 
.db "stop", low(stop), high(stop) 
.db "start", low(start), high(start) 
.db "HELP!", low(HELP), high(HELP) 

I would either make all entries the same length or define a length byte in front of each search item.

Regards