How is PORTB a register? It sounds like a memory location
to me where you are storing a value.
I'm not exactly what your calling method is trying to do
but I'm guessing you are looking to use one call statement
to be able to call the correct place based on the value of
i... Correct? Well, you have to realize that when
Assembly programs are compiled, all memory locations are
compiled as constants, not variables. In order to
accomplish what you want to do, I can think of two things:
1. Make each chunk (call zero, call one...) the same #
bytes long and call location_call_zero + i chunks later
Like so (not knowing specific syntax):
mov ax, ;get value of i,(mov ax, i gets location)
;i is a word? byte?
mul constant_number_bytes_per_chunk
add ax, zero
;Thus, if zero is at mem 0x1000 and each chunk is 10 bytes
;and i=5 then it calls location 0x1000 + (5 * 10)
2. Use the xlat command to get the locations... This is
a little more complicated than i originally thought but
...
mov bx, table ;point to base of table b/c xlatb command
;makes al equal the byte at location
;ds:bx + al ...
xor ax, ax
mov al,
mul 2 ;multiply by two b/c xlatb command uses
;bytes but our table is in words
xlatb ;get low byte of location
mov cl, al ;save it
mov al,
mul 2
inc al ;next byte will be high byte of location
xlatb ;get high byte into al
mov ah, al ;move high byte to high end of ax register
mov al, cl mov low byte back
call ax
......
table dw zero, one, two, three, four, five ;ETC
This effectively makes a table of constant value locations
of the procedure calls at compilation time. Then, it calls
the correct location when the time comes
While number 1 is clearly more simple, it requires you to
keep your procedures to a constant number of bytes. You
could do this by adding sufficient db # commands after
each ret if they aren't already the same size or you could
use the more complicated second method.