News:

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

NOOB question

Started by MASM, January 02, 2012, 03:05:57 PM

Previous topic - Next topic

MASM

Hello everyone!

I used to do some MASM in MS DOS days before I switched to 6502 assembler programming.

Now I would like to brush up my MASM skills.

Therefore, I wrote a little program to put a character into Video Memory in text mode.

Somehow MASM comes up with an error I don't quite understand.

here is my program (video ram starts at B0000H in text mode)

           .MODEL SMALL

            .DATA

VIDEO   EQU B0000H
           
            .CODE
           
            ORG 0100H
           
            MOV AL,41H
            MOV VIDEO,AL
       
            END

here is what MASM says:

A2006: undefined symbol B0000H in line MOVE VIDEO,AL

(I looked up absolute addressing in my ASM86 but it should work)

AND the linker complains about 'unresolved externals'

who can help me? ::)







Rockphorr

welcome in 16 bit thread and

VIDEO   EQU 0B0000H

B0000H is not digit, it is name
Strike while the iron is hot - Бей утюгом, пока он горячий

MASM

oops!

thanks a bunch!

But how does it come that 41H rather than 041H is allowed in MOV AL,41H ?

anyway, now MASM tells me error 2001: immediate operand not allowed in MOV VIDEO,AL


dedndave

under MASM, if it starts with a numeric (0-9), it is a number
if it starts with a non-numeric, it is a label
so - for hex vales that start with a-f, you have to preceed them with a 0

MASM

Thank you!

But what about my MOV 0B0000H,AL illegal immediate?

I have to admit according to syntax logic it would look like immediate, but how do I tell MASM I want absolute addressing?

i.e. moving AL into memory location 0B0000H ?


dedndave

the way you have it written, you are trying to move a byte to a 20-bit immediate - that just doesn't work

first of all, 0B000h is a segment - 16-bit intel processors use segmented addressing
0B0000h is 20 bits  :P

but - try this...

        mov     ax,0B000h
        mov     es,ax

        mov     al,55h
        mov     es:[0],al

dedndave

the 16-bit segment value is multiplied by 16, then added to the offset to obtain the "physical" address
(well - it was the physical address on an 8088   :wink )

we typically use the DS register to hold the local data segment and the ES register for the video (or other) segment

by the way - this is 16-bit code
we have a special sub-forum for 16-bit stuff, which is quickly becoming obsolete
before you pull out too many hairs figuring out segmented addressing, have a look at 32-bit code   :U

untio

Hi to all,
After look at the code written by MASM, I have a question about the memory model and the org directive.
I think that with:
.MODEL SMALL
and:
ORG 100H
The program will not work fine.
¿Am I right or do I not? and ¿why?.

dedndave

you are right - it should be
        .MODEL  Tiny
however - it may work, as long as you don't put any data in a data segment   :P
for a .COM program, the linker wants to see that all code fits in a single segment
so - if no data segment is ever created, Small model may work - never tried it   :bg

MASM

yep!

segmentation is a good point

so it seems can't express it directly without parting my address into segment : offset

I will try that es:[0] thing.

Also I will change my memory model to .TINY

Actually I was going to produce a MODEL SMALL program and then apply exe2bin, but now I found I can directly produce a .COM file with the .MODEL TINY directive

MASM

Oh, yes, sorry for posting in the wrong subforum  :lol


dedndave

no worries - one of the moderators will move it there for you

with 32-bit code, you can directly address 4 gb of space with a single register
with the 16-bit segment:offset, you can indirectly address 1 mb of space

MASM

it assembles all right now, however the linker complains about several issues now :dance:

warning LNK4078: 'multiple data sections found with different attributes'

(I dropped the .DATA expression from my code and have only section, namely a .CODE section, now)

so what is this warning about, anyway ?

next we have a LNK2001 error: unresolved external symbol _WinMainCRTStartup

AND a fatal LNK1120 error: unresolved external ::)


dedndave

you will want to use the 16-bit linker - Link16.exe

jj2007

Hi,
Welcome to the forum :thumbu
It is natural that you want to continue where you left assembler in the MS DOS days. However, 32-bit coding is a lot easier. Unless you have a really compelling argument to stay with 16-bit code...
include \masm32\include\masm32rt.inc

.code
start: print "Hello World", 13, 10
inkey "that was easy..."
exit

end start


Sorry if that doesn't have the old assembler look & feel - but you can use all combinations of "true" assembler and Masm. The first letter of your nick stands for MACRO, and that's what makes your life easier.
\masm32\macros\macros.asm is a good lecture in this respect :wink