Author Topic: trouble compiling very simple 16-bit asm code  (Read 3521 times)

ggmasm32

  • Member
  • **
  • Posts: 51
trouble compiling very simple 16-bit asm code
« on: September 15, 2015, 11:16:48 AM »
I have been away from asm x86 for years and returning back however I am having trouble building a very simple file, so I am wondering if someone can clear me out. Again, sorry if it has been posted before (spamming), if similar thread available, may be put it here.

First I installed masm32 from this site and used link16 to linkage which is always how I did before if I remember.

here is the code and batch build files:

Some how I am havin L1101 with following error during link:
From output i can see obj file is generated successfully but linker is having issue with L1101 invalid object module. Any help is appreciated! THanks.,

==LINK ERROR===

Z:\sw.dev>ml /c /Fm /Fl /coff asmfile.asm
Microsoft ® Macro Assembler Version 9.00.21022.08
Copyright © Microsoft Corporation. All rights reserved.

Assembling: asmfile.asm

Z:\sw.dev>link16 asmfile.obj, asmfile.exe,,,,

Microsoft ® Segmented Executable Linker Version 5.60.339 Dec 5 1994
Copyright © Microsoft Corp 1984-1993. All rights reserved.

asmfile.obj : fatal error L1101: invalid object module
Object file offset: 1 Record type: 4c

==ASM FILE===
.386
.model flat, stdcall

sta segment stack
db 100h dup(0)
sta ends

data segment
db 100h dup(0)
data ends
code segment
assume cs:code, ds:code,ss:sta

_start:
mov ax, 200h
; mov ax, code
; mov ds, ax
; mov dx, offset boker
; mov ah, 8
; int 21h
; mov ax, 4c00h
; int 21h
; boker db 'hello world!$'

code ends
end _start

==BATCH FILE===

del *.obj
del *.exe
del *.lst

ml /c /Fm /Fl /coff asmfile.asm
link16 asmfile.obj, asmfile.exe,,,,
   

ggmasm32

  • Member
  • **
  • Posts: 51
Re: trouble compiling very simple 16-bit asm code
« Reply #1 on: September 15, 2015, 11:43:59 AM »
OK update, got it working finally after googling quite a lot:
changed the batch file to following and 16-bit file is generated:

del *.obj
del *.exe
del *.lst

rem ml /c /coff /Cp /Fm /Fl  asmfile.asm
ml /omf /c /Zi /Zd asmfile.asm
link16 asmfile.obj, asmfile.exe,,,,


Now if I run fom DOS, it complains this version of windows can not run 16-bit code.
Hmm I thought Win7 still supports running 16-bit code?
Sounds like I need to downgrade to WinXP??

dedndave

  • Member
  • *****
  • Posts: 8734
  • Still using Abacus 2.0
    • DednDave
Re: trouble compiling very simple 16-bit asm code
« Reply #2 on: September 15, 2015, 12:57:48 PM »
64-bit versions of windows do not natively support 16-bit code
however, i think you can run it under DosBox

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 4813
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: trouble compiling very simple 16-bit asm code
« Reply #3 on: September 15, 2015, 04:36:14 PM »
You are correct, Win7 does not support 16 bit real mode code. You can either go back to XP or start writing 32 bit code, its far more powerful and a lot simpler in its addressing mode.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin:

ggmasm32

  • Member
  • **
  • Posts: 51
Re: trouble compiling very simple 16-bit asm code
« Reply #4 on: September 16, 2015, 04:03:24 AM »
i am contemplating about writing 32-bit code. But have no experience. I did a lot of stuff in 16-bit code. Is there any good tutorials to start from?
i am using ml 6.14 link16 and grdb for 16-bit code.
What should use for 32-bit code?
Is there any simple example available?

and declaring segment like:

code segment para public use16 way

i am still seeing grdb is misinterpreting the 66h as some meaningless instruction when I go through code. I remember it has to do something with 16-bit and 32-bit-ness. Looks like I need to read mode.

ggmasm32

  • Member
  • **
  • Posts: 51
Re: trouble compiling very simple 16-bit asm code
« Reply #5 on: September 16, 2015, 04:07:53 AM »
since this forum is quite responsive, i decided to spill my gut. this is the start of project that I have abandone in the middle few years back.

Basically I am looking for write a simple minix (unix-like) kernel using the mix of asm and c that was taught in my university a decade ago.
I hit a wall and abandoned when there is an issue transitioning to pmode with int enabled (basically i coud not build IDT so abandoned)
I am going to take a shot at it again. Because in rmode, i can at most load 2-3 process at a time and 1mb memory wraps around.
Final binary will be dd-d to FDD and boot like an MBR from sector 0.
The code will deal with IVT and also might use some of int21h, int16h, int10h mostly for stdio I/O. I hope 32-bit will not have limitation to do any of these.
THanks.,

rrr314159

  • Member
  • *****
  • Posts: 1381
Re: trouble compiling very simple 16-bit asm code
« Reply #6 on: September 16, 2015, 04:37:58 AM »
hi ggmasm32,

to get started with 32-bit u should download the masm32 package, see the "MASM32 downloads" link at the top of this page. Detailed instructions can be found at jj2007's page including a link to JWasm, which many of us use in place of MicroSoft's ml.exe. U can also get ml.exe from Visual Studio.

The instructions in green on jj2007's page can be skipped, they're about "MasmBasic" which is useful but not necessary. As for examples, tutorials etc there are plenty with the masm32 package.

The particular OS-type project you have, I know very little about, but others here can help.
I am NaN ;)

FORTRANS

  • Member
  • ****
  • Posts: 945
Re: trouble compiling very simple 16-bit asm code
« Reply #7 on: September 16, 2015, 06:36:32 AM »
Hi,

Basically I am looking for write a simple minix (unix-like) kernel using the mix of asm and c that was taught in my university a decade ago.

   You might want to read postings in the Usenet group

alt.os.development

Google Groups provides access to older posts.

   Or the wiki at:

OSDev - operating system development articles and forum
http://wiki.osdev.org/Main_Page

   Search the old forum for bootloaders in the 16-bit section.

HTH,

Steve N.
HTH,