Thread View: comp.os.msdos.programmer
2 messages
2 total messages
Started by Gary A. Hildebrand
Thu, 21 Jan 1993 23:25
Is there any way to force MASM 5.1 to generate NEAR jumps?
Author: Gary A. Hildebrand
Date: Thu, 21 Jan 1993 23:25
Date: Thu, 21 Jan 1993 23:25
70 lines
2775 bytes
2775 bytes
All, Consider the following macro and code, which are the early stages of an exception handler plus entry points for a virtual 8086 monitor: ; ; Macro acts as entry point to handler from IDT entry n ; idt_vec macro n push ax ; save a register mov al,n ; load vector index jmp near ptr mhandler ; chain to master handler endm .CODE mhandler: pop ax iretd idt_vec0: idt_vec 0 idt_vec1: x = 1 rept 255 idt_vec x x = x + 1 endm Here is the code which will place the offsets of the entry points in an IDT: ; ; load offsets for gate descriptors in IDT ; mov ax,offset idt_vec0 mov di,offset idt mov cx,256 cld next_idt_vec: stosw add di,6 add ax,idt_vec1 - idt_vec0 loop next_idt_vec What's wrong, you ask? Even though the `mhandler:` label is not forward referenced by the expanded `idt_vec` macro, and the jump to `mhandler:` has been typed as a near one, MASM 5.1 tries to optimize the jumps nevertheless. The first 20 or so entry points will use short jumps instead of near ones. Normally this would be acceptable, but the IDT loader code depends on the code size for each entry point being the *same*, since it just uses the size of the first entry point. Is there any trick to make MASM 5.1 not optimize these jumps? It seems kind of silly to place the `mhandler` and `idt_vec` sections in completely different parts of the code segment, or stick a bunch of NOP's after the IRETD. Of course, it's very likely that the real `mhandler` section will be large enough to prevent this problem from occurring, but there should be a way to control what MASM is doing. I haven't tried giving this to TASM, to see what it would do. Once again, this is one of those problems where I swear I've seen it before (and one way or another, it was solved)! Feel free to post or e-mail your responses on this. Thanks in advance for the help! Gary -- / Gary A. Hildebrand Internet: gah@mew.mei.co.jp \ / Matsushita Electric Works, Ltd. UUCP: uunet!mew.mei.co.jp!gah \ / 13-2, Mita 5-chome, Minato-ku Fax: 03-3451-0793 \ / Tokyo 108, JAPAN Tel: 03-3452-4941 \
Re: Is there any way to force MASM 5.1 to generate NEAR jumps?
Author: Lamont Downs
Date: Fri, 22 Jan 1993 02:35
Date: Fri, 22 Jan 1993 02:35
4 lines
639 bytes
639 bytes
>Is there any trick to make MASM 5.1 not optimize these jumps? It seems You could hard code the jumps with a series of DBs... downs@helios.nevada.edu
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads