News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Getting Started with Masm 32

Started by WayneSallee, May 22, 2005, 05:51:01 PM

Previous topic - Next topic

WayneSallee

I'm working on converting a 16 bit program to a 32 bit program. Fun fun :-) What role can the segment registers play. Can I use them freely as 16 registers, or is the use of them prohibited. Or what role do they play if any in 32 bit programing?

Wayne Sallee
Wayne@WayneSallee.com

hutch--

Wayne,

You don't use segment registers in 32 bit code as they are set to the same starting address for FLAT memory model. Count it as a blessing.  :toothy
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Mark Jones

Hello Wayne, welcome to the forum. :)

Please see this thread about the 16-bit registers: http://www.masmforum.com/simple/index.php?topic=1362.0

I found that information by using the little search box above.

That said, I would not recommend starting your 32-bit journey with such a complex task. Look at the Iczelion tutorials included with MASM32, that's probably your best way to get accustomed to this new style of coding.

Good luck and have fun.
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

GregL

Wayne,

Are you talking about the DOS-based IDE that came with MASM 6.1?. Wasn't it called 'Programmer's Workbench'? It's been more than a decade since I used it. There are IDEs for MASM that run on 32-bit Windows. The one that comes with MASM32 is QEdit, some others are WinAsm and RadAsm. Otherwise it's done from the command-line.

pbrennick

[Shameless Plug]Don't forget EasyCode.[/Shameless Plug]

Paul

Mark Jones

I was thinking the same thing Paul, but you beat me to it. :)
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

WayneSallee

.DATA

.CODE

.DATA

.CODE

.DATA

This is getting old. did not have to do it when programing in 16 bit. Is there a way around having to tell it every time that it's now data, or now code?

Also what's a good book to buy that would be best for me with my move from 16 bit to 32 bit, preferably one without a lot of higher code, but a rather pure assebly language code?

Wayne Sallee
Wayne@WayneSallee.com

hutch--

 :bg

Wayne,

Yes there is a way around it, write all of you data to the data section in one ".data" notation. The capacity to use,


.data
  somedata dd 0
.code


is there if you need to split up code and data.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

AeroASM


WayneSallee

Quote from: hutch-- on May 26, 2005, 04:21:00 AM
:bg


is there if you need to split up code and data.


I like putting the data with the subrotines that use it. That's my prefered way to organize it, and it was simple with masm16, but with masm32 I find that I have to insert .code, and .data.  So I thought I would check to see if there was a way to still do it without having to inset .code, and .data.

Is there some reasoning behind this that I don't understand? It seems so much simpler to mix the code with the data instead of having it segmented. Is there some reasoning behind this that I don't understand?

Wayne Sallee
Wayne@WayneSallee.com

QvasiModo

Hi all :)

Quote from: WayneSallee on May 26, 2005, 10:32:48 PM
Is there some reasoning behind this that I don't understand? It seems so much simpler to mix the code with the data instead of having it segmented. Is there some reasoning behind this that I don't understand?

The main reason is the fact that under modern OSs the code section is read-only.

Speed is another reason. For old processors it used to be all the same, but now mixing code and data is bad: it makes the processor waste bandwidth fetching data into the code cache, and invalid opcodes are slower to decode.

AeroASM

INside procedures you can use stack space for local variables like this:


MyProc proc arg1:DWORD,arg2:DWORD

LOCAL Var1:DWORD
LOCAL Var2:DWORD

...

ret

MyProc endp

WayneSallee

Still working on changing my code over to 32 bit.

I can't even get a PUSH   EBX to work. I don't get any errors on assembly, but when I run it, microsoft gives an error that it has to be shut down. I can put ret's before push statements, but if a push is read, it errors.

Is there some kind of stack preperation that I have to do that I didn't have to mess with on 16 bit?

Wayne Sallee
Wayne@WayneSallee.com

AeroASM

The only way that push ebx could fail at the OS level is if you mess up the stack pointer esp.

Please could you post the offending code?

WayneSallee

No microsoft does not have to shut down. Microsoft shuts down my program.

Now I found the problem. It's erroring on that fact that I ret without poping the stack to ballance it out. So it's the ret that is creating the error, not the push

I was using the ret to debug, and was actualy creating a bug.

Ok back to de work :-)

Wayne Sallee
Wayne@WayneSallee.com