What do I have to change from 32 bits to 64?

Started by xassiz, January 31, 2011, 02:36:25 PM

Previous topic - Next topic

xassiz

Hello, I'm new in ASM.

A friend recommended me MASM and JWasm with GoLinker.

I use Windows 7 64 bits.

I made correctly the Win64_2.asm from JWasm\Samples, but I started learning with a tutorial and it teaches but for 32 bits.

My code is:

.MODEL SMALL
.CODE
Mycode:
MOV AX,@DATA
MOV DS,AX
MOV DX,Offset Texto
MOV AH,4C00H
INT 21H
.DATA
Texto DB "yehehe$"
.STACK
END Mycode

What do I have to change for 64 bits?

Thanks!

PD: Sorry by my english, I'm from spain ::)

PD2: I think is because the bits, the error was:
Quoteyehe.asm(7) : Error A2050: Operands must be the same size: 1 - 2
yehe.asm: 12 lines, 1 passes, 15 ms, 0 warnings, 1 errors

qWord

your code is 16Bit DOS code.
My suggestion is to start with 32Bit Assembler using masm32 package - it's an all in one solution and there is a lot of code available. As long as you have programming skills with some other programming language (e.g. c/c++) it shouldn't be a problem to step in.

qWord
FPU in a trice: SmplMath
It's that simple!

dedndave

qWord is right

but the error is here
MOV AH,4C00H

you are trying to MOV a word value into a byte register
replace that line with
MOV AX,4C00H

also - if you want to see the results...
MOV DX,Offset Texto
MOV AH,9
INT 21H
MOV AX,4C00H
INT 21H

xassiz

Quote from: qWord on January 31, 2011, 02:59:47 PM
your code is 16Bit DOS code.
My suggestion is to start with 32Bit Assembler using masm32 package - it's an all in one solution and there is a lot of code available. As long as you have programming skills with some other programming language (e.g. c/c++) it shouldn't be a problem to step in.

qWord
I program in C/C++, Perl, Python, PHP, Bash/Batch.. but I would like try something new, and ASM can teach me a lot of things.

My friend recommended me JWasm because MASM32 isn't free, and GoLink because he wasn't sure that the Jwasm's linker runs in x86.

Quote from: dedndave on January 31, 2011, 03:16:30 PM
but the error is here
MOV AH,4C00H

you are trying to MOV a word value into a byte register
replace that line with
MOV AX,4C00H
I changed that, and runs like 32 bits:
jwasm code.asm
It makes code.obj, but I do:
GoLink code.obj
and the output is:
Error!
A source file is in OMF format which is not supported (code.obj)
Output file not made


I try like 64 bits:
jwasm -win64 code.asm
and..

code.asm(1) : Warning A4097: Multiple .MODEL directives, .MODEL ignored
code.asm(6) : Error A2050: Operands must be the same size: 2 - 8
code.asm: 12 lines, 2 passes, 0 ms, 1 warnings, 1 errors


And another doubt, over x64 I'll can run 32 bits codes correctly with the sofware I have?


Thanks!

qWord

build this as console app:
option casemap:none
option frame:auto ; see documentation

includelib kernel32.lib
includelib msvcrt.lib

;UNICODE EQU 1 ; lets use unicode
_WIN64 EQU 1
include Windows.inc ; japheth's wininc - http://www.japheth.de/

;/* define some CRT functions */
printf proto :ptr BYTE,:VARARG
_getch proto

.code
main proc

.data
sz db "Hello World",0
.code

invoke printf,ADDR sz
invoke _getch

invoke ExitProcess,0

main endp
end main
FPU in a trice: SmplMath
It's that simple!


dedndave

install the masm32 package
masm is free, but you can't use it to write code for non-windows OS's
JwAsm is unrestricted - you may use it however you like
but - masm is still a good place to get your feet wet



qWord

you must download and install the windows SDK - it contains the needed libraries. MASM32 supplies only 32Bit libraries, that wont work for 64Bit.
FPU in a trice: SmplMath
It's that simple!

xassiz

Quote from: qWord on February 01, 2011, 02:50:57 PM
you must download and install the windows SDK - it contains the needed libraries. MASM32 supplies only 32Bit libraries, that wont work for 64Bit.
Ok thanks, I have just downloaded the windows SDK libraries.. but now, how can I assemble?
Quotetest.asm(9) : Error A2089: Cannot open include file 'Windows.inc'
test.asm(25) : Error A2161: INVOKE requires prototype for procedure
test.asm: 28 lines, 1 passes, 0 ms, 0 warnings, 2 errors

japheth

Quote from: xassiz on February 01, 2011, 04:17:45 PM
Ok thanks, I have just downloaded the windows SDK libraries.. but now, how can I assemble?

The fact that you tried to assemble 16-bit DOS code as a 64-bit Windows application tells me that you are not ready to play with 64-bit assembly.

The best hint I can give is: try 32-bit Windows first - and read the docs!

xassiz

Quote from: japheth on February 01, 2011, 04:37:22 PM
Quote from: xassiz on February 01, 2011, 04:17:45 PM
Ok thanks, I have just downloaded the windows SDK libraries.. but now, how can I assemble?
The best hint I can give is: try 32-bit Windows first - and read the docs!
You say that I program for 32-bit or over 32-bit windows?

qWord

Quote from: xassiz on January 31, 2011, 05:25:22 PMI program in C/C++
how long are you programming? - your previous posts let me assume, that you are an greenhorn ... in this case assembler it is not a good choice.
FPU in a trice: SmplMath
It's that simple!

xassiz

Quote from: qWord on February 01, 2011, 06:02:27 PM
Quote from: xassiz on January 31, 2011, 05:25:22 PMI program in C/C++
how long are you programming? - your previous posts let me assume, that you are an greenhorn ... in this case assembler it is not a good choice.
2 years in C >.<

I want ASM, I'm a "greenhorn" in ASM :dazzled: