• Advertisement
Sign in to follow this  

assembly program crashes: need help

This topic is 3670 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

this assembly program i've been working with just won't run .MODEL SMALL .STACK 200h .DATA .CODE _START: ;add AX,20h END _START it compiles and links, but when i run it, it crashes if it makes a difference, i'm using masm, and running XP any thoughts?

Share this post


Link to post
Share on other sites
Advertisement
DOS interrupts do work on XP, if you're running a DOS program. In any case, RET should terminate your program nicely. Falling off the end is never the right way. Can you tell me how you're compiling and linking your program?

Share this post


Link to post
Share on other sites
i'm using the winAsm IDE, with MASM and the linker that came with VS08

it's being compiled as a console project, and other than that.. i don't know what to tell ya


ok i think that RET call worked, because nothing at all shows up when i run it, no crash, but no program, so i guess it just finishes so fast i don't see it, but whenever i try to call an interupt, it crashes, i can use MOV, ADD, etc, but when i try INT 20h, or int 21h , its crashes

[Edited by - godsenddeath on April 4, 2008 2:03:49 AM]

Share this post


Link to post
Share on other sites
You're most likely compiling a Windows program. Interrupts are not used to access system functions in Windows, only in DOS. I'm not very familiar with MASM, but I suspect that you should be using .MODEL FLAT instead of .MODEL SMALL. I'm not sure if this affect the code generation, but if it does, it might differentiate between 16-bit and 32-bit modes. You need to use the latter in Windows. To call system functions, you need to import the symbols. Something like this should work:
extern _printf

push myString
call _printf
ret

myString: .db 'Hello\n',0

Here's some info: http://webster.cs.ucr.edu/Page_TechDocs/MASMDoc/ProgrammersGuide/Chap_13.htm

Share this post


Link to post
Share on other sites
when i used MODEL FLAT, i get this

C:\Documents and Settings\Admin\My Documents\New Folder\g.asm(3) : error A2085:instruction or register not accepted in current CPU mode



*EDIT nevermind, i fixed that by adding .386

Share this post


Link to post
Share on other sites
i guess what is really frustrating is that there aren't many good, focused, and modern assembly resources, it seems as though they skip around alot, or they're 20 years old

Share this post


Link to post
Share on other sites
That can be a bit of a problem. You can learn a lot from looking at the assembly output of a C compiler. Microsoft's compiler has the /FA switch for this, although Microsoft apparently does not recommend using the resulting files directly with MASM.

Share this post


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

  • Advertisement