Thanks
Mathhead200, but I really don't how to deal this problem without...
OK, in another way to think about it. Every high level language can't run before compile. But the machine language is hard to read, so I want to use the assembly language to explain the selection.
The first method, we compare two variables and through instructions JG, JZ, and so on, to control the program run in different branch. A simple code, can't not run, only for explain.
Goal: if x>0 then y = 1, else if x=0 then y = 0; else if x<0 then y = -1;
x db ?
y db ?
mov al, 0
cmp x, al
jg big
jz sav
mov al,0ffH
jmp short sav
big: mov al, 1
sav: mov y,al |
Equal to the follow code:
if(x>0)
{
y = 1;
}
else if(x == 0)
{
y=0;
}
else
{
y = -1; //0ffH
} |
It's means...
The second method, we use the instruction xlat(Translate).
Goal: translate the decimal number 0-15 to the hexadecimal.
The base address + offset, access like the array.
tab db '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F' |
If we want to find the 11(decimal), we can:
mov ax, seg tab
mov ds,ax
mov bx,offset tab
mov al,11
xlat |
Equal to the follow code:
char array[16] = ('0','1','2','3',...'A',...'F');
array[11] = A; |
Also equal to:
if(x == 1)
{
x = 1
}
...
else if(x == 11)
{
x = A;
}
...
else if(x == 15)
{
x = F;
} |
It's means...
I still can't find a good way to solve the problem. Maybe you can use array. The element is address of the function.