flat assembler
Message board for the users of flat assembler.
Index
> DOS > My first "Hello_world" app |
Author |
|
DJ Mauretto 08 Oct 2010, 15:14
Hello........
Code: org 100h use16 mov ax,0003h int 10h mov ah, 09h mov dx,SAY int 21h xor ax,ax int 16h ret SAY db 'hello_world',24h _________________ Nil Volentibus Arduum Last edited by DJ Mauretto on 08 Oct 2010, 15:16; edited 3 times in total |
|||
08 Oct 2010, 15:14 |
|
LocoDelAssembly 08 Oct 2010, 15:14
You need a 16- or 32-bit OS. However, the most likely problem by which your program didn't do anything was just because the very first instruction is RET (i.e. return).
The proper way is this: Code: mov ah, 09h mov dx,SAY int 21h int 20h ; Use this to exit program instead of plain RET for COM files ; x86 is not Harvard arquitecture, therefore you must be careful not to put data in places where it could get executed. ; Placing data just after an unconditional branch (like Int 20h above) is enough SAY db 'hello_world' |
|||
08 Oct 2010, 15:14 |
|
maton1200 08 Oct 2010, 16:24
@DJ Mauretto : thanks, those interrupts are very helpful, but why do you put 24h at the end of text?.
@locodelassembly: thanks but your code compiles as .BIN and it runs weird after I rename it to .COM, weird smileys show up onscreen |
|||
08 Oct 2010, 16:24 |
|
DJ Mauretto 08 Oct 2010, 16:28
Quote: thanks, those interrupts are very helpful, but why do you put 24h at the end of text?. Dos function use 24h or '$' as end of string _________________ Nil Volentibus Arduum |
|||
08 Oct 2010, 16:28 |
|
LocoDelAssembly 08 Oct 2010, 18:10
maton1200, sorry, I stripped the "org 100h" by accident, it should be the first thing in the source. And the wierd stuff is because I forgot to terminate the string with the dollar sign as DJ Mauretto mentions.
|
|||
08 Oct 2010, 18:10 |
|
maton1200 11 Oct 2010, 02:50
Thanks.
I'm trying to run my app in Windows 7 ultimate X64 command line but i get this message. "This version of ( my app) is not compatible with the version of Windows you are running. Check your computer.." etc. I dont know if the interrupts are not valid in 64 bit OS. Any ideas? _________________ ...... |
|||
11 Oct 2010, 02:50 |
|
Tyler 11 Oct 2010, 02:59
NTVDM was removed from x64 Windows. You have to either run it in a DOS emulator, like DOSBox or DOSEmu, or rewrite it as 32 or 64 bit. The interrupts will not work as you want in 32 and 64bit mode, you will have to use some kind of API like WinAPI or libc.
Alternatively, if your processor supports hardware based vitalisation, you can install XP Mode, which is capable of running 16bit tasks. |
|||
11 Oct 2010, 02:59 |
|
revolution 11 Oct 2010, 04:55
maton1200: Basically, Windows 7 64-bit does not support 16-bit programs. You need to download one of the DOS emulators or run a VM.
But perhaps a better option would be to write this as a 32-bit application: Code: include 'win32ax.inc' .code start: invoke MessageBox,0,'Hello world!','Hello world!',0 invoke ExitProcess,0 .end start |
|||
11 Oct 2010, 04:55 |
|
maton1200 11 Oct 2010, 13:55
@Tyler thanks, and yes, I do have an XP VM in VMWARE player but I want my codes to be executed in W7 32 and 64 bit.
@revolution : so basically I cant assemble MS-DOS code for W7 64 bit, and all I have to do is program code compatible with Window's API which is quite similar to that code you just wrote ?. |
|||
11 Oct 2010, 13:55 |
|
revolution 11 Oct 2010, 13:59
maton1200 wrote: @revolution : so basically I cant assemble MS-DOS code for W7 64 bit, and all I have to do is program code compatible with Window's API which is quite similar to that code you just wrote ?. |
|||
11 Oct 2010, 13:59 |
|
rugxulo 11 Oct 2010, 19:58
Installing and using DOSBox is extremely easy, and it works very well. But it's quite slow. It's not suitable for anything other than games and simple apps. (No compiling under it, that would be annoying even if it would, only sometimes, work.)
XP Mode doubles your HD and RAM requirements, and it's technically (legally?) only available to non-home users, e.g. Business, Enterprise, Ultimate. (Why??) But it doesn't need VT-X anymore, thankfully. At least if you're going to run 64-bit, you should have enough RAM for plenty of VMs. |
|||
11 Oct 2010, 19:58 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.