Author Topic: Running a plain asm program in Windows 7 64-bit  (Read 20011 times)

Offline Luns

  • Jr. Member
  • *
  • Posts: 9
Running a plain asm program in Windows 7 64-bit
« on: March 24, 2011, 04:50:46 AM »
I'm trying to learn plain assembly, with no C function calls or anything.  I've assembled my code with NASM, and then tried running it in DOSbox, but nothing happens.  Here's my program...

Code: [Select]
org 100h
mov dx,msg
mov ah,9
int 21h
mov ah,4Ch
int 21h
msg db "Hello, World!",0Dh,0Ah,'$'

And then I assemble it with 'nasm -o hello.com -f bin hello.asm'.  I run it in DOSbox by just typing 'hello.com', but all that happens is it skips a line and gives me another command prompt.  Is the code right?  I just got it from here.

Thanks for looking.

e:  I just tried downloading the DOS version of NASM and assembling the program with that in DOSbox, but the same thing happens.
« Last Edit: March 24, 2011, 05:17:12 PM by Luns »

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: Running a plain asm program in Windows 7 64-bit
« Reply #1 on: March 24, 2011, 07:56:25 PM »
OMG, the "Clueless Newbie's Guide"... Well, it "should" still work. Your code looks fine (I would think that, of course :) ). One fairly common mistake is to write "int 21" instead of "int 21h" - you don't seem to have done that. Leaving out the "org 100h" will usually output "garbage" - you don't seem to have done that, either. I dunno.

I have no experience with "dosbox" - I've downloaded it, but can't get it to build. I may have another go at it "one of these days". Even if I had it, "dosbox" for Linux might not be the same as "dosbox" for 64-bit Windows, so it might not help diagnose what's going on. I assume "dosbox" is working normally for you, outside of this problem(?)...

It "shouldn't" matter which build of Nasm you're using - the command line determines the type of file you get. Probably more convenient to have Nasm that'll run within "dosbox", though...

I can't even think what to try... maybe BIOS output?

Code: [Select]
; nasm -f bin -o myfile.com myfile.asm
org 100h

mov bx, 7
mov ah, 0Eh
mov al, 'X'
int 10h

ret

I really don't know what it'll tell you if that works - or doesn't. Essentially, like our hypothetical "Clueless Newbie", I haven't got a clue!

Best,
Frank


Offline Keith Kanios

  • Full Member
  • **
  • Posts: 383
  • Country: us
    • Personal Homepage
Re: Running a plain asm program in Windows 7 64-bit
« Reply #2 on: March 24, 2011, 11:55:14 PM »
Frank's newbie example works fine here:
-Windows 7 Professional 64-bit
-DOSBox 0.74
-NASM 2.05/2.09.07/2.10rc4

Offline Luns

  • Jr. Member
  • *
  • Posts: 9
Re: Running a plain asm program in Windows 7 64-bit
« Reply #3 on: March 25, 2011, 01:45:40 AM »
Haha oh that's your guide?  Thanks very much for it, it's very helpful for first starting with assembly.

I have no idea what I changed, but I went back and tried it with the original code and it works now... No clue why but I'm just happy it works.

Thanks very much  :)

Offline David Stone

  • Jr. Member
  • *
  • Posts: 4
Re: Running a plain asm program in Windows 7 64-bit
« Reply #4 on: March 26, 2011, 05:06:57 AM »
It was helpful to me also. A perfect thing for the beginners.