Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
12/22/01 16:57
Read: times


 
#17986 - RE: case statement using assy
hi.

1st, excuse me for poor english.

if the range of values lies together ya can use a function table, same as bellow:

;assume A has the value between 0..127

CLR C
RLC A
MOV DPTR,#TABLE
JMP @A+DPTR
TABLE:
AJMP case_000
AJMP case_001
AJMP case_002
...
AJMP case_127

you can insert some dummy entries only for default case.

this is the method which most compilers generates code for switch() statements. but at the other hand if values are more different and complex ya can simple search a table pointed to by DPTR and if found an entry, use JMP @A+DPTR to jump to that entry.

this code is simple, but execution speed depends on value of initial expression. but in first choice, all of execution times are same.

I hope it can help ya.

reza.


List of 9 messages in thread
TopicAuthorDate
case statement using assy            01/01/70 00:00      
RE: case statement using assy            01/01/70 00:00      
RE: case statement using assy            01/01/70 00:00      
RE: case statement using assy            01/01/70 00:00      
RE: case statement using assy            01/01/70 00:00      
RE: case statement using assy            01/01/70 00:00      
RE: case statement using assy - spencer            01/01/70 00:00      
RE: case statement using assy            01/01/70 00:00      
RE: case statement using assy            01/01/70 00:00      

Back to Subject List