what is the different styles of com file structure?

Started by amitjoc, April 20, 2010, 03:42:40 PM

Previous topic - Next topic

amitjoc

; Template for DOS .com file

.model tiny

        code    segment

        org     100h

start:

; ...Put your code here...

; exit to DOS
        mov     ax, 4c00h
        int     21h

        code    ends

end start



above is the RadAsm Template and mostly used structure and i am using below structure what is the difference please tell

; a program to add three numbers using memory variables
[org 0x0100]
           mov  ax, [num1]         ; load first number in ax Computer Architecture & Assembly Language Programming Course Code: CS401
           mov  bx, [num2]         ; load second number in bx
           add  ax, bx                 ; accumulate sum in ax
           mov  bx, [num3]         ; load third number in bx
           add  ax, bx                 ; accumulate sum in ax
           mov  [num4], ax         ; store sum in num4

            mov  ax, 0x4c00         ; terminate program
            int  0x21

num1:         dw   5
num2:         dw   10
num3:         dw   15
num4:         dw   0

dedndave

hi again   :bg

.COM files are 16-bit only - they cannot be made for win32
although, they can be run under any 16-bit or 32-bit windows operating system

to link 16-bit code, you need to use a different linker
you can download a 16-bit linker and place it in the masm32\bin folder
http://website.masm32.com/microsoft/Lnk563.exe

also, i have attached a batch file for assembling 16-bit programs using that linker
place the unzipped batch file in masm32\bin also
then, you can assemble from the command line...

a16 MyProg

oh - by the way
for 16-bit questions, we have a special subforum
scroll down to the list of subforums

FORTRANS

Hi,

   The RadAsm template is written for MASM style assemblers.
Note the .MODEL and END directives and the hexadecimal numbers
end with an H.

   The other program is written for a different assembler.  Note
the missing END directive the different ORG directive format and
the hex number format is different.

Steve

clive

Given the x86 isn't a Load-Store architecture the following would be more efficient


          mov  ax, [num1]         ; load first number in ax
          add  ax, [num2]         ; add second number into ax
          add  ax, [num3]         ; add third number into ax
          mov  [num4], ax         ; store sum in num4
It could be a random act of randomness. Those happen a lot as well.

dedndave

hi Clive
he is just starting out
trying to get a program assembled and step through it with a debugger (i think)
i remember, back in the 16-bit days, things were so much simpler   :bg
i think, as far as IBM PCs, i started out much the same way
except i just had the debugger - lol
with a little practice, you can actually write a program with it

clive

Indeed, but having multiple examples of how to do the same thing is also instructive. The x86 isn't an accumulator locked instruction set like say the 6502 or Z80 (A 8-bit/HL,IX,IY 16-bit), but it can't do memory-to-memory in the manner the 68000 could. And it is not a load store, like say ARM or MIPS, which can only load/store registers, and performs all logic/math operations register-to-register.

-Clive
It could be a random act of randomness. Those happen a lot as well.

clive

Quote from: dedndave
with a little practice, you can actually write a program with it

Yes, DDT, SID, DEBUG could be used to input and save assembler. It was also significantly cheaper than buying an assembler, and they came with the system so it could be readily used in the field, so you could fix/patch things. I've also entered stuff with switches and paper tape, but I don't think that is a useful skill today.

-Clive
It could be a random act of randomness. Those happen a lot as well.

MichaelW

This uses the simplified segment directives:

.model tiny
.data
.code
.startup
.exit
end

Specifying tiny in the memory model field of the .model directive tells the assembler to create a .COM program. The .data directive opens a data segment. Define your data (memory variables) between the .data and .code directives. The .code directive closes the data segment and opens a code segment. For a tiny memory model the .startup directive effectively generates an org 100h statement. This tells the assembler that the offset addresses in the program should start at 100h, to match the offset address where the program will be loaded at runtime. The .exit directive generates the sequence:

mov ah, 04Ch
int 021h

You should place your code between the .startup and .exit directives. For a .COM program the linker combines the code and data segments into a single segment, placing the code first (at the lower addresses) and the data last. For the assembler a minimal command line would be:

ML /c filename.asm

And for the linker:

LINK16 /tiny filename.obj;
eschew obfuscation

amitjoc

First of all A jumbo Big, dinosaur big Thanks   :U
all of you for taking time to a newbie and
your attachment really helped me
and this time my special thanks to " MichaelW "

by the way i have IBM PC assembly Language and Programming Book and Art of assembly if any one want to make
a suggestion It also Help me

:cheekygreen: :cheekygreen: :cheekygreen: :boohoo: :boohoo: