I'm studying computer engineering at a university and I have been doing C/C++ for about a year and now I'm learning assembly for intel based computers, but I'm having difficulty getting anything started. I'm not sure what to install I keep hearing that I need MASM or TASM, but when I install both I can't get anything to run or work. I thought I got it one time, but there was an error. Will the assembler tell me if there is a compiler error such as when writing C in borland? Also is there an assembler that comes with Borland C++ or Visual Studio 6 enterprise? Thanks in advance
Posted on 2001-05-17 08:14:00 by Jaszbo
Inprise (formerly Borland) made TASM, and was sold as a separate package to C++. They stopped support for TASM, and (as far as I am aware) no longer intend on developing it further. Again as far as I am aware, it is not bundled with their C++ compiler (it wasn't with C Builder 3 at least). MASM is the Microsoft Assembler, and is also not in the Visual C++ package (the C compiler does cope with inline assembly, but its not great). Unlike Borland (and unlike Microsoft :P ) they do give it away free (in the DDK), and so it can be used in the MASM32 package that Hutch provides. It is this MASM32 pack that most of us here use. This is because MASM is still supported by MS, and continues being developed. So I would suggest you download MASM32 from Hutch's site! http://www.pbq.com.au/home/hutch/default.htm Q) Will the assembler warn you of errors? A) Yes and no! There are certain things that an assembler (MASM & TASM are both compilers/assemblers as they also contain high level constructs such as IF-ELSE) will warn you about undefined variables etc. However certain problems will come at link time, and others will not show up until your CPU melts itself (only joking :D ). Because assembly is much lower level, there are plenty more ways in which to make your computer go horribly wrong! There is also less checking at "compile" time. The emphasis is most definitely on the programmer to ensure things are correct, but in a good way! What I suggest you do: 1) Get MASM32 from Hutch's site (see link above) 2) Get Icz's tutorials from http://win32asm.cjb.net 3) Mess around with those tutorials, change things etc. 4) Ask questions here about what you don't understand / broke! Mirno
Posted on 2001-05-17 08:45:00 by Mirno
I want to say thank you so very much for helping me, I downloaded the masm32 with the link you sent me and the program seems to run better than the others I tried, and I went here to download some tutorials to help me, but I wasn't sure which ones I should download since there are so many from this site http://win32asm.cjb.net I think I might know most of the first part of the tutorial with anything that has to do with base convesion and boolean algebra and I've been working for a pc shop for 2 years now so the hardware parts aren't a problem either. Here is a link to the lab that I must do for my class which I would like to get started on the first one which is just a basic hello world http://pegasus.cc.ucf.edu/~fgonzale/eel3801/labmanual.pdf Thank you so very much in advance
Posted on 2001-05-17 16:32:00 by Jaszbo
The URL you posted shows that your class is teaching DOS based assembly, and uses TASM. Of course this doesn't prohibit you from doing Win32 assembly as well, but it will be different! Windows uses functions in the API to provide us (the programmers) with "system level" interaction (disk reads & writes etc. It also provides lots of other things too). DOS however uses interupts ("int nn"), there are plenty of docs around the web describing the DOS interupts (try looking for Ralph Browns interupt list). The second difference is that Win32 is (as the name sugests) written using 32bit code, DOS is 16bit and so is limited to 16bit registers. There is of course one final point to make, most people here use MASM (from the MASM32 package), not TASM. There are syntactic differences. They both use the same opcodes (for the most part, I'm not sure if TASM has MMX, 3D-Now, SSE, or SSE2, but all the general ones should be the same). However both MASM and TASM have their own quirks, and syntax. There are people on the board who are fluent in TASM, so they will be able to help with problems, but be aware that your course, and this board (again for the most part) use different assemblers. What you learn in one area will still be applicable (to some extent) to the other, but DOS & Win32 are different! If you still want to learn Win32 assembly, then (I've just remembered DOH!) the basic package is included in MASM32 in "x:\masm32\ICZTUTES". These deal with everything you need to know to get started. Mirno
Posted on 2001-05-18 06:04:00 by Mirno
Just a minor "correction" to Mirno's post. You can use 32 bit registers and instructions in DOS mode, if you use the .386 (or higher) directive. However, you are still limited to the segmented memory model, and DOS functions still use the 16 bit registers to pass parameters. :)
Posted on 2001-05-18 07:23:00 by S/390
Ok, since the masm32 is different than the one I'm supposed to use TASM, can I still use masm32? The book for the class gave me a free copy of TASM and MASM, but I'm not getting it to work and masm32 seems to be easier to use. I opened this asm file into qeditor.exe title Hello World Program (hello.asm) ; This program displays "Hello, world!" dosseg .model small .stack 100h .code main proc mov ax,@data mov ds,ax mov ax,0900h mov dx,offset msg int 21h mov ax,4C00h int 21h main endp .data msg db 'Hello World!',0Ah,0Dh,'$' end main Then I clicked on build all and this is the dos error that comes on the screen Microsoft (R) Macro Assembler Version 6.14.8444 Copyright (C) Microsoft Corp 1981-1997. All rights reserved. Assembling: D:\School\eel3801\program.asm D:\School\eel3801\program.asm(4) : warning A4015: directive ignored with /coff switch D:\School\eel3801\program.asm(9) : error A2006: undefined symbol : DGROUP D:\School\eel3801\program.asm(19) : warning A4023: with /coff switch, leading u nderscore required for start address : main _ Assembly Error Press any key to continue . . . Any help is appreciated.
Posted on 2001-05-18 08:12:00 by Jaszbo
The MASM32 package is designed to assemble and link Windows 32bit applications, as such it compiles the code to COFF (Common Object File Format) object files. This is done via the /coff switch in the command line (masm32 executes a batch file, these can be found in \masm32\bin\), so you will want to assemble code without this command line switch. Secondly, you will need to get a different version of link.exe, as the one provided in MASM32 is a COFF linker, you need an OMF linker to link DOS programs. There is a copy of the DOS linker on Iczelion's site in the downloads section. As for any further advice, I am afraid I will be unable to help (having never created a DOS app in my life). Sorry. Mirno
Posted on 2001-05-18 09:36:00 by Mirno
Ok I downloaded the link and placed it in the bin directory double clicked on it and it asked if I wanted to replace the existing one, I clicked yes. Now I opened the qeditor and there is still an error. So I'm not sure what to do next since everything is greek to me. Also since everybody here does the 32bit assembly is the 16bit useless except for educational reasons? Also do the majority of people who write assembly do it for cracks? Just that that is what most topics seem about more or less
Posted on 2001-05-18 09:50:00 by Jaszbo
16 bit is dead, it died when windows 95 came out. Other than as a learning exercise, assembly in DOS is pretty much dead. You could program 32bit stuff in DOS, but you're still programming for DOS! Microsoft are trying to get us away from Win 9x (which arguably still is a DOS based OS but thats something else entirely!). Most of the topics here are about cracking? Any topic here deemed soley to be about cracking is locked, and further discussion is impossible! Assembly has in recent time got an association with cracking, this is purely because you need to know it in order to crack. However you can do a whole lot more than just crack with it! You can write entire pieces of software in assembly (ask Bogdan, he's writing an entire game purely in assembly). Of the current page of topics, not one is purely cracking related. Mirno
Posted on 2001-05-18 11:12:00 by Mirno
Jaszbo, Assembly language programming for DOS is entirely different from Win32 ASM programming. Tools you need: ml.exe - Hutch's site (from masm32 package) link.exe - Iczelion's site (16-bit linker at download section) interrupt list - Both for DOS and BIOS - Do a search on the net. I am trying to give you some basic idea. CPU works in a segmented architecture using the following formula (Under DOS) in real mode, Effective address = Segment Address * 16 + Offset Address Also there are 6 memory models available to write programs namely tiny, small, compact, medium, large and huge. The difference between these are the available # of segments for data and code sections. Also you can create a .COM file or an .EXE (MS-DOS) file. COM file can have atmost maximum of 64K for both data and code. Using MASM, there are different styles of writing code for segment machanism. I am giving you one example/style of how to create .COM and .EXE files. Sample1 - EXE file ------------------ hello.asm listing

.Model Small

msg     DB      "Hello, World!", 0Ah, 0Dh, '$'



        Mov     ax, DGROUP	; DGROUP contains .data and .data?
        Mov     ds, ax		; segment value together

        Mov     ax, 0900h	; Service number to print string
        Mov     dx, Offset msg	; Pointer to string
        Int     21h		; Interrupt

        Mov     ax, 4c00h	; Service number to exit and retrun value
        Int     21h		; Interrupt

End     start

Compiler command: -----------------

ml /c hello.asm

Linker command: --------------

link hello,hello,,,,

You will get linker warning that you are not having a stack segment. Just ignore that. Sample2 - COM file ------------------ hello1.asm listing

.Model Tiny

        Org     100h		; Start image at 256


        Mov     ax, cs		; Since COM is 64K, all segments
        Mov     ds, ax		; point to code segment

        Mov     ax, 0900h	; Service number to print string
        Mov     dx, Offset msg	; Pointer to string
        Int     21h		; Interrupt

        Mov     ax, 4c00h	; Service number to exit
        Int     21h		; Interrupt

msg     DB      "Hello, World!", 0Ah, 0Dh, '$'

End     start

Compiler Command: -----------------

ml /c hello1.asm

Linker Command --------------

link /TINY hello1,hello1.com,,,,

If you are interested in doing DOS assembly either for fun or for your education, you will see having the following books handy. Assembly Language Programming for X86 by Peter Norton and John Socha - A must have to learn modular design in assembly for building a very large project. Develops a disk editor from scratch. Assebmly Language Programming by Richard Detmier - Good one covering all the instructions of X86 family and has lot of stuff for educational programs. I don't have ISBN number for these. These may be out of print also. Jones.
Posted on 2001-05-19 02:16:00 by sjhenry