Page 1 of 1
ASSEMBLY set up
Posted: Sun Mar 31, 2013 10:06 am
by hazique35
Im having so much trouble trying to start using this. Im trying to use flat assembler. I know that DosBox can be used, but this is an emulator, and therfore I will not be working directly with the hardware. (correct me if i am wrong on this) So how the heck can I start coding with ASSEMBLY if I cant even run it? Im using Windows 7, on a 64 bit operating system. Ive looked this up all day but I cant find much. What do I have to do?
Thanks
Re: ASSEMBLY
Posted: Sun Mar 31, 2013 10:20 am
by trinopoty
Assemble to a flat binary.
Copy it to the first sector of floppy.
Run it in Bochs/Virtualbox/VMware.
Re: ASSEMBLY set up
Posted: Sun Mar 31, 2013 10:39 am
by hazique35
Thanks for the answer. I dont know how to assemble to a flat binary... Here is the code that I a trying to run:
Code: Select all
ORG 100h
USE16
mov ah, 09
mov dx, msg
int 21h
mov ah, 01
int 21h
mov ah, 4ch
int 21h
msg db 'Hello World', 0ah, '$'
Do I need to add any extra code? Sorry, Ive only started using ASSEMBLY now, Im more familiar with C++.
Re: ASSEMBLY set up
Posted: Sun Mar 31, 2013 11:03 am
by bluemoon
Look like you're call DOS services, and you mentioned DOSBOX, so I suppose you're learning assembly with DOS environment.
In that case, DOS only support loading .com or .exe (MZ) executable format file.
To generate an .com you may hand code an .ORG 100h to skip the PSP (as you already do), assemble as flat binary(you did it too) and rename it with .com extension.
You code looks well, so what's the problem, what do you expect to see and what's the observables?
Re: ASSEMBLY set up
Posted: Sun Mar 31, 2013 11:16 am
by iansjack
As you are using 64-bit Windows you have no choice but to use an emulator. 16-bit programs are not supported under Windows 64-bit.
Re: ASSEMBLY set up
Posted: Sun Mar 31, 2013 11:18 am
by hazique35
So, sense I have to use the emulator, I wont actually be able to do anything with the hardware or can I still do some stuff?
Re: ASSEMBLY set up
Posted: Sun Mar 31, 2013 12:12 pm
by Antti
I just wrote you a sample code (NASM + LINK). This is a native 64-bit windows program. I am sure that this helps you to get started.
Code: Select all
Build instructions:
nasm.exe -o hello.obj -f win64 hello.asm
link.exe /OUT:hello.exe /ENTRY:start /SUBSYSTEM:WINDOWS hello.obj kernel32.lib user32.lib
Code: Select all
; Sample 64-bit Windows program
global start
extern MessageBoxW
extern ExitProcess
section .text
start:
sub rsp, 32+8 ; Alignment + shadow parameters
mov rcx, 0 ; hwnd = NULL
lea rdx, [rel helloMessage] ; lpText = helloMessage
lea r8, [rel helloCaption] ; lpCaption = helloCaption
mov r9, 0 ; uType = MB_OK
call MessageBoxW
mov rcx, 0 ; uExitCode = 0
call ExitProcess
.end: jmp .end
section .data
helloCaption: dw __utf16__ 'http://forum.osdev.org', 0x0000
helloMessage: dw __utf16__ 'Hello 64-bit Windows world!', 0x0000
Re: ASSEMBLY set up
Posted: Sun Mar 31, 2013 12:17 pm
by hazique35
thanks!