.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
🔒 Locked
ASM Code Question
Advertisement
Original Post
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: Can anyone tell me what's wrong?
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.
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.
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
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++.
This is what 'Assembly Language Step-by-step' from Jeff Dunteman has as HW example. Note that you need to use NASM.
main.asm
NASM command line: nasm main.asm -f bin -o main.exe
main.asm
bits 16org 0100hsection .textstart: mov dc, helloworld mov ah, 9 int 21h mov ax, 04c00h int 21hsection .datahelloworld db "Hello world!", 13, 10, "$"NASM command line: nasm main.asm -f bin -o main.exe
Quote:
Original post by RabidDog
Wild stab in the dark, have you tried _message?
Didn't work. Maybe somethings wrong with WinAsm? I'm trying to get NASM to try it out.
I can't even get nasm to work. Maybe ASM isn't for me. :/ I seem to keep getting that stupid error talking about the underscore for 'main' I keep putting one but it still won't work. Even MASM32 gave me the same errors, even on several versions of this code. I can't figure this one out.
[Edited by - ajm0528 on July 23, 2008 5:36:41 PM]
Ok, so....messing around with WinAsm some more I discovered that when I make a new project, if I choose DOS->DosCom, a source file opens with template code that looks like this:
When I "Go-All," it works but the DOS window flashes briefly and closes. It doesn't stay open, showing the text. Any ideas on how to make the window pause to stay open?
All in all, the problem is fixed (guess the first tutorial I found was OLD code or something. The code above seems to work just fine. I just need to know how to make the window pause so you can actually read the text.
.model tiny.data msg db "This is a 16-bit DOS .COM executable",13,10,"Hello World!",13,10,"$" ; The string must ends with a $.code .startup mov dx,offset msg ; Get the address of our message in the DX mov ah,9 ; Function 09h in AH means "WRITE STRING TO STANDARD OUTPUT" int 21h ; Call the DOS interrupt (DOS function call) mov ah,0 ; Call bios function "GET KEYSTROKE" int 16h .exitendWhen I "Go-All," it works but the DOS window flashes briefly and closes. It doesn't stay open, showing the text. Any ideas on how to make the window pause to stay open?
All in all, the problem is fixed (guess the first tutorial I found was OLD code or something. The code above seems to work just fine. I just need to know how to make the window pause so you can actually read the text.
You need to run it from a command line. Or, perhaps your IDE has an option to keep the window open.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement