Reputation: 8580
I am writing assembly and my code works for near jumps (like the following, the instructions get executed):
org 0x500
jmp main
%include "smallFile.inc"
main:
;start instructions, these instructions get executed
However, when I include multiple files, larger files (following), it doesn't make the jump, the instructions do not get executed. I've tried to play around with adding addresses before the "main" mnemonic, my understanding may be off.
How would I make the following situation work?
org 0x500
jmp main
%include "smallFile1.inc" ;couple bytes assembled and linked in
%include "smallFile2.inc" ;couple bytes assembled and linked in
%include "smallFile3.inc" ;couple bytes assembled and linked in
%include "LargeFile.inc" ;couple hundred bytes assembled and linked in
%include "LargeFile2.inc" ;couple hundred bytes assembled and linked in
main:
;start instructions, these are never reached
Upvotes: 0
Views: 1257
Reputation: 8580
So I was doing some more digging, I stumbled across the following resource:
To which I saw there was something called a near jump...jmp near
in the code. I don't know how I missed that in my previous hours of looking. When I entered it into my code it resolved my issue...
short jumps are +- 127 relative bytes. Near jumps are up to 2GB within a segment. Far jumps or outside of the segment; I think I may have been trying to use the far jump incorrectly.
The following fixed my code;
org 0x500
jmp near main
%include "smallFile1.inc" ;couple bytes assembled and linked in
%include "smallFile2.inc" ;couple bytes assembled and linked in
%include "smallFile3.inc" ;couple bytes assembled and linked in
%include "LargeFile.inc" ;couple hundred bytes assembled and linked in
%include "LargeFile2.inc" ;couple hundred bytes assembled and linked in
main:
;start instructions, these instructions are now reached.
Thank you to everyone who looked at this in attempts to resolve my issue. Hope this helps somebody someday.
Upvotes: 1