; Source name : EAT.ASM
; Executable name : EAT.COM
; Code model: : Real mode flat model
; Version : 1.0
; Created date : 6/4/1999
; Last update : 9/10/1999
; Author : Jeff Duntemann
; Description : A simple example of a DOS .COM file programmed using
; NASM-IDE 1.1 and NASM 0.98.


[BITS 16] ; Set 16 bit code generation
[ORG 0100H] ; Set code start address to 100h (COM file)

[SECTION .text] ; Section containing code
START:

mov dx, msg; Mem data ref without [] loads the ADDRESS!
mov ah,9 ; Function 9 displays text to standard output.
int 21H ; INT 21H makes the call into DOS.

mov ax, 04C00H ; This DOS function exits the program
int 21H ; and returns control to DOS.

[SECTION .data] ; Section containing initialized data

msg db "This is a message", 17, 10, "$" ;Here's our message

Reading from a book, I played around with it then I got sick of it and nothing worked so I directly copied and pasted that code to try to get it to run. It compiles, but its almost as if the interrupts are ignored. So maybe the IF flag is set? I'm not sure, I tried MOV IF,1. It wouldn't assemble so =S Any help would be greatly appreciated.

BTW I'm compiling as a COM.

Recommended Answers

All 6 Replies

What OS are you using? I'm not sure if that stuff is still working under NT (Win 2000 or higher). Than you have to link it directly to an exe (with Link) and execute it.
If so than have a look at the BIOS-interrupt INT 13h (http://www.ctyme.com/rbrown.htm - bookmark this site it's very, very, very important and Ralf Brown is your God!). Int 13h can also be used in the oder DOS-Versions so you bet use that in the future.

By the way: I also startet with Jeff Duntemans Book "Assenbly Language Step by Step" and I can guarantee you that this book is one of the best to start assembling. So keep going!

Greetings
Simon

PS I think that INT13h is also covered in that book a few chapters a head. Have a look there.

Thanks, I'm running windows XP. And yes this book is a life saver, the only one I actually feel I understand. I'll give Int 13h a shot. Thanks again.

Hmm doesn't seem to work. I'm linking it via ALINK

Ahh, I see I got it to work. Thank you for your help.

Hi, jetamay:

I almost encountered the same problem as you had. Can you tell me how to make it work under Windows XP?
Thank you very much!

Garry

I see that you are using [org 0100h], that is a .COM file.. you cannot use a linker on it!

From the looks of it, you are trying to display "This is a message."
Give this a shot.. if you are using NASM16, assembly it with this

nasm16 text.asm -o text.com

And also, try this code out. Name the file 'text.asm' and use the NASM16 command above to assemble it.

[org 0100h]

[section .text]
mov dx,msg1		;Load the message into DX
mov ah,9		                ;Function 9 - Display string
int 21h			;Make the call into DOS and display it

mov ax,4ch		;Terminate DOS process
mov ah,0		                ;Exit with ERRORLEVEL of 0
int 21h			;Call DOS and exit



[section .data]
msg1 db "This is a message.", 13, 10, "$"
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.