This is a section of my code that is having problems. Im just trying to get this jump to work. I am getting error A2075 jump destination too far. Its too far because my array is rather large, so i cannot simply make shorten the distance of the jump.. is the any way around this?
cmp edi, esi
je ID
ID:
mov Array,1
thanks
cmp edi, esi
je ID
ID:
mov Array,1
thanks
Which assembler? (probably MASM, but which version?)
Try rewriting it to "je near ID" - shouldn't be necessary with recent assembler versions, but might fix it for you.
Do you have your array between the "je" and "ID:"? It's not too good mixing code and data, especially not data that's written to.
Try rewriting it to "je near ID" - shouldn't be necessary with recent assembler versions, but might fix it for you.
Do you have your array between the "je" and "ID:"? It's not too good mixing code and data, especially not data that's written to.
I agree with f0dder. I know NASM treats conditional jump codes as "short" and throws out a warning if you are trying to jump to a label out of the +/-128 range. A "near" is required to override this default.
I've always appreciated this function of NASM, as it lets me know if my routines are getting bulky and need redesign ;)
I've always appreciated this function of NASM, as it lets me know if my routines are getting bulky and need redesign ;)
I prefer automatic jump size optimization, or defaulting to near if there's no optimization... decent assemblers have JSO, but of course lets you specify "near" and "short" where you need either (including recent NASM version).
Still gives you control where you need it, doesn't bomb out and require you to fix source in cases where you don't care, and gives small code automatically :)
Still gives you control where you need it, doesn't bomb out and require you to fix source in cases where you don't care, and gives small code automatically :)
I used to encounter this with TASM, but I learned to make the 'near' or even 'far' jump since mine doesn't optimize well. It tries its best, but.... I definitely think code and data should not be mixed, and as the program grows, this becomes more important to the point where even different types of data may need to be separated.
I used to encounter this with TASM
Try using the newest version ;)
Here is a more complete section of the code:
mov esi, 0
mov currentRow, esi ;current row count
mov edi, 0
mov currentCol, edi ;current col count
mov ecx, ROWS ;outer loop count
L1:
push ecx
mov ecx, COLS ;inner loop count
L2:
mov eax, COLS
mov ebx, currentRow
mul ebx
mov ebx, OFFSET Array
add ebx, eax
mov edx, currentCol
cmp ecx, ROWS
jbe skip
mov Array,1
mov eax, array
call writeint
mov saveVal, edx
mov EDX, OFFSET skipnot
Call writestring
mov edx, saveVal
jmp skip2
skip:
cmp edi, esi
je near ID
ID:
mov Array,1
skip2:
mov EDX, OFFSET skipwork
Call writestring
add edi, 4 ;increments the counter by 4
mov currentCol, edi
call CRLF
loop L2
pop ecx
add esi, 4
loop L1
Alright, putting the near in there didnt work. I dont know what the problem is. sorry guys im a n00b and havent developed any debugging/coding skills in ASM.
I appreciate all the responses you guys are awesome.
mov esi, 0
mov currentRow, esi ;current row count
mov edi, 0
mov currentCol, edi ;current col count
mov ecx, ROWS ;outer loop count
L1:
push ecx
mov ecx, COLS ;inner loop count
L2:
mov eax, COLS
mov ebx, currentRow
mul ebx
mov ebx, OFFSET Array
add ebx, eax
mov edx, currentCol
cmp ecx, ROWS
jbe skip
mov Array,1
mov eax, array
call writeint
mov saveVal, edx
mov EDX, OFFSET skipnot
Call writestring
mov edx, saveVal
jmp skip2
skip:
cmp edi, esi
je near ID
ID:
mov Array,1
skip2:
mov EDX, OFFSET skipwork
Call writestring
add edi, 4 ;increments the counter by 4
mov currentCol, edi
call CRLF
loop L2
pop ecx
add esi, 4
loop L1
Alright, putting the near in there didnt work. I dont know what the problem is. sorry guys im a n00b and havent developed any debugging/coding skills in ASM.
I appreciate all the responses you guys are awesome.
cmp edi, esi
je near ID
ID:
I had a peek at the debugger on my own assembler, which has an override for out of range jumps
ifz-jmp ID
which translates as:
3003 jnz 3008
3005 jmp 100 ;<--to position of ID
3008 etc
It looks like you need to figure out a way to call it a jmp instead of je.
je near ID
ID:
I had a peek at the debugger on my own assembler, which has an override for out of range jumps
ifz-jmp ID
which translates as:
3003 jnz 3008
3005 jmp 100 ;<--to position of ID
3008 etc
It looks like you need to figure out a way to call it a jmp instead of je.
So I suppose if you do a local test jump to the jmp it might be ok
cmp edi, esi
je near ID
ID:
could become:
cmp edi,esi
je NewName
;
NewName
jmp ID
kinda thing
cmp edi, esi
je near ID
ID:
could become:
cmp edi,esi
je NewName
;
NewName
jmp ID
kinda thing