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

first asm program help

first asm program help

first asm program help

I started a book on assembly, but it's a bit old and I wasn't able to assemble the fist program :s. Here's the code:


.STACK  64
    DATA1    DB    52H
    DATA2    DB    29H
    SUM     DB      ?
           MOV        AL,DATA
           MOV        DS,AL
           MOV        AL,DATA1
           MOV        BL,DATA2   
           ADD        AL,BL
           MOV        SUM,AL
           MOV        AH,4CH
           INT         21H
           END    MAIN
What changes would need to be made for this program to work? Thank you.

RE: first asm program help

Which assembler program were you using for this?

RE: first asm program help

I'm on Windows and I tried doing compiling with MASM32.

RE: first asm program help

That code looks very much like 16 bit dos assembler to me.

I'd bet that MASM32 wouldn't like it much, as you've found out.

If you have a look through some of the threads in this forum, you'll see that various free assemblers are recommended that will cope very nicely with dos type programming.

A86 is one that springs to mind.

And there's one called NASM that gets recommended too.

Some of these assemblers might need to be run from as dos prompt or command prompt.

You'll also need a debugger to execute the code: debug is still supplied with Windoze but there are better debuggers available... clown like D86.

RE: first asm program help

Thanks, I'll look for NASM for 16-bit code. But I'd still like to know how I'd write it in win32 (I read an ebook by Dr. Paul Carter on win32 ASM, but he mixes it with C to make the actual program). Thank you very much.

RE: first asm program help

There is a bit of a problem if your writing code
for win32.
The segment registers can't be changed the way as in 16 bit
or real code assembly.
The segment registers under win32 hold segment selectors and not real segment values.
The selectors are read from a Global Discripter Table.
So if you don't use DS ES FS gs or SS derecty you can run
the code with win32.

Succes, Tessa

RE: first asm program help

Don't misunderstand the statement:
"So if you don't use DS ES FS gs or SS derecty you can run the code with win32". If you use an assembler that thinks it's writing 32-bit code, the product won't run in a 16-bit environment. There are all sorts of differences beyond the (very true) difference in segment registers. For instance, if the processor thinks it's in 32-bit mode then every reference to ax will involve a segment size override prefix byte that the assembler must put in. If it's in 16 bit mode there won't be an override prefix for ax, but there would be for eax. The assembler and the processor need to be in agreement about this!

You don't need debug to run your program assuming you have an assembler that comes with some sort of linker and can therefore create a .exe (or .com) file. I can't speak for nasm or a86 being a tasm person, which comes with tlink. tasm produces the object file (.obj) and tlink turns it into an exe.

RE: first asm program help

Would it be possible for you to write me a skeleton that I could use to write 32 bit programs? Thank you.

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