Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Forcing Instructions to Start at an Offset

lemmlemm Member Posts: 1
Hello.


Are there any MASM directives that will force your code to start
at an arbitrary offset.

For example, I want to write mov ax, bx at cs:3000h, even if
it happens the only line in my program. How do I do that?

Comments

  • 3y3ty3y3ty Member Posts: 15
    I believe your talking about 16-bit assembly.
    Your best bet is to move the instructions to 3000h within
    the code segment.

    move_the_code:
    mov cx,end_of_code
    sub cx,3000h
    ; Assumes DS & ES have same segment address as CS
    mov si,offset code_to_move
    mov di,3000h
    cld
    rep movsb
    ... ; whatever

    code_to_move:
    org 3000h ; I believe MASM allows multiple ORG directives
    ; this is unnecessary if the code refers to no labels

    ... ; the actual code
    end_of_code equ $ ; the counter will be 3000h + size of instructions
    ; in bytes
    Hope this helps...

Sign In or Register to comment.