flat assembler
Message board for the users of flat assembler.

Index > Main > can I use multiple source files?

Author
Thread Post new topic Reply to topic
lazer1



Joined: 24 Jan 2006
Posts: 185
lazer1 01 Apr 2006, 17:59
can I divide my code into multiple source files? Shocked

how will code in 1 file reference things in another source file?

on 68k assemblers you tend to use xref and xdef,
Post 01 Apr 2006, 17:59
View user's profile Send private message Reply with quote
UCM



Joined: 25 Feb 2005
Posts: 285
Location: Canada
UCM 01 Apr 2006, 18:29
yes
you reference them directly, use
Code:
 include 'name_of_file_that_you_are_trying_to_include.asm'     

this includes them directly. for example:

MAIN.ASM
Code:
call NOTMAIN
jmp BLAH
RANDOM:
include 'NOTMAIN.ASM'
    


NOTMAIN.ASM
Code:
NOTMAIN:
mov eax,0x39590395
ret
BLAH:
mov ebx,0x8234
jmp RANDOM
    

This assembles correctly (if you assemble MAIN.ASM, that is.)
Post 01 Apr 2006, 18:29
View user's profile Send private message Reply with quote
lazer1



Joined: 24 Jan 2006
Posts: 185
lazer1 02 Apr 2006, 00:23
UCM wrote:
yes
you reference them directly, use
Code:
 include 'name_of_file_that_you_are_trying_to_include.asm'     

this includes them directly. for example:

MAIN.ASM
Code:
call NOTMAIN
jmp BLAH
RANDOM:
include 'NOTMAIN.ASM'
    


NOTMAIN.ASM
Code:
NOTMAIN:
mov eax,0x39590395
ret
BLAH:
mov ebx,0x8234
jmp RANDOM
    

This assembles correctly (if you assemble MAIN.ASM, that is.)


that is what I've been doing so far, unfortunately I've globbed so
much code that the binaries no longer run,

if I comment out some of the includes which arent referenced they
run,

my code right at the start calls a subroutine right at the end
and the code fails.

I tried expanding out all the includes and the binary still fails:

the globbed source is 71295 bytes including a lot of comments
and the resulting binary which doesnt run is 18700 bytes,

are there any limits on the size of a source file for fasm?

maybe I will experiment and find the size at which the file fails,

I tried the -m option also and it makes no difference,

it all depends how much source code is present:

with 61356 bytes of source the binary was fine
and with 64079 bytes of source there was partial malfunction,
with the full version 71295 bytes there is a lot of malfunction,

I'm going to try and insert say 10K of fake comments to
the 61356 byte file and see if it functions,

UPDATE:

there appears to be a bug in fasm as regards source file size:

with the 61356 source file I inserted a huge amount of
fake comments which produced an IDENTICAL correct binary,

however I then created an extra include file with 4689 nop instructions
and the machine not only malfunctioned but it reset,

so there is a bug in fasm if there are too many source instructions,
and at the start you call a subroutine right at the end:

try inserting a huge number of nop instructions,

[editted out an apparent further problem which wasnt a problem]

this code is loaded to 10000h, and the stack is from 20000h to 2fff0h
so it cannot be trashing its own stack,
Sad

is there a reliable 16 bit real disassembler that I can use,
because the problem happens right at the start,

unfortunately XP's "debug prog.bin" disassembly is useless,

FURTHER UPDATE (some hours later!)

I've been comparing disassemblies, the fasm output
looks correct, maybe the bug is in the program I wrote
to copy the binary to disk, I'll study that.
Post 02 Apr 2006, 00:23
View user's profile Send private message Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2138
Location: Estonia
Madis731 02 Apr 2006, 11:10
Use OllyDbg as a visual debugger. Much better than the debug program.
Post 02 Apr 2006, 11:10
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
lazer1



Joined: 24 Jan 2006
Posts: 185
lazer1 02 Apr 2006, 13:41
after much study the bug appears to be
that int 13h ah=2 to read sectors from a floppy
to ram will not copy beyond the cylinder boundary: Embarassed

with my boot code the first sector
loads the next 32K of sectors to 10000h and
then jmp's to 10000h,

as I dont have any echo facilities in the first sector
I wasnt checking the error status of this copy to ram,

by hacking an error message I've found that

if I copy 35 sectors from sector 2 there is no error
but if I copy 36 sectors there is error,

recall I was getting malfunction with an 18k binary
which will require 36 sectors as 35 sectors is 17920 bytes,

IIRC a floppy's geometry is 80 x 2 x 18

so the first cylinder is 1,2,3,....,36

so it is failing when I try to copy beyond the cylinder!

(next cylinder is 37 onwards, 37-2+1==36)

I need to get around the problem without making
any disk geometry assumptions, so either a
3 phase boot or see if there is some way to do it
in the first sector,

are there unconstrained ways to copy sectors from a floppy
better than int 13h ah==02h ?
Post 02 Apr 2006, 13:41
View user's profile Send private message Reply with quote
RedGhost



Joined: 18 May 2005
Posts: 443
Location: BC, Canada
RedGhost 02 Apr 2006, 23:27
lazer1 wrote:

are there unconstrained ways to copy sectors from a floppy
better than int 13h ah==02h ?


http://board.flatassembler.net/topic.php?t=4757

_________________
redghost.ca
Post 02 Apr 2006, 23:27
View user's profile Send private message AIM Address MSN Messenger Reply with quote
lazer1



Joined: 24 Jan 2006
Posts: 185
lazer1 05 Apr 2006, 21:56
RedGhost wrote:
lazer1 wrote:

are there unconstrained ways to copy sectors from a floppy
better than int 13h ah==02h ?


http://board.flatassembler.net/topic.php?t=4757


looks like the ultimate way to do it! Razz
Post 05 Apr 2006, 21:56
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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.