flat assembler
Message board for the users of flat assembler.
![]() Goto page 1, 2 Next |
Author |
|
revolution 27 Feb 2012, 14:02
Windows 64-bit does not support the DOS VM (NTVDM). You can't run any DOS program natively. You can either use an external VM (like DosBox) or write some Windows native 32-bit or 64-bit code.
|
|||
![]() |
|
Coty 27 Feb 2012, 14:03
Hello! Windows 64bit does not, in anyway support 16bit programs, this could only be run properly on windows XP 32bit.
To run the program on x64 you can do one of 3 things. 1) Find different code that uses 32bit or 64bit. 2) Download a DOS emulator like DOSBOX, with DOSBOX you can drag and drop your 16bit program onto the DOSBOX.EXE and it will emulate it wonderfully! 3) You can downgrade to windows XP 32bit, but I do not sugjest this on a 64bit machine as 64bit OS runs faster on 64bit machines. Get DOSBOX here: http://www.dosbox.com/ You should take note, that unlike programming languages like C++, assembly can not simply have a few flags changed to run in x64, you have to write code that will run in x64. This is why people call assembly "un-portable", because you must re-write the code. However, imho re-writing the code is better anyway since you can take full advantage of the machine properly. |
|||
![]() |
|
majidkamali1370 27 Feb 2012, 18:23
use64 does not work here?
![]() |
|||
![]() |
|
Coty 28 Feb 2012, 01:42
No! For one there is no header on a DOS program file! MS windows uses an ELF(?) like header at the beginning of its code that tells windows many things about the program. DOS files are basically RAW binary files. Another thing is, windows does not have the OLD DOS API! Thus, Windows has no idea what int 21h is!
Even windows XP 32bit has no idea what int 21h is, however, if the program is names *.COM, WinXP will launch a built in emulator that for some reason was removed in all 64bit OSes... and any OS newer than windows vista (however 32bit windows vista and windows 7 support text mode only emulation of 16bit programs, and will work so long as it doesn't go into VGA graffics mode or write to screen without using INTS. Last edited by Coty on 28 Feb 2012, 01:47; edited 1 time in total |
|||
![]() |
|
revolution 28 Feb 2012, 01:46
Coty wrote: MS windows uses an ELF(?) like header at the beginning of its code that tells windows many things about the program. |
|||
![]() |
|
Andy 28 Feb 2012, 08:52
Okey. And from where I should start learning about programming FASM on x64 machines? A very basically example would be great. Thanks!
|
|||
![]() |
|
revolution 28 Feb 2012, 09:09
Andy wrote: Okey. And from where I should start learning about programming FASM on x64 machines? A very basically example would be great. Thanks! Code: ; Example of 64-bit PE program format PE64 GUI entry start section '.text' code readable executable start: sub rsp,8*5 ; reserve stack for API use and make stack dqword aligned mov r9d,0 lea r8,[_caption] lea rdx,[_message] mov rcx,0 call [MessageBoxA] mov ecx,eax call [ExitProcess] section '.data' data readable writeable _caption db 'Win64 assembly program',0 _message db 'Hello World!',0 section '.idata' import data readable writeable dd 0,0,0,RVA kernel_name,RVA kernel_table dd 0,0,0,RVA user_name,RVA user_table dd 0,0,0,0,0 kernel_table: ExitProcess dq RVA _ExitProcess dq 0 user_table: MessageBoxA dq RVA _MessageBoxA dq 0 kernel_name db 'KERNEL32.DLL',0 user_name db 'USER32.DLL',0 _ExitProcess dw 0 db 'ExitProcess',0 _MessageBoxA dw 0 db 'MessageBoxA',0 |
|||
![]() |
|
Andy 28 Feb 2012, 09:35
Thank you, it works. I just have to study a little section .idata. All things there looks so complicated.
LE: I made it work in this way: Code: include "win64ax.inc" .data Caption db 'Win64 assembly program',0 Message db 'Hello World!',0 .code start: xor r9d,r9d lea r8,[Caption] lea rdx,[Message] xor rcx,rcx call [MessageBox] mov ecx,eax invoke ExitProcess,0 .end start My question now is: if I include win64ax what kind of APIs can I call? I am able to call any function from kernel32.dll or shell32.dll? |
|||
![]() |
|
questlima 27 Aug 2014, 14:40
i think you can call all the functions not sure i am new to FASM
kernel32.inc user32.inc gdi32.inc advapi32.inc comctl32.inc comdlg32.inc shell32.inc wsock32.inc http://code.google.com/p/vyne-compiler/source/browse/VyneCompiler/INCLUDE/WIN64AX.INC |
|||
![]() |
|
flatH 30 Sep 2014, 06:09
How can i write a text to console?
|
|||
![]() |
|
comrade 30 Sep 2014, 07:37
flatH wrote: How can i write a text to console? Code: code section: stdcall [GetStdHandle],STD_OUTPUT_HANDLE stdcall [WriteFile],eax,message,message.length,esp,0 data section: message db "Hello World!",13,10 .length = ($-message) |
|||
![]() |
|
flatH 30 Sep 2014, 07:42
I get the message
Quote: Error: illegal instruction. |
|||
![]() |
|
typedef 30 Sep 2014, 12:51
Don't copy "code section" and "data section".
That was there to tell you where you need to put the code. |
|||
![]() |
|
flatH 30 Sep 2014, 13:04
I get now:
Quote:
|
|||
![]() |
|
typedef 30 Sep 2014, 20:10
Code:
invoke GetStdHandle, STD_OUTPUT_HANDLE
or Code: push STD_OUTPUT_HANDLE call [GetStdHandle] |
|||
![]() |
|
flatH 01 Oct 2014, 05:33
Sorry to ask again
![]() Do you mean like this? Code: invoke GetStdHandle, STD_OUTPUT_HANDLE stdcall [WriteFile],eax,message,message.length,esp,0 message db "Hello World!",13,10 .length = ($-message) I then get: Quote:
if i mussonderstood your answer, i am sorry. Assembler is completely different to me then any other language i learned so far. |
|||
![]() |
|
comrade 01 Oct 2014, 07:50
Start by copying an existing sample and modifying it.
|
|||
![]() |
|
flatH 02 Oct 2014, 05:42
It's kinda hard to find a sample for x64 and console (no message box)...
|
|||
![]() |
|
comrade 02 Oct 2014, 08:34
You were already given a pointer to samples under FASM\SAMPLES\WIN64 on another thread you started.
|
|||
![]() |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.