News:

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

Hello and a question

Started by Rogare, September 30, 2009, 08:45:56 PM

Previous topic - Next topic

dedndave

here is a new batch file for you
i have written it to use Link16.exe in the D:\masm32\bin folder...

Rogare


dedndave

ok
this isn't hard - lol
what happens when you run that batch file ?
there should be some kind of output
you should change your current directory to the same location as the file you want to assemble
let's say it's MyFolder.....
then run:
D:\MyFolder>a16 goto

it should tell you that the file (goto.asm) is not found
or - it can't find ML.EXE
or - it can't find LINK16.EXE

Rogare

GOTO.ASM is in D:\ root.
Here is output:
D:\>a16 goto
Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997.  All rights reserved.

Assembling: goto.asm

Microsoft (R) Segmented Executable Linker  Version 5.60.339 Dec  5 1994
Copyright (C) Microsoft Corp 1984-1993.  All rights reserved.

Volume in drive D has no label.
Volume Serial Number is 00B2-CF12

Directory of D:\

09/30/2009  10:32 PM               200 GOTO.ASM
10/01/2009  05:09 PM               539 goto.exe
               2 File(s)            739 bytes
               0 Dir(s)  58,187,956,224 bytes free

D:\>goto

D:\>

Including a test run for goto.exe - which does nothing.

dedndave

ok
something is not right - lol
the exe is 539 bytes - that is the correct size
let's try a different asm file....

while you are doing that, i will look at this goto.exe file

dedndave

ok
i found the problem
lol
you are going to laugh
"goto" is a DOS batch command
it is "internal" - i.e. it is inside command.com - and takes precedence over externals
so, when you type "goto" at the prompt it executes the batch command - not the exe
i just renamed the exe to gotoA.exe and it worked

Rogare

WOW.
Thanks so much for everything!

dedndave

my pleasure
that was a different kind of problem than what we are used to seeing in here
usually, there is something wrong with their program or their setup
it was a nice change of pace - lol

Rogare

Well, I started playing and I wrote this piece of code:
.MODEL SMALL
.STACK 100h
.DATA
x DB ?
.CODE

initProg PROC
mov ax,@DATA
mov ds,ax
ret
initProg ENDP

endProg PROC
mov ax,4C00h
int 21h
ret
endProg ENDP

printDot PROC
mov ah,02h
mov dl,2Ah
int 21h
ret
printDot ENDP

printC PROC
pop dx
mov ah,02h
int 21h
ret
printC ENDP

readC PROC
mov ah,01h
int 21h
xor ah,ah
push ax
ret
readC ENDP

start:
call initProg
mov ah,02h
mov dl,2Ah
int 21h
mov ah,08h
int 21h
;until here
call printDot
mov dx,0048h
call printC
mov dx,0069h
call printC
call readC
call endProg
END start

It starts well, prints the asterisk and reads a character. That's all (doesn't get to the procedures).
Ideas why?

FORTRANS

Hi,

   There Is a POP DX In printC that destroys the return address.
Also a PUSH AX in readC that will put an incorrect address on the
stack.

Steve

Rogare

Oh. You are correct. Thanks!

Rogare

I got another 2 question, this time there aren't problems :wink.
1. I heard there are registers like EAX and EBX - can they be used with 16-bit ASM?
2. At what times should I use which register? I know that CX is used for loops and CBW works only for AX - is there a complete lists of what registers are used for each thing, and for general uses what I should use?

Edit: Another question :)
In my book it says there are 5 sizes of variables: DB,DW,DD,DQ,DT. I know what to do with the first, as they match the registers (al is DB and ax is DW). What is the use of the last three?

Rogare

Thanks!
About the last part.
I know what they ARE, the question is how can they be used? I can't move them into registers (which are too small) and all the instructions require using registers. For example I got a DQ and I want to add 7 to its value - how would that be done? Stuff like that.

FORTRANS

Hi,

   The 32-bit registers can be used  in 16-bit mode, but you
have to be careful in setting up your code segment.  I usually
assemble using two blocks of code, but there are ways to
set things up all at once.  Check the MASM documentation.

   Here is a sample showing code using ECX and CX in sequence.


    2849 0DCA  66| 59                C          POP     ECX             ;
    2850 0DCC  66| 83 E9 01          C          SUB     ECX,1           ;
    2851 0DD0  77 86                 C          JA      RB_1b
    2852                             C
♀◘Microsoft (R) Macro Assembler Version 5.00                  10/1/9Color


    2853 0DD2  8B 0E C87A R          C          MOV     CX,[Padding]
    2854 0DD6  E3 05                 C          JCXZ    RB_3b


Steve N.

Rogare

#29
I am afraid I can't read that code :)
Could you scroll and see how I work (few posts higher)?
What do you mean by 2 blocks of code and "to set things up"?
P.S.: For curiosity - what is the code you posted? Output of something? Different assembler's syntax?

Edit: Another question:
When should I use a macro and when should I use a procedure? I know the difference, but could you give examples where one of the options is better than the other?