I have been struggling to get a "hello world" running under win32. I found linux examples, but they reference "system.inc" which doesn't seem to be available anywhere!
Can someone post the simplest of simple code examples?
Thanks.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Looks like a typo (probably mine) in the comment for the command line to Alink. There shouldn't be a space between "hwmb" - or "helloworld" - and ".obj". Looks like Alink is treating them as two seperate files... opens "helloworld", adding the default ".obj" extension, apparently (which means you probably don't need it at all), then tries to open ".obj"... without success.
If you're typing that space - don't. :)
If that doesn't fix it... holler again.
Best,
Frank
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
thanks for the quick response...I actually started another thread cuz I saw that this one was kinda old.....that did fix the problem but now instead of saying error opening file helloworld.obj, it is saying win32.lib
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
"push 0Eh" for the messagebox number is kinda non-standard. The "plain OK" messagebox is 0. I'd try that first. By experimentation, I discovered a few "weird" messagebox styles - two "help" buttons, for example. That may be one of 'em. Used to work in 9x, I've been told it doesn't work in the "newfangled" Windows versions...
If that doesn't help... ending a Windows program with "ret" is not too usual, either. Normal thing would be to call "ExitProcess" - wants one parameter on the stack, usually zero. That'll need to be declared "extern", too. If that were the problem, I'd expect it to show the messagebox, and complain on exit...
I'm guessing it was my attempt to be "funny" with the "push 0Eh" that's causing the problem.
The last "push 0", incidentally, is supposed to be the handle of the window (usually called "hinst" or so). If this were a part of a program, instead of a freestanding messagebox, you'd push the handle returned from CreateWindowEx (I think...).
Could probably find a better Hello World example to play with... check the Alink documentation. I think the "main" one is for Tasm, but there's a Nasm one, too. Or, perhaps better, check out:
Okay. The "push dword MessageBoxA" is *not* right. That first push is the "messagebox style" (dunno the right name). It's a seies of defines, usually found in an include file ("win32.inc" or some such name) - MB_OK is zero. Other numbers give other messageboxes. I think it's a bit flag. Some numbers result in a messagebox with no "close" button (alt-F4.. or ctrl-F4? to close it). Experiment! Or perhaps read the documentation...
Best,
Frank
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
org 100h
mov dx,msg
mov ah,9
int 21h
mov ah,4Ch
int 21h
msg db 'Hello, World!',0Dh,0Ah,'$'
I copied and pasted the above into notepad.
saved it as "hello.nsm"
then in windows draged and dropped the "hello.nsm"
onto nasm.exe and it
spit out "hello"
I renamed "hello" to "hello.exe"
copied to root of harddrive.
Opened the dos command window and did enough
cd.. untill on c:
then typed hello and enter and presto
"Hello,World!" appeared.
perfect!!!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have been struggling to get a "hello world" running under win32. I found linux examples, but they reference "system.inc" which doesn't seem to be available anywhere!
Can someone post the simplest of simple code examples?
Thanks.
its on the page www.linuxassemby.org or somthing like that you have to found it
The URL is not valid
http://www.linuxassembly.org/
Ya gotta spell it right :) You'll find "system.inc" and other ".inc"s you'll need in the "asmutils" package.
Here's one for Linux that doesn't need any include files:
; nasm -f elf myprog.asm
; ld -o myprog myprog.o
global _start
section .text
_start
mov eax,4
mov ebx,1
mov ecx,msg
mov edx,msg_len
int 80h
mov eax,1
int 80h
section .data
msg db 'Hello, world',0Ah
msg_len equ $-msg
For Windows... you'll want win32.lib, and probably some massive include files. Get Alink at:
http://alink.sourceforge.net
; assemble: nasm -f obj hwmb.asm
; link: alink -oPE hwmb .obj win32.lib
extern MessageBoxA
segment .data USE32
title1 db 'A Windows Program', 0
string1 db 'Look, Ma! A Windows program!', 0
segment .text USE32
..start
push dword 0Eh ; OK button
push dword title1
push dword string1
push dword 0
call MessageBoxA
ret
I doubt that the "ret" is safe - better to use ExitProcess - seems to work...
Thanks...
org 100h
mov dx,msg
mov ah,9
int 21h
mov ah,4Ch
int 21h
msg db 'Hello, World!',0Dh,0Ah,'$'
[code]
; assemble: nasm -f obj hwmb.asm
; link: alink -oPE hwmb .obj win32.lib
extern MessageBoxA
segment .data USE32
title1 db 'A Windows Program', 0
string1 db 'Look, Ma! A Windows program!', 0
segment .text USE32
..start:
push dword 0Eh ; OK button
push dword title1
push dword string1
push dword 0
call MessageBoxA
ret
[/code]
I am learning assembly and so I wanted to see if I could get this working...which once I got through the error....
colon was required after start,
I tried to use alink to link it, but everytime I do it displays:
loading file helloworld.obj
error opening file .obj
I tried looking for different erros alink would have on google to help me fix this but with no luck,
could someone help me? Thanks
Looks like a typo (probably mine) in the comment for the command line to Alink. There shouldn't be a space between "hwmb" - or "helloworld" - and ".obj". Looks like Alink is treating them as two seperate files... opens "helloworld", adding the default ".obj" extension, apparently (which means you probably don't need it at all), then tries to open ".obj"... without success.
If you're typing that space - don't. :)
If that doesn't fix it... holler again.
Best,
Frank
thanks for the quick response...I actually started another thread cuz I saw that this one was kinda old.....that did fix the problem but now instead of saying error opening file helloworld.obj, it is saying win32.lib
And if I take out the win32.lib part it says......
loading file helloworld.obj
matched externs
matched comdefs
unresolved external MessageBoxA
Well, I moved the win32.lib into the folder with the program and it worked...thanks for you help
well, it might have worked as far as alink was concerned, but the helloworld.exe that is created doesn't do anything??
Minor bug. Ignore it. :)
Seriously... what could be wrong?
"push 0Eh" for the messagebox number is kinda non-standard. The "plain OK" messagebox is 0. I'd try that first. By experimentation, I discovered a few "weird" messagebox styles - two "help" buttons, for example. That may be one of 'em. Used to work in 9x, I've been told it doesn't work in the "newfangled" Windows versions...
If that doesn't help... ending a Windows program with "ret" is not too usual, either. Normal thing would be to call "ExitProcess" - wants one parameter on the stack, usually zero. That'll need to be declared "extern", too. If that were the problem, I'd expect it to show the messagebox, and complain on exit...
I'm guessing it was my attempt to be "funny" with the "push 0Eh" that's causing the problem.
The last "push 0", incidentally, is supposed to be the handle of the window (usually called "hinst" or so). If this were a part of a program, instead of a freestanding messagebox, you'd push the handle returned from CreateWindowEx (I think...).
Could probably find a better Hello World example to play with... check the Alink documentation. I think the "main" one is for Tasm, but there's a Nasm one, too. Or, perhaps better, check out:
http://www.asmcommunity.net/projects/nasmx/
Should be some more "up to date" examples there.
Best,
Frank
[code]
extern MessageBoxA
segment .data USE32
title1 db 'A Windows Program', 0
string1 db 'Look, Ma! A Windows program!', 0
segment .text USE32
..start:
push dword MessageBoxA ; OK button
push dword title1
push dword string1
push dword 0
call MessageBoxA
ret
[/code]
that works......and if I use:
[code]
extern MessageBoxA
extern ExitProcess
segment .data USE32
title1 db 'A Windows Program', 0
string1 db 'Look, Ma! A Windows program!', 0
segment .text USE32
..start:
push dword MessageBoxA ; OK button
push dword title1
push dword string1
push dword 0
call MessageBoxA
call ExitProcess
[/code]
it has an error on closing, I dont know if I was doing it right
duhhhh....I just needed to take the brackets off the call ExitProcess
Okay. The "push dword MessageBoxA" is *not* right. That first push is the "messagebox style" (dunno the right name). It's a seies of defines, usually found in an include file ("win32.inc" or some such name) - MB_OK is zero. Other numbers give other messageboxes. I think it's a bit flag. Some numbers result in a messagebox with no "close" button (alt-F4.. or ctrl-F4? to close it). Experiment! Or perhaps read the documentation...
Best,
Frank
org 100h
mov dx,msg
mov ah,9
int 21h
mov ah,4Ch
int 21h
msg db 'Hello, World!',0Dh,0Ah,'$'
I copied and pasted the above into notepad.
saved it as "hello.nsm"
then in windows draged and dropped the "hello.nsm"
onto nasm.exe and it
spit out "hello"
I renamed "hello" to "hello.exe"
copied to root of harddrive.
Opened the dos command window and did enough
cd.. untill on c:
then typed hello and enter and presto
"Hello,World!" appeared.
perfect!!!
Seems like no one has used (or uses) the 13h service routine of INT 10h yet. I am using DOS on Windows XP platform. The following is my code snippet.
main:
msg db "Hello World\n", 0
msglen equ $-msg
xor bp, bp
mov es, bp
mov ax, [msg]
mov [es:bp], ax
xor ax, ax
mov ah, 0x13
mov al, 01h
mov bh, 00h
mov bl, 0Ah
mov cx, msglen
xor dx, dx
int 10h
It yielded garbage..