News:

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

Using 16 bits on WIn7 64 bits

Started by milosjovac, January 29, 2011, 12:27:13 PM

Previous topic - Next topic

milosjovac

Hello, i have one question.

I started to programming in assembly fews weeks ago. 8086 assembly to be more precise. My system is win7X64, so i used http://www.emu8086.com/ to run my source code. But this emulator have a big fault - doesn't work with procedures, at last not like i know to use them. So I install this MASM32, in hope to continue with learning of procedures, but failure again, for this sample source code, i have errors in MASM32, but not in my old emulator.


name nizMinMax
data segment
    niz dw 12h, 13h, 14h, 11h, 10h, 9h, 0ffffh, 04h, 00h
    min dw ?
    max dw ?               
    broj db 9
data ends
code segment
    assume cs: code, ds: data
start:
    mov ax, data
    mov ds, ax
    lea si, niz
    xor bx, [si] ;ovo ce biti reg za smestanje min elem
    xor dx, [si] ;ovo ce biti reg za smestanje max elem
    mov cl, broj
    mov ch, 0
   
    petlja:
        mov ax, [si]
       
        cmp bx, ax       
        jna ax_je_veci
        mov bx, ax
       
        ax_je_veci:
        cmp dx, ax
        ja max_je_veci
        mov dx, ax
                 
        max_je_veci:
        add si, 2
    loop petlja
       
        mov min, bx
        mov max, dx                 
       
    mov ah, 4ch
    int 21h
code ends
end start
 

Is it problem in some MASM32 settings, or i don't using it on right way?
Thanks in advance.

jj2007

Hi Milos,
Welcome to the Forum :thumbu

Here is a complete "application" for Masm32:
include \masm32\include\masm32rt.inc

.data
AppName db "Masm32:", 0

.code
start: MsgBox 0, "Hello World", addr AppName, MB_OK
exit

end start

This is for testing if your settings are correct. It is 32 bit code. What you posted is 16 bit code - is there any good reason why you want to use 16 bits only?

P.S.: Here are some useful tips.

milosjovac

Thank you for fast answer jj2007! and thank you on welcome.

Yap, there is one reason for 16bit assembly - that is what professor expecting from me on exam :)

I tried your "Hello World" code, and it's work, so settings are OK.


Is there a chance to my 16-bits code work properly on MASM32?

jj2007

Here is an example for 16 bit code that works fine with ml.exe. However, you need the old 16 bit linker, link16.exe.

Quote.Model small   ; credits to DednDave
.Stack 512

.Data
MsgText   db "Hello 16-bit World", 13, 10, 10
   db "Hit any key to quit ...", 13, 10, "$"

.Code

_main proc FAR

; set the DS register to DGROUP (will fail with some Masm versions - use ml 6.15 or higher, or JWasm)
   mov ax, @DATA
   mov ds, ax

; display the message
   mov dx, offset MsgText
   mov ah, 9
   int 21h

; wait for a key
   mov ah, 0
   int 16h

; the DOS equivalent to ExitProcess
   mov ax, 4C00h
   int 21h

_main endp

end _main

milosjovac

Thank you a lot! Hope i will handle with this...  :wink

But still, is there any other solution for running 16-bit code on X64 system?   

jj2007

Quote from: milosjovac on January 29, 2011, 01:11:01 PM
But still, is there any other solution for running 16-bit code on X64 system?   

The Professional and Enterprise versions offer XP mode, but you'll have to download it. Convince your teacher that 16 bit code is obsolete... :bg

milosjovac

Hehe, i will try :) But he considered that is ground very important, so this is just a first part of the exam  :eek

Thank you on tips and time, i will install a virtual machine and XP. Probably best solution!  :cheekygreen:

dedndave

i guess they are running 16-bit code under 64-bit OS's by using DosBox or similar
by all means, if you can convince the instructor that it's time to move on....
16-bit code is all but dead - only used by us die-hard's that don't want what we know about it to go to waste   :P

i think if i had a newer system, i would try to make it dual-boot into XP so i could get away from 64-bit limitations, too

GregL


jj2007

Quote from: GregL on February 03, 2011, 04:51:32 AM
"XP Mode" is a free download.

So is anybody around who got XP mode running on Win7 Home?

BlackVortex


jj2007

Quote from: BlackVortex on February 24, 2011, 07:56:30 PM
I prefer Virtualbox.

http://www.virtualbox.org/

Supports many OSes, DOS, too.

They are remarkably silent on how to install the guest OS. I guess an OEM disk will not do the job. So where would you get a legal copy of Windows XP...?

BogdanOntanu

Quote from: jj2007 on February 24, 2011, 08:46:39 PM
Quote from: BlackVortex on February 24, 2011, 07:56:30 PM
I prefer Virtualbox.

http://www.virtualbox.org/

Supports many OSes, DOS, too.

They are remarkably silent on how to install the guest OS. I guess an OEM disk will not do the job. So where would you get a legal copy of Windows XP...?

You buy one Windows XP CD and license for your virtual Box in exactly the very same way you do for any "normal non virtual" computer.... as an alternative you could use an extra one if you have spare licenses left from older PC's...

One advantage of XP Mode on Win7 is that (I guess) you do not need another license BUT you "only" need to have Win7 Pro in order to legally use WinXP mode on Win7 (and Win7 Pro already costs more)

PS.
------
OEM CD should do the job and install like on every computer... BUT I think it is not exactly correct or legal to use it like this? ...

However if you use the mouse and your OEM is "tied" to "that" mouse :D :D :D it might be OK.
Anyway you need to have 2xOEM licenses and CD-s: one for your host OS and another for your guest OS.
Ambition is a lame excuse for the ones not brave enough to be lazy.
http://www.oby.ro

Rockoon

Win7/64's XP Mode, if I understand correctly, will not emulate hardware for 16-bit code execution. That is.. its not an emulator, but instead only provides the necessary functionality for OS-within-OS virtualization... your code is still natively run, but in isolation with translations for API calls and I/O.
When C++ compilers can be coerced to emit rcl and rcr, I *might* consider using one.