Forcing Instructions to Start at an Offset


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?


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

    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
    rep movsb
    ... ; whatever

    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.

Howdy, Stranger!

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


In this Discussion