Jump to content
  • Advertisement
Sign in to follow this  
ajm0528

ASM Code Question

This topic is 3710 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have an ASM Code Question. I recently downloaded/installed WinAsm Studio and wanted to test a simple Hello World application. When I assembled the code, I got two errors; one of them I fixed by adding an underscore infront of the 'main proc' statement. The other error says: D:\Programming\helloworld.asm(18) : fatal error A1010: unmatched block nesting : main Here is the code:
.model small
.stack
.data
message   db "Hello world, I'm learning Assembly !!!", "$"

.code

_main   proc
   mov   ax,seg message
   mov   ds,ax

   mov   ah,09
   lea   dx,message
   int   21h

   mov   ax,4c00h
   int   21h
main   endp
end main

Can anyone tell me what's wrong?

Share this post


Link to post
Share on other sites
Advertisement
It looks like you edited your post, and the line with the error appears to be outside of the code you pasted. Can you paste the entire source?

Share this post


Link to post
Share on other sites
Quote:
Original post by ajm0528
The other error says: D:\Programming\helloworld.asm(18) : fatal error A1010: unmatched block nesting : main


You gave _main to the proc macro and main to endp -- they need to match. Just add an underscore there. x)

Share this post


Link to post
Share on other sites
Just in case you're not aware, since it seems to come up fairly routinely, the code you have there is 16-bit DOS code. Windows will emulate it for you but it isn't native Windows code (or any other even vaguely modern OS).

I'm not saying that what you're doing is completely wasted effort, but a lot of the kind of stuff people usually start doing as a next step from that point (e.g. talking directly to "video memory") either doesn't work at all or is extremely slow because of the layers of emulation needed to get it to work.

Share this post


Link to post
Share on other sites
Quote:
Original post by Anon Mike
Just in case you're not aware, since it seems to come up fairly routinely, the code you have there is 16-bit DOS code. Windows will emulate it for you but it isn't native Windows code (or any other even vaguely modern OS).

I'm not saying that what you're doing is completely wasted effort, but a lot of the kind of stuff people usually start doing as a next step from that point (e.g. talking directly to "video memory") either doesn't work at all or is extremely slow because of the layers of emulation needed to get it to work.


The tutorial I was looking at is most likely really old. I just found it on a search and saw the Hello World program.


Oxyd, when I add the underscore to the second main statement I get these:

Assembling: D:\Programming\testcode.asm
D:\Programming\testcode.asm(19) : error A2006: undefined symbol : main
D:\Programming\testcode.asm(9) : error A2004: symbol type conflict
D:\Programming\testcode.asm(19) : error A2148: invalid symbol type in expression : main

Share this post


Link to post
Share on other sites
Ok, i put an underscore infront of all the 'main' statements and I get this:

D:\Programming\testcode.asm(9) : error A2004: symbol type conflict

which marks this line of code in the editor:
mov   ax,seg message

Share this post


Link to post
Share on other sites
Are you sure 'seg' has to be infront of 'message'? I'm just a beginner but never saw that in my HW program...

Share this post


Link to post
Share on other sites
Quote:
Original post by Decrius
Are you sure 'seg' has to be infront of 'message'? I'm just a beginner but never saw that in my HW program...


I tried removing 'seg' and I still get errors. Oh well, I was just wanting to mess around with ASM right now but I guess I'll stick to C++.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!