Assembly in C Emu8086 branch table
-
Hello there, Im trying to make an assembly program that translates a simple switch case program in c without using and commands related to jg or jt only jmp I tried making something like this: org 100h mov si,3 jmp word ptr [jmptab+si] case1: PRINTN "Number One" jmp endcases case2: PRINTN "Number Two" jmp endcases case3: PRINTN "Number Three" jmp endcases case4: PRINTN "Number Four" endcases: jmptab: DW case1 DW case2 DW case3 DW case4 mov ah, 0 int 16h ret include magshimim.inc Where did I go wrong?
-
Hello there, Im trying to make an assembly program that translates a simple switch case program in c without using and commands related to jg or jt only jmp I tried making something like this: org 100h mov si,3 jmp word ptr [jmptab+si] case1: PRINTN "Number One" jmp endcases case2: PRINTN "Number Two" jmp endcases case3: PRINTN "Number Three" jmp endcases case4: PRINTN "Number Four" endcases: jmptab: DW case1 DW case2 DW case3 DW case4 mov ah, 0 int 16h ret include magshimim.inc Where did I go wrong?
[This should really go in QA] Hint: a. What is the size of each entry in your jump table? b. How are you indexing the jump table?
If you have an important point to make, don't try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time - a tremendous whack. --Winston Churchill