Article View: comp.lang.asm.x86
Article #188Re: 32bit Assembler ( figureing out relocations )
From: Jerzy Tarasiuk
Date: Tue, 17 Jan 1995 13:09
Date: Tue, 17 Jan 1995 13:09
47 lines
3627 bytes
3627 bytes
>>>>> "E" == Erica A Ramsey <lajade@xnet.com> writes: E> Hello, I want to write an assembler. I notice that dos .exe files have ... E> I really don't see why a relocation table is necessary for 32bit protected E> mode or even dos programs!!! the offsets within the modules themselves E> don't change, regardless of the address the module was loaded at!!! But far addresses and segments change. E> The only use of relocation tables for dos .exe files, I think, is that if E> one is using far pointers. The same for 32bit protected mode programs, E> relocation is only needed if the program uses 48bit far pointers; remember, E> in 32bit protected mode a far pointer is 16bit selector plus 32bit offset. E> If I say ahead time that one cannot use far pointers then I should be E> fine; ie, I will not need relocation tables. Or I could be wrong, I'm so One may need relocation if program starts in Real Mode and needs compute address of something of its code or data. E> How do I know which items should be relocatable ? 'call' instructions E> shouldn't need to be relocated because 'call' instructions are relative E> from pc counter; correct? conditional jumps shouldn't need to be relocated E> because they are also relative from pc counter. But, jmp instructs E> and variables would have to be relocatable because they are absolute Every memory reference and every offset stored in memory are relative to start of segment; unless assembler knows no other modules can contribute to the segment it must use relocations. Both CALL and JMP have indirect forms like CALL WORD PTR [PROCADR] and both offset of PROCADR in the CALL instruction and value of PROCADR are relocatable, both have relative forms which have address difference encoded into them and this form doesn't need relocation if jump/call and its target are in same module and segment. E> Is a link phase really necessary ? Can't I just create exe modules? I E> don't plan to have libraries or anything. Assembler which can assemble single module to .EXE and doesn't allow to link modules has limited usefulness. Very limited if it doesn't have some advanced pseudo-instructions like QUAL - one may use such an assembler for small test, but nothing more. E> I have gnu assembler source from binutils. does anyone have any E> experience porting gas to dos ? GAS is ported to DOS in DJGPP.
Technical Details
Message-ID:
<JT.95Jan17140912@albert5.fuw.edu.pl>Path:
arc1-ca.pugleaf.net!nntp.gmd.de!Germany.EU.net!howland.reston.ans.net!swrinde!pipex!uunet!newsfeed.ACO.net!fuw.edu.pl!news!jtReferences:
<3f9kib$36o@flood.xnet.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 11318c,14c198d00592d0c8 X-Google-Attributes: gid11318c,public X-Google-Thread: 10f6aa,14c198d00592d0c8 X-Google-Attributes: gid10f6aa,public X-Google-Thread: 110292,14c198d00592d0c8 X-Google-Attributes: gid110292,public X-Google-Thread: 102bfa,14c198d00592d0c8 X-Google-Attributes: gid102bfa,public X-Google-Thread: 114917,14c198d00592d0c8 X-Google-Attributes: gid114917,public X-Google-ArrivalTime: 1995-01-17 05:09:12 PST Newsgroups: comp.lang.asm.x86,comp.sys.intel,alt.msdos.programmer,comp.os.msdos.programmer,gnu.gcc.help Path: arc1-ca.pugleaf.net!nntp.gmd.de!Germany.EU.net!howland.reston.ans.net!swrinde!pipex!uunet!newsfeed.ACO.net!fuw.edu.pl!news!jt From: jt@fuw.edu.pl (Jerzy Tarasiuk) Subject: Re: 32bit Assembler ( figureing out relocations ) In-Reply-To: lajade@xnet.com's message of 14 Jan 1995 22:51:55 GMT Message-ID: <JT.95Jan17140912@albert5.fuw.edu.pl> Sender: news@fuw.edu.pl Nntp-Posting-Host: albert5 Reply-To: jt@zfja-gate.fuw.edu.pl (Jerzy Tarasiuk) Cc: Erica A Ramsey <lajade@xnet.com> Organization: Warsaw University, Physics Department References: <3f9kib$36o@flood.xnet.com> Date: Tue, 17 Jan 1995 13:09:12 GMT Lines: 47