Hello.
Does anyone see a problem with the following code:


.386
.model flat, stdcall
.data
db msg "Cleared.",0
db times 510-($-$$), 0
dw 0AA55h
.code
start:
mov ah, 00h
mov al, 03h
int 10h

xor ax, ax
mov al, 2eh
out 70h, al
xor al, al
out 71h, al

xor ax, ax
mov ah, 13h
mov al, 01h
mov bh, 00h
mov cx, 23h
mov bl, 07h
mov bp, msg
add bp, 07c00h
int 10h
end start

I get hte error at mov bp,msg
thx
Posted on 2005-01-22 22:46:14 by ReVeR
msg has type BYTE, so MASM complains to load it into a 16bit register

Most likely you wanted to do


mov bp, offset msg
Posted on 2005-01-23 00:46:07 by japheth
the error is that you're trying to do 16bit code on win32 flat model. i see you're trying to do a bootloader of some sort, do .model tiny. and the signature+padding's got to be at the END of the bootloader
Posted on 2005-01-23 01:37:12 by Drocon
hey, any ideas what the next erro means:
error LNK2001: unresolved external symbol _WinMainCRTStartup
I used the offset for the msg, that was right but now i get this.....
waht is it?
Posted on 2005-01-23 09:37:40 by ReVeR
Are you using a 16bit linker?
Posted on 2005-01-23 10:15:02 by roticv
make shore the WinMain proc is declared with a proto,
or the WinMain proto exists and the proc it self doesnt exists....
Posted on 2005-01-23 10:30:33 by GR33d
linker.....i am using a linker that comes with masm 32 so....it is a 32 bit linker....do i have to use a 16 bit linker...i don';t think there is any 16 bit code there...since i chaned mov bp, offset msg. And why do i need to have a win main...can't i jsut run my program without a winmain?
here is the updated code:
format PE GUI 4.0

entry start
include 'C:\IDE\FASM\INCLUDE\win32a.inc'
section '.data' data readable writeable
msg db "Cleared",0
;times 510-($-$$) db 0
times db 510-($-$$), 0
dw 0AA55h
section '.code' code readable executable
start:
mov ah, 00h
mov al, 03h
int 10h

xor ax, ax
mov al, 2eh
out 70h, al
xor al, al
out 71h, al

xor ax, ax
mov ah, 13h
mov al, 01h
mov bh, 00h
mov cx, 23h
mov bl, 07h
mov bp, msg
add bp, 07c00h
int 10h
Posted on 2005-01-23 11:11:53 by ReVeR

i don';t think there is any 16 bit code there

The use of interrupts and port I/O is *very* much 16bit DOS code - this won't work at all in a win32 program. Yes, you will need a 16-bit linker if you want to write this kind of code.

Or, you could get FASM - http://www.flatassembler.net
Posted on 2005-01-23 11:14:16 by f0dder
Do check the EULA that comes with masm32. Or if you are not using masm32, whatever EULA that comes with your ml.exe.

PS: I think FASM is better for this kind of thing. Personally I do not like Nasm.
Posted on 2005-01-24 06:14:36 by roticv
i got fasm now...
but syntaxies is so diffrent here and all...
anyways i get error on the first line...any ideas on what it should be, i looked at the other source code but it is the same......


format PE GUI 4.0
entry start
include 'C:\IDE\FASM\INCLUDE\win32a.inc'
section '.data' data readable writeable
msg db "Cleared",0
;times 510-($-$$) db 0
times db 510-($-$$), 0
dw 0AA55h
section '.code' code readable executable
start:
mov ah, 00h
mov al, 03h
int 10h

xor ax, ax
mov al, 2eh
out 70h, al
xor al, al
out 71h, al

xor ax, ax
mov ah, 13h
mov al, 01h
mov bh, 00h
mov cx, 23h
mov bl, 07h
mov bp, msg
add bp, 07c00h
int 10h

sThx in advnace
Posted on 2005-02-01 18:03:13 by ReVeR
That is wrong


format binary
use16
org 7c00h
jmp start
nop
start:
mov ah, 00h
mov al, 03h
int 10h

xor ax, ax
mov al, 2eh
out 70h, al
xor al, al
out 71h, al

xor ax, ax
mov ah, 13h
mov al, 01h
mov bh, 00h
mov cx, 23h
mov bl, 07h
mov bp, msg
int 10h
hlt
msg db "Cleared",0
times 510+7c00h-$ db 0
db 55h,0aah ; boot signature

PS: I have not tested it out yet, but I think it should work
Posted on 2005-02-02 06:42:23 by roticv
okey, i compiled the program and the compilation is fine, i don't get any errors, nothing like htat, but i get a .bin file....am i not suppoused to get a .exe, .com or even .bat file?
how do i finish the linking of this file to get an executable?
Posted on 2005-02-02 16:51:17 by ReVeR
hey, nm my previous post, i got it.
My question is, ar ther any tutorials articles, etc on the bootleader and 16 bit programming of the above kind?
thx
Posted on 2005-02-04 23:00:36 by ReVeR
What kind are you searching for? Most tutorials are for nasm, but I guess it would not be too difficult to convert them into fasm.

There are some useful links here:
http://www.asmcommunity.net/board/viewtopic.php?t=13474
Posted on 2005-02-05 19:09:23 by roticv