flat assembler
Message board for the users of flat assembler.

Index > DOS > [ASK] Assign the code address

Author
Thread Post new topic Reply to topic
rednight



Joined: 19 Nov 2008
Posts: 3
rednight 19 Nov 2008, 08:45
Hi all

I'd like to assign the codes that was started from memory address BF000h when I run the program.

For example,

Code:
; fasm example of writing simple EXE program 

format MZ 

        push    cs 
        pop     ds 
        mov     ah,9 
        mov     dx,hello 
        int     21h 

        mov     ax,4C00h 
        int     21h 

hello db 'Hello world!',24h    
    


When I run the 'helloworld.exe' progrom.
The codes 'mov ax, 4C00h' was in the memory address BF000h exactly.


How do I to do this work?

Kindly thanks for your precious opinions. Wink
Post 19 Nov 2008, 08:45
View user's profile Send private message Reply with quote
DJ Mauretto



Joined: 14 Mar 2007
Posts: 464
Location: Rome,Italy
DJ Mauretto 19 Nov 2008, 09:08
Quote:
When I run the 'helloworld.exe' progrom.
The codes 'mov ax, 4C00h' was in the memory address BF000h exactly.
Question

_________________
Nil Volentibus Arduum Razz
Post 19 Nov 2008, 09:08
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 19 Nov 2008, 12:39
rednight,

Do you want to compile that code as if b8 00 4c is at particular offset?
Code:
;org 0EFF7h is implicit from the following instructions' size
        push    cs
        pop     ds
        mov     ah,9
        mov     dx,hello
        int     21h
org 0F000h; segment is unimportant because of "push cs"/"pop ds"
        mov     ax,4C00h
        int     21h

hello db 'Hello world!',24h    
But you definitely should load this code at offset 0EFF7h.

_________________
"Don't belong. Never join. Think for yourself. Peace." – Victor Stone.
Post 19 Nov 2008, 12:39
View user's profile Send private message Reply with quote
rednight



Joined: 19 Nov 2008
Posts: 3
rednight 20 Nov 2008, 00:55
baldr wrote:
rednight,

Do you want to compile that code as if b8 00 4c is at particular offset?
Code:
;org 0EFF7h is implicit from the following instructions' size
        push    cs
        pop     ds
        mov     ah,9
        mov     dx,hello
        int     21h
org 0F000h; segment is unimportant because of "push cs"/"pop ds"
        mov     ax,4C00h
        int     21h

hello db 'Hello world!',24h    
But you definitely should load this code at offset 0EFF7h.


Dear baldr,

Yes, you got it ! ^^
I'd like to compile code at the particular offset. (memory address especially)
Sorry about my example isn't good.

Further detail, after I compiled the program to 'helloworld.exe.'
And I execute it, the opcode 'b8 00 4c' can be loaded to particular memory address where I assigned.


Anyway, do you know how to do it ?
Please share your experience, thanks in advance. Embarassed
Post 20 Nov 2008, 00:55
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 20 Nov 2008, 18:54
rednight,

How do you expect code to be loaded at specific address? Copy it yourself.

Or use debug bf000h.bin <script.d, where script.d contains
Code:
m 100 11a b000:eff7
g =b000:eff7    
debug will load given binary file at offset 100h, m command will copy bytes 100..11a to b000:eff7, g will transfer control to that copy. If you compile code to file with com/exe extension, add q command to quit debug. Last line in script.d must end with CR/LF.

May be if you explain the problem in more details…
Post 20 Nov 2008, 18:54
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.