Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

The offset value

The offset value

The offset value

I´m tried to open a file to write in it, but in every place that I look for, they say to me that I need enter with the off set value, like in the bellow example .

   mov     ax,3d02h
   mov     dx,offset cs:fname              ; DX=*FileName
   int     21h                             ; DOS/FileOpen
   jc      errorlbl                        ; Jump On Errors

   mov     word ptr [offset cs:fname],ax   ; BX=Handle
   mov     bx,ax

   mov     ax,4200h
   xor     cx,cx                           ; Segment
   mov     dx,23ceh                        ; Offset
   int     21h                             ; DOS/FileSeekSet
   jc      errorlbl                        ; Error !

   mov     ax,4000h
   mov     bx,word ptr [offset fname]      ; BX=Handle
   mov     cx,6                            ; Lenght
   mov     dx,offset patch                 ; Buffer
   int     21h                             ; DOS/WriteFile
   jc      errorlbl

   mov     ax,3e00h
   mov     bx,word ptr [offset fname]      ; BX=Handle
   int     21h                             ; DOS/CloseFile
   jc      errorlbl

My answer is : How can i found the offset value of a specifie instruction ?

RE: The offset value

The first that catches my eye is this line:
  mov     dx,offset cs:fname    ; DX=*FileName  ????

The first thought that comes to mind is that you are trying to write a COM program where DS = CS in which case this will work much more efficiently:
  MOV DX, OFFSET fname;

My second thought is that you declared fname as a variable in the code seg, in which case you need to save DS and then set DS = CS before performing the INT, and then restore DS before returning. But the CS segment overide is still not neccessary for the MOV DX, OFFSET fname.

RE: The offset value


Put a label before your opcode (instruction), and get the offset b using - offset label.

mov bx,10
mov ax,30
mov dx,offset label1

;At this point, dx will contain the offset of the instruction: mov bx,10 (the first byte).

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close