New To masm and Assembly Language - Need Help

Started by flicka, June 21, 2005, 12:22:35 AM

Previous topic - Next topic

flicka

Hi everyone.

I'm actually just started taking a class in assembly language I have read the text book chapters and I have no idea how to create a program with masm. :green I want to LEARN and understand this so I can go through with class, homework and the exam.

I have MASM32 editor and checked out their demo programs. They are different from what I see in my class book.
This is the first exercise I tried to do following the example from my text book the present the programs as follow:

TITLE          A05ASM1             (EXE)   Program to move and multiply
CODESEG   SEGMENT   PARA 'code'
ASSUME   CS : codeseg, DS : codeseg, SS : codeseg, ES : codeseg
   ORG      100H      ; Start at end of PSP
BEGIN:   JMP      MAIN      ; Jump past data
;------------------------------------------------------------------------------------------------------
MAIN      PROC      NEAR
      MOV      AX, 40H   ; move 40H to AX
      SHL      AL, 1   ; shift A1 1 bit
      MOV      BL,1AH   ; move 1AH to BL
      MVL      BL   ; multiply AL by BL
      MOV      AX, 4C00H   ; end of procedure   

MAIN      ENDP
      END      MAIN

If I do this in MASM it's not working. I'm sure I'm missing a bunch of things.
If anyone can explain to me how a program in Masm should look I can then try to do this correctly. If I can only understand how to write and create 1 program.
PLEASE Don't give me the program done, teach me and explain to me how to get this done on my own...

Thanks for helping me get started with Assembly language.

hutch--

Hi Flicka,

The code you posted is 16 bit DOS code and it will not build in the MASM32 editor. What you need is the 16 bit Microsoft linker which you can get from the forum web site and you can use the version of ML.EXE that comes with MASM32 and between them you can build successful 16 bit DOS code.

We have a dedicated forum for 16 bit code and many of our members have a lot of experience with this old style code but when you are doing your course work, you must be willing to do your own work before others will help you.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

flicka

Hi Hutch!

Not a problem on doing my own work, That's actually what I want to be able to do. :U
I just want to understand what I should be doing and which tools I should be using  :U
I'm surprised about what you're saying, but trust me I don't doubt you one second, because my professor had said if we had it we could use Borland turbo debugger win32. So i automatically thaught we were doing 32.

Ok so I can download the 16 bit Microsoft linker and I should be able to do it.. I'll try that right away. I would have spent a week desperately trying to get this to work with MASM32 :lol

Thanks so much Hutch

flicka

Thanks Hutch for moving this to the right place!

Ok I have masm32 and I downloaded the linker for 16 bit but now don't how to get these working to write a program with them :eek :red

I really need help to understand how to get the software to work for 16-bit....

Mark Jones

Hi Flicka, here are a few hints.

1. Put X:\MASM32\BIN in your path if possible.
2. Open a command/console/dos prompt and type ML /?
3. Type LINK16 /? (or whatever you named the 16-bit linker executable.)
4. Study the makeit.bat file in the EXAMPLE9\SMALLWIN folder. It is for 32-bit code but shows the basic compilation process.
5. Experiment. :)
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

flicka

Ok Marc,
I'm going to try to figure this out with your hints  :U
I'll let you know how it goes.

Thanks.

hutch--

OK,

Here is a bare COM template with a batch file to build it. You must name the old 16 bit DOS linker to "link16.exe" and place it in the BIN directory of MASM32. Unzip this file into a directory on the SAME partition as you have MASM32 installed and run MAKE16.BAT to build the COM file.

The batch file has the minimum ML and linker commands to build a com file so you should have a look at it to see what the options are.

The file does a crude clear screen by changing the video mode.

Just to be a bit cheeky, here is how to write the same COM file in HEX.


; ---------------
; com file in HEX
; ---------------

:B4 00          ; mov ah, 00h
:B0 02          ; mov al, 2
:CD 10          ; int 10h
:B8 4C 00       ; mov ax, 004Ch
:CD 21          ; int 21h

; ---------------------------------------------------------------------------
; Select "Save HEX as Binary" option on the File menu to create this COM file
; ---------------------------------------------------------------------------

[attachment deleted by admin]
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

flicka

Hi!

Thanks Hutch!  :U
I just got home from work so I'll try this out tonight and I'll let you know as soon as I get this working and I understand everything  :green2
I do have another question for any of you: Do I have to creat a batch file for each program I create?

Thanks again to all of you. I think with the info I got from you I'll get the hang of this.

hutch--

If you are doing enough 16 bit code, its easy enough to create a general purpose batch file for each build type, COM, EXE etc ... and the different memory models for the EXE files but in the short term, get used to creating them for each project as you will get good at the assembler and linker options.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

flicka

Thanks! I think I've got MASM running now...

I do have another question; One of the exercises I have in my textbook asks us to use debug.
Could anyone explain to me how it works? what are the commands I nee to use? The textbook seems to assume we know Debug, but I don't  :red

Any information will be really appreciated.

Thanks!

hutch--

You actually need a debugger to do this. Ancient MASM came with Codeview but I doubt it will work on a modern box. Its not hard to find 32 bit debuggers but they probably will not work on 16 bit code.

Maybe one of the members can suggest what to use here as I admit I am years out of date writing 16 bit code.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

flicka

hutch  :toothy
I feel like we're learning some ancient dinausaur  :wink
It's very interesting to learn something new but I'll admit hard...
Thanks.

MichaelW

The attachment is a DEBUG tutorial.



[attachment deleted by admin]
eschew obfuscation

flicka

Thanks so much Michael  :U

I'll have a long night tonight working on ASM, MASM, TASM and Debug :wink

I have done a program when I run I get an .exe file but there is nothing, well just the DOS black screen. Would you guys be kind enough to check my program? I would think that I shoud obtain something like a number or a code?

Title test1 program (test1.exe) Move and multiply operations
;--------------------------------------------------------------
STACKSG    SEGMENT PARA STACK 'Stack'
   DW    32    DUP(0)
STACKSG ENDS
;--------------------------------------------------------------
DATASG      SEGMENT   PARA 'Data'
   FLDD   DW   40
   FLDE    DW   1AH
   FLDF    DW    ?
DATASG ENDS
;--------------------------------------------------------------
CODESG    SEGMENT    PARA   'Code'
MAIN    PROC      FAR
   ASSUME SS:STACKSG,DS:DATASG,CS:CODESG
   MOV AX,DATASG             ;Set address of data
   MOV DS,AX             ; segment in DS
   MOV AX,FLDD             ;Move 40H to AX
   SHL AX,1                             ;Shift AL 1 bit left
   MOV BL, 1AH             ;Move immediate value 1AH to BL
   MUL BL                                                                      ; Multiply AL by BL
   MOV AX,4C00H            ;End processing
   INT 21H
MAIN    ENDP               ;End of procedure
CODESG ENDS               ;End of segment
END    MAIN               ;End of program

Thanks Guys

MichaelW

The only error I see is that FLDD is initialized to 40d instead of 40h as implied in one of the comments. You are getting a blank screen because your code is not generating any output. To display the product of the multiply operation you will need to convert it to an ASCII string and then display the string.

eschew obfuscation