flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
mns 26 Sep 2015, 06:56
I want to call a function which is in an another *.inc file from a segmented memory programme and experimented with a test programme. Although finally i could made a working programme(attached here with), i had to make the function (in the .inc file) as a separate segment and call it from the main source as below
call segment name:function name eg: call extra:wrtsrn , in my programme is there any other way that i could call a function in a .inc file with only it's function name(without segment name or without giving it a segment name in .inc file) in segmented memory programme?
|
|||||||||||
![]() |
|
mns 26 Sep 2015, 17:18
thanks ACP. I tried by including .inc in data segment(of the main programme) +without another code segment name in .inc file but failed.(in vbox winxp system).then only i came up with above solution.
|
|||
![]() |
|
ACP 26 Sep 2015, 18:17
You are welcome.
Placing code in data segment is a good idea in most cases and could be considered bad practice generally speaking. DOS compatible systems are quite flexible due to their simplicity but more modern operating systems working in protected/long mode will not allow you to execute code from data section (or stack) without actually marking the memory as executable. Stick to the solution I've gave you and you will be fine ![]() |
|||
![]() |
|
mns 27 Sep 2015, 05:16
ACP, i'm afraid you didn't understand what i.ve said.i tried lot of things including your solution they all show either empty console which has to be close forcefully or continuous loop of my strings(character strings in data section) printed in console window (in winxp) which also have to forcefully close.
|
|||
![]() |
|
ACP 27 Sep 2015, 08:24
This is one way to make your code working. I don't know why are you touching ES register in second file. Also pusha/popa does not touch segment registers so either add push ds / pop ds at your procedure or you have to reinitializate it after returning to main if you are about to add more code reference data using DS.
test1.asm Code: format MZ heap 0 stack 64 entry main:start segment main use16 start: mov ax,data1 mov ds,ax mov es,ax mov dx,txt1 mov ah,9h int 21h call wrtsrn xor ah,ah int 16h mov ax,4c00h int 21h include 'wrtsrn.inc' ;-------------------------------------------------------------------------------------------------------------------------------------------------- ;------------------------------------------------------------data------------------------------------------------------------------------- segment data1 txt1 db 'testing segmented mode',24h wrtsrn.inc: Code: ;wrtsrn.inc----------------------- wrtsrn: pusha mov ax,data2 mov ds,ax mov es,ax mov ah,9h mov dx,text int 21h popa ret segment data2 text db 9h,'hello world',24h |
|||
![]() |
|
mns 27 Sep 2015, 17:20
Thank you very much ACP pointing it out that mistakes and correcting me.
![]() so it is, where you include .inc file in the main program matters. it should include in the end of the code segment of the main programme then? |
|||
![]() |
|
ACP 27 Sep 2015, 17:53
mns wrote: Thank you very much ACP pointing it out that mistakes and correcting me. No. It is included there due to a fact that you declare in inc file additional data segment and the way FASM is creating segments in MZ EXE file. |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.