Hey Folks. This is my first post here.
I am very much new to Assembly language and really want to learn it! I have done C language and Assembly has been introduced now in our syllabus (Computer Engineering second year :bg) In my college our teacher uses TASM to compile the code. But i am using windows 7 and have installed MASM..
We have to write instructions for the 8086 microprocessor and in our college much of the build and link process is done via command prompt. I am figuring out how to do the same in MASM.
Also i am using the book Microprocessors and Interfacing by Douglas V Hall. My first code that i want to run is as shown below.
; 8086 PROGRAM
;Abstract :This program multiplies the two 16 bit words in the memory
;The locations are called MULTIPLICAND and MULTIPLIER. The result
;is stored in the memory location called PRODUCT
;Registers :Uses CX, DS, AX, DX
;Ports :None Used
data_here segment
multiplicand dw 204ah ;first word here
multiplier dw 3b2ah ;second word here
product dw 2 dup (0) ;result of multiplication here
data_here ends
code_here segment
assume cs:code_here, ds:data_here
start: mov ax, data_here ;initializes the data register
mov ds, ax
mov ax, multiplicand ;get one word
mul multiplier ;multiply by second word
mov product, ax ;store low word of the result
mov product+2, dx ;store high word of the result
int 3 ;wait for command from user
code_here ends
end start
Any links or advice for the same would be really helpful.
Sorry if i made any mistake!! Thanks a lot!!
Cheers!!
Welcome neo1691;
if you are using masm v5 or v4, just type in prompt: "masm name.asm", and after "link name.obj".
if you are using masm32 from here, when you go link, use the older linker provided, type "ml /c /omf name.asm" and after "link16 name.obj".
I'm suposing you are debuging the generated program, because your example does not return command back again to ms-dos, or maybe some dyna-86L??(your example comes in that manual).
Tasm and Masm have a very close sintax, maybe 90% of same tapes. I do not have changed one line in your code and assembled fine under masm32 package.
You will receive one "warning" while linking your source, like "no stack segment", but in this specific case, ignore.
Or if you like, include one stack segment in your source code:
stack_here segment stack
db 100h dup(?)
stack_here ends
to your program return to ms-dos, include the lines below at end of you code,(remove/comment that "int 3" and put in that place the code below).
mov ax, 4C00h ;exit do dos
int 21h
Be in peace, and keep walking.
welcome to the forum :U
let me start by saying that 16-bit code isn't what you really want to learn
and - if you have a 64-bit OS, it won't run 16-bit code
i know some instructors are stuck on 16-bit, but see if you can convince him to try 32-bit code
if you succeed, you are sure for an A - lol
that having been said....
there are some shortcuts that may interest you
.MODEL Small
.DOSSEG ;DOS segment order
.STACK 1024
OPTION CaseMap:None ;case sensitive
;##########################################################################
.DATA
multiplicand dw 204ah ;first word here
multiplier dw 3b2ah ;second word here
;**************************************************************************
.DATA?
product dw 2 dup (?) ;result of multiplication here
;##########################################################################
.CODE
;**************************************************************************
_main PROC FAR
ASSUME DS:DGROUP
mov ax, @data ;initializes the data register
mov ds, ax
mov ax, multiplicand ;get one word
mul multiplier ;multiply by second word
mov product, ax ;store low word of the result
mov product+2, dx ;store high word of the result
int 3 ;wait for command from user
;------------------------------------------
;terminate program
mov ax,4C00h ;terminate, return = 0
int 21h ;DOS function call
_main ENDP
;##########################################################################
END _main
here is the SymDeb result...
C:\Masm32\Asm16>symdeb mul16.exe
Microsoft (R) Symbolic Debug Utility Version 4.00
Copyright (C) Microsoft Corp 1984, 1985. All rights reserved.
Processor is [80286]
-u 10 28
0EBF:0010 B8C10E MOV AX,0EC1
0EBF:0013 8ED8 MOV DS,AX
0EBF:0015 A10A00 MOV AX,[000A]
0EBF:0018 F7260C00 MUL Word Ptr [000C]
0EBF:001C A30E00 MOV [000E],AX
0EBF:001F 89161000 MOV [0010],DX
0EBF:0023 CC INT 3
0EBF:0024 B8004C MOV AX,4C00
0EBF:0027 CD21 INT 21
-r
AX=0000 BX=0000 CX=002E DX=0000 SP=0400 BP=0000 SI=0000 DI=0000
DS=0EAF ES=0EAF SS=0EC3 CS=0EBF IP=0010 NV UP EI PL NZ NA PO NC
0EBF:0010 B8C10E MOV AX,0EC1
-t
AX=0EC1 BX=0000 CX=002E DX=0000 SP=0400 BP=0000 SI=0000 DI=0000
DS=0EAF ES=0EAF SS=0EC3 CS=0EBF IP=0013 NV UP EI PL NZ NA PO NC
0EBF:0013 8ED8 MOV DS,AX
-t
AX=0EC1 BX=0000 CX=002E DX=0000 SP=0400 BP=0000 SI=0000 DI=0000
DS=0EC1 ES=0EAF SS=0EC3 CS=0EBF IP=0015 NV UP EI PL NZ NA PO NC
0EBF:0015 A10A00 MOV AX,[000A] DS:000A=204A
-t
AX=204A BX=0000 CX=002E DX=0000 SP=0400 BP=0000 SI=0000 DI=0000
DS=0EC1 ES=0EAF SS=0EC3 CS=0EBF IP=0018 NV UP EI PL NZ NA PO NC
0EBF:0018 F7260C00 MUL Word Ptr [000C] DS:000C=3B2A
-t
AX=5A24 BX=0000 CX=002E DX=0776 SP=0400 BP=0000 SI=0000 DI=0000
DS=0EC1 ES=0EAF SS=0EC3 CS=0EBF IP=001C OV UP EI PL NZ NA PE CY
0EBF:001C A30E00 MOV [000E],AX DS:000E=5A24
-t
AX=5A24 BX=0000 CX=002E DX=0776 SP=0400 BP=0000 SI=0000 DI=0000
DS=0EC1 ES=0EAF SS=0EC3 CS=0EBF IP=001F OV UP EI PL NZ NA PE CY
0EBF:001F 89161000 MOV [0010],DX DS:0010=0776
-t
AX=5A24 BX=0000 CX=002E DX=0776 SP=0400 BP=0000 SI=0000 DI=0000
DS=0EC1 ES=0EAF SS=0EC3 CS=0EBF IP=0023 OV UP EI PL NZ NA PE CY
0EBF:0023 CC INT 3
-d ds:a 11
0EC1:0000 4A 20 2A 3B 24 5A J *;$Z
0EC1:0010 76 07 v.
-
i have attached the program and a copy of SymDeb.exe
Quote from: dedndave on March 09, 2012, 08:50:36 PM
let me start by saying that 16-bit code isn't what you really want to learn
Dave, I know the Comp-Sci professor at the local college and he too teaches ASM based on TASM 16-bit.
I don't know if he's stuck on it, but, it's what the college has.
It's a licensing issue.
I don't think he would accept Masm code as a replacement.
He wants to be able to take the students code and assemble it on the school computer.
Quote
i know some instructors are stuck on 16-bit, but see if you can convince him to try 32-bit code
if you succeed, you are sure for an A - lol
Again, it's a licensing issue.
The college can only use what they have bought.
Horse poo, the teachers are just stuck in their old habits. There are plenty of free Assemblers without restrictions: FASM, GoASM, JWASM, NASM and others. I have seen many people turned off of Assembly because of 16 bit.
I couldn't agree more. There is some degree of truth to that.
1) the instructor doesn't want to learn something new,
2) the college can't afford to buy the licenses for the assemblers.
Also, for the same reasons, they are still teaching Visual Basic 6.
I modified the source a bit so it provides some indication of what it is doing, and so it will terminate properly:
; 8086 PROGRAM
;Abstract :This program multiplies the two 16 bit words in the memory
;The locations are called MULTIPLICAND and MULTIPLIER. The result
;is stored in the memory location called PRODUCT
;Registers :Uses CX, DS, AX, DX
;Ports :None Used
data_here segment
multiplicand dw 204ah ;first word here
multiplier dw 3b2ah ;second word here
product dw 2 dup (0) ;result of multiplication here
msg db "done",13,10,"$"
data_here ends
code_here segment
assume cs:code_here, ds:data_here
start: mov ax, data_here ;initializes the data register
mov ds, ax
mov ax, multiplicand ;get one word
mul multiplier ;multiply by second word
mov product, ax ;store low word of the result
mov product+2, dx ;store high word of the result
int 3 ;wait for command from user
mov dx, offset msg
mov ah, 9
int 21h
xor ah,ah
int 16h
mov ax, 4c00h
int 21h
code_here ends
end start
I can assemble it with ML 6.15 (no errors or warnings) and link with LINK 5.60.339 (no errors but a no-stack-segment warning) and the resulting 564-byte EXE runs OK. Or I can assemble it with Turbo Assembler 3.1 (no errors or warnings) and link with Turbo Link 5.1 (no errors but a no-stack warning) and the resulting 564-byte EXE runs OK.
QuoteAgain, it's a licensing issue.
The college can only use what they have bought.
Steve,
JwAsm - same syntax as Masm - no licensing problems :U
i also recommend Pelles C - lot's of good stuff - including a linker
Thanks a lot for all the replies.
I cannot ask my tutor to go to 32 bit microprocessor as our syllabus contains 16 bit 8086 interfacing (exam will be on 8086) so i have to learn it!! Our education system lags in such things, for C language we are still forced to use the turbo C compiler.
Anyway, i feel that masm32 instructions to link and compile are more confusing to me, i would try to install the other versions of masm as they have very similar linking procedures to tasm..
Again thanks a lot for your replies!! :U
Quote from: mineiro on March 09, 2012, 08:23:18 PM
Welcome neo1691;
if you are using masm32 from here, when you go link, use the older linker provided, type "ml /c /omf name.asm" and after "link16 name.obj".
I'm suposing you are debuging the generated program, because your example does not return command back again to ms-dos, or maybe some dyna-86L??(your example comes in that manual).
Did not get any link to masm v5 or v6. Anyways i had masm32 installed on my system. Its installed in C drive and the multiply.asm file is in other drive. I open the command prompt window in that drive (F:/) and type the command you gave, it gives error, 'ml is not recognised as an internal or external command'
and what do you mean by
Quotewhen you go link, use the older linker
..
Thanks
Quote from: neo1691 on March 10, 2012, 05:10:41 PM
...masm32 installed on my system. Its installed in C drive and the multiply.asm file is in other drive. I open the command prompt window in that drive (F:/) and type the command you gave, it gives error, 'ml is not recognised as an internal or external command'
Oh dear, and now you are stuck in an infinite loop? ::)
My 50$ advice: Copy the file from F: to C:\Masm32 and try again.
Quote
and what do you mean by Quotewhen you go link, use the older linker
..
Thanks
Go to C:\Masm32\bin and type dir link*.exe
(hint: take the oldest one; that makes it 100$ :green)
Quote from: jj2007 on March 10, 2012, 05:56:44 PM
Quote from: neo1691 on March 10, 2012, 05:10:41 PM
...masm32 installed on my system. Its installed in C drive and the multiply.asm file is in other drive. I open the command prompt window in that drive (F:/) and type the command you gave, it gives error, 'ml is not recognised as an internal or external command'
Oh dear, and now you are stuck in an infinite loop? ::)
My 50$ advice: Copy the file from F: to C:\Masm32 and try again.
Quote
and what do you mean by Quotewhen you go link, use the older linker
..
Thanks
Go to C:\Masm32\bin and type dir link*.exe
(hint: take the oldest one; that makes it 100$ :green)
here is your $100 :8)
C:\masm32\bin>dir link*.exe
Volume in drive C has no label.
Volume Serial Number is A075-3A80
Directory of C:\masm32\bin
03/19/1998 11:58 AM 462,899 link.exe
01/13/1995 09:40 AM 364,544 link16.exe
2 File(s) 827,443 bytes
0 Dir(s) 83,508,326,400 bytes free
C:\masm32\bin>
Thanks for the reply!! :clap:
Quote from: neo1691 on March 10, 2012, 06:04:50 PM
Thanks for the reply!! :clap:
Welcome to the Forum :thumbu
In case you are really, really determined to stick to 16-bit code, here is a tool that may help to build little apps (http://www.masm32.com/board/index.php?topic=17991.0). It's assembler even if it doesn't look like.
Quote from: jj2007 on March 10, 2012, 06:11:23 PM
Quote from: neo1691 on March 10, 2012, 06:04:50 PM
Thanks for the reply!! :clap:
Welcome to the Forum :thumbu
In case you are really, really determined to stick to 16-bit code, here is a tool that may help to build little apps (http://www.masm32.com/board/index.php?topic=17991.0). It's assembler even if it doesn't look like.
I dont want to stick to 16 bit offcourse, only want to learn 16 bit to get a basic knowledge of assembly!! The i will move on to 32 bit as soon as i get enough knowledge. Also i may build small fun devices using 16 bit, just for fun!! But for that i need an assembler.. :green
I will try the one that you gave!! Thanks again
Quote from: jj2007 on March 10, 2012, 05:56:44 PM
Quote from: neo1691 on March 10, 2012, 05:10:41 PM
...masm32 installed on my system. Its installed in C drive and the multiply.asm file is in other drive. I open the command prompt window in that drive (F:/) and type the command you gave, it gives error, 'ml is not recognised as an internal or external command'
Oh dear, and now you are stuck in an infinite loop? ::)
My 50$ advice: Copy the file from F: to C:\Masm32 and try again.
Tried this too.. It gives the same error again!! And i have not been able to run Masmbasic because there is no richmasm directory in it!! :(
neo - try this...
c:\masm32\bin\ml /c multiply.asm
c:\masm32\bin\Link16 multiply.obj
.MODEL Small
.DOSSEG ;DOS segment order
.STACK 1024
OPTION CaseMap:None ;case sensitive
;##########################################################################
.DATA
multiplicand dw 204Ah ;first word here
multiplier dw 3B2Ah ;second word here
;**************************************************************************
.DATA?
product dw 2 dup (?) ;result of multiplication here
;##########################################################################
.CODE
;**************************************************************************
_main PROC FAR
ASSUME DS:DGROUP
mov ax, @data ;initializes the data segment
mov ds, ax
mov ax, multiplicand ;get one word
mul multiplier ;multiply by second word
mov product, ax ;store low word of the result
mov product+2, dx ;store high word of the result
int 3 ;wait for command from user
;------------------------------------------
;terminate program
mov ax,4C00h ;terminate, return = 0
int 21h ;DOS function call
_main ENDP
;##########################################################################
END _main
Quote from: dedndave on March 10, 2012, 03:30:23 AM
JwAsm - same syntax as Masm - no licensing problems :U
i also recommend Pelles C - lot's of good stuff - including a linker
Yes, but neither Jwasm nor Pelles C have a printed manual/book that can be used as the class textbook.
I forgot to mention that.
They use one of the Turbo Asm books as the class textbook. (required reading).
Quote from: neo1691 on March 10, 2012, 04:18:09 AM
I cannot ask my tutor to go to 32 bit microprocessor as our syllabus contains 16 bit 8086 interfacing (exam will be on 8086) so i have to learn it!!
Our education system lags in such things, for C language we are still forced to use the turbo C compiler.
Yeh, out here they not only teach using VB-6, they also still teach C++ using VC++ 6.
Both with Wrox Press books as textbooks.
I wonder what Randall Hyde thinks on this matter. Isn't he associated with the University of California, at Riverside ?
well, Steve...
hate to belabor the point, but JwAsm uses the same syntax as Masm
that means that a book written for Masm will work if used with JwAsm
if you can get the intructor to install the masm32 package
then put JwAsm in there
then show him a simple windows GUI program
and perhaps even point him at Iczelion's tutorials so he sees that it isn't difficult
the idea isn't so much to make him switch to 32-bit mid-term - understandable if he doesn't want to do that
but, to make him consider the possibility for future classes
and start him looking for books that teach 32-bit code :U
as time goes on, more and more students are going to be using a 64-bit version of windows
they aren't going to be able to work with 16-bit code without a lot of messing around
Quote from: neo1691 on March 10, 2012, 05:10:41 PM
Did not get any link to masm v5 or v6. Anyways i had masm32 installed on my system. Its installed in C drive and the multiply.asm file is in other drive. I open the command prompt window in that drive (F:/) and type the command you gave, it gives error, 'ml is not recognised as an internal or external command'
Masm32 instalation, by default, put executables in "c:\masm32\bin", in this folder, have ml.exe, link.exe, link16.exe, ... . So you can copy your source code to that place that will work.
Or, if you like to work in your F: drive, in a separated folder, type "path=%path%;c:\masm32\bin"
Now, if you are inside drive F:\, or H:\, or Z:\, and type "ml" will work. This command append one more path to be searched by command prompt (environment) when you type something.
A bit offtopic, but type only "path" and hit <enter>. You will see many folders listed, separated by ";". You can see "c:\windows" listed? If yes, you can type "notepad" and hit <enter>. The environment know about notepad.exe because have searched inside all that folders and have found it.
F:\>ml
ml is not recognised as an internal or external command ...
F:\>path=%path%;c:\masm32\bin
F:\>ml
Microsoft (R) Macro Assembler Version 6.15.8803
Copyright (C) Microsoft Corp 1981-2000. All rights reserved.
usage: ML [ options ] filelist [ /link linkoptions]
Run "ML /help" or "ML /?" for more info
F:\>
You can append many folders in one time, like this:
path=%path%;c:\masm32\bin;C:\masm32;C:\masm32\include;C:\masm32\lib;;F:\util;G:\editors
Thanks a lot for all your replies. I will try that and report soon!!
Quote from: dedndave on March 10, 2012, 11:59:41 PM
neo - try this...
c:\masm32\bin\ml /c multiply.asm
c:\masm32\bin\Link16 multiply.obj
This is what i tried
C:\masm32\bin> ml /c multiply.asm
Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997. All rights reserved.
Assembling: multiply.asm
C:\masm32\bin> Link16 multiply.asm
Microsoft (R) Segmented Executable Linker Version 5.60.339 Dec 5 1994
Copyright (C) Microsoft Corp 1984-1993. All rights reserved.
Run File [multiply.exe]: Y
List File [nul.map]: Y
Libraries [.lib]: Y
Definitions File [nul.def]: Y
LINK : fatal error L1092: cannot open module-definition file - Y.def
C:\masm32\bin>
What should i do when it prompts for Run File [multiply.exe]:
(sorry if i am being silly :red )
Quote from: neo1691 on March 10, 2012, 10:56:48 PM
> Copy the file from F: to C:\Masm32 and try again.
Tried this too.. It gives the same error again!! And i have not been able to run Masmbasic because there is no richmasm directory in it!! :(
DosBasic does not require a RichMasm directory. I added a makeit.bat to DosBasic (http://www.masm32.com/board/index.php?topic=17991.0), for use with qEditor. The sample file assembles, links and executes fine.
Study that makeit.bat file - it contains everything you need for simple 16-bit apps.
Quote from: neo1691 on March 11, 2012, 07:11:45 AM
What should i do when it prompts for Run File
With the 16-bit linker, if you terminate the command line with a semicolon the linker will use the defaults for the remaining fields. So you can use this:
Link16 multiply.obj;
Quote from: neo1691 on March 11, 2012, 07:11:45 AM
Quote from: dedndave on March 10, 2012, 11:59:41 PM
neo - try this...
c:\masm32\bin\ml /c multiply.asm
c:\masm32\bin\Link16 multiply.obj
This is what i tried
C:\masm32\bin> ml /c multiply.asm
Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997. All rights reserved.
Assembling: multiply.asm
C:\masm32\bin> Link16 multiply.asm
Microsoft (R) Segmented Executable Linker Version 5.60.339 Dec 5 1994
Copyright (C) Microsoft Corp 1984-1993. All rights reserved.
Run File [multiply.exe]: Y
List File [nul.map]: Y
Libraries [.lib]: Y
Definitions File [nul.def]: Y
LINK : fatal error L1092: cannot open module-definition file - Y.def
C:\masm32\bin>
What should i do when it prompts for Run File [multiply.exe]:
(sorry if i am being silly :red )
you tried to link an ASM file :P
C:\masm32\bin> Link16 multiply.
asmC:\masm32\bin> Link16 multiply.
objmake a TXT file - once you have saved it, rename it to a BAT file...
@echo off
if "x%1"=="x" goto a16usage
if exist %1.asm goto a16asm
:a16usage
echo Usage: a16 asm16file
echo "asm16file" = asm16file.asm
goto batchexit
:a16asm
if exist %1.obj del %1.obj
c:\masm32\bin\ml /c %1.asm >c:\masm32\bin\asmbl.txt
if errorlevel 1 goto showtxt
if exist %1.exe del %1.exe
c:\masm32\bin\Link16 %1.obj; >>c:\masm32\bin\asmbl.txt
:showtxt
if exist %1.obj del %1.obj
type c:\masm32\bin\asmbl.txt
:batchexit
dir %1.* /o-d
i name mine "a16.bat" and locate it in the c:\masm32\bin folder
i also place that folder in the PATH environment variable
see this link for instructions...
http://www.masm32.com/board/index.php?topic=14154.msg112459#msg112459
then, all you need to do is this...
a16 multiply
Quote from: dedndave on March 11, 2012, 11:11:22 AM
Quote from: neo1691 on March 11, 2012, 07:11:45 AM
Quote from: dedndave on March 10, 2012, 11:59:41 PM
then, all you need to do is this...
a16 multiply
I did that!! Here is the output
C:\masm32\bin>a16 multiply
Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997. All rights reserved.
Assembling: multiply.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 C has no label.
Volume Serial Number is A075-3A80
Directory of C:\masm32\bin
03/12/2012 07:58 PM 558 multiply.exe
03/11/2012 12:37 PM 1,470 multiply.asm
2 File(s) 2,028 bytes
0 Dir(s) 83,456,884,736 bytes free
C:\masm32\bin>a16 multiply
Quote
:U
now, all you need to do is learn how to use Debug or SymDeb :P
the program has no output, so it is the most practical way of seeing what has happened
i prefer to use SymDeb, so....
SymDeb multiply.exe
once you have opened the executable in SymDeb, there are several commands (the SymDeb prompt is a hyphen)
the first command you want to learn is "?" - it gives you a list of all the commands :P
the most commonly used commands are "u", "t", "g", "r", "q", and the variations of "d" ("d", "db", "dw", "dq")
in this case, the "t" is a good choice - you can single step (trace) through and watch the registers change as each instruction is executed
C:\Masm32\Asm16>SymDeb multiply.exe
Microsoft (R) Symbolic Debug Utility Version 4.00
Copyright (C) Microsoft Corp 1984, 1985. All rights reserved.
Processor is [80286]
-?
A [<address>] - assemble M <range> <address> - move
BC[<bp>] - clear breakpoint(s) N <filename> [<filename>...] - name
BD[<bp>] - disable breakpoint(s) O <value> <byte> - output to port
BE[<bp>] - enable breakpoint(s) P [=<address>] [<value>] - program step
BL[<bp>] - list breakpoint(s) Q - quit
BP [bp] <address> - set breakpoint R [<reg>] [[=] <value>] - register
C <range> <address> - compare S <range> <list> - search
D[type][<range>] - dump memory S {-|&|+} - source level debugging
E[type] <address> [<list>] - enter T [=<address>] [<value>] - trace
F <range> <list> - fill U [<range>] - unassemble
G [=<address> [<address>...]] - go V [<range>] - view source lines
H <value> <value> - hexadd W [<address> [<drive><rec><rec>]] - write
I <value> - input from port X [?] <symbol> - examine symbols(s)
K [<value>] - stack trace XO<symbol> - open map/segment
L [<addr> [<drive><rec><rec>]] - load Z <symbol> <value>
? <expr> - display expression > } <device/file> - Redirect output
! [dos command] - shell escape < { <device/file> - Redirect input
. - display current source line = ~ <device/file> - Redirect both
\ - screen flip * <string> - comment
<expr> ops: + - * / : not seg off by wo dw poi port wport mod and xor or
<type> : Byte, Word, Doubleword, Asciz, Shortreal, Longreal, Tenbytereal
-t
AX=0EC5 BX=0000 CX=002E DX=0000 SP=0400 BP=0000 SI=0000 DI=0000
DS=0EB3 ES=0EB3 SS=0EC7 CS=0EC3 IP=0013 NV UP EI PL NZ NA PO NC
0EC3:0013 8ED8 MOV DS,AX
-t
AX=0EC5 BX=0000 CX=002E DX=0000 SP=0400 BP=0000 SI=0000 DI=0000
DS=0EC5 ES=0EB3 SS=0EC7 CS=0EC3 IP=0015 NV UP EI PL NZ NA PO NC
0EC3:0015 A10A00 MOV AX,[000A] DS:000A=204A
-t
AX=204A BX=0000 CX=002E DX=0000 SP=0400 BP=0000 SI=0000 DI=0000
DS=0EC5 ES=0EB3 SS=0EC7 CS=0EC3 IP=0018 NV UP EI PL NZ NA PO NC
0EC3:0018 F7260C00 MUL Word Ptr [000C] DS:000C=3B2A
-t
AX=5A24 BX=0000 CX=002E DX=0776 SP=0400 BP=0000 SI=0000 DI=0000
DS=0EC5 ES=0EB3 SS=0EC7 CS=0EC3 IP=001C OV UP EI PL NZ NA PE CY
0EC3:001C A30E00 MOV [000E],AX DS:000E=676F
-t
AX=5A24 BX=0000 CX=002E DX=0776 SP=0400 BP=0000 SI=0000 DI=0000
DS=0EC5 ES=0EB3 SS=0EC7 CS=0EC3 IP=001F OV UP EI PL NZ NA PE CY
0EC3:001F 89161000 MOV [0010],DX DS:0010=6172
-t
AX=5A24 BX=0000 CX=002E DX=0776 SP=0400 BP=0000 SI=0000 DI=0000
DS=0EC5 ES=0EB3 SS=0EC7 CS=0EC3 IP=0023 OV UP EI PL NZ NA PE CY
0EC3:0023 CC INT 3
-q
C:\Masm32\Asm16>
Quote from: dedndave on March 12, 2012, 02:46:18 PM
:U
now, all you need to do is learn how to use Debug or SymDeb :P
the program has no output, so it is the most practical way of seeing what has happened
i prefer to use SymDeb, so....
SymDeb multiply.exe
once you have opened the executable in SymDeb, there are several commands (the SymDeb prompt is a hyphen)
the first command you want to learn is "?" - it gives you a list of all the commands :P
the most commonly used commands are "u", "t", "g", "r", "q", and the variations of "d" ("d", "db", "dw", "dq")
in this case, the "t" is a good choice - you can single step (trace) through and watch the registers change as each instruction is executed
C:\Masm32\Asm16>SymDeb multiply.exe
Microsoft (R) Symbolic Debug Utility Version 4.00
Copyright (C) Microsoft Corp 1984, 1985. All rights reserved.
Processor is [80286]
-?
A [<address>] - assemble M <range> <address> - move
BC[<bp>] - clear breakpoint(s) N <filename> [<filename>...] - name
BD[<bp>] - disable breakpoint(s) O <value> <byte> - output to port
BE[<bp>] - enable breakpoint(s) P [=<address>] [<value>] - program step
BL[<bp>] - list breakpoint(s) Q - quit
BP [bp] <address> - set breakpoint R [<reg>] [[=] <value>] - register
C <range> <address> - compare S <range> <list> - search
D[type][<range>] - dump memory S {-|&|+} - source level debugging
E[type] <address> [<list>] - enter T [=<address>] [<value>] - trace
F <range> <list> - fill U [<range>] - unassemble
G [=<address> [<address>...]] - go V [<range>] - view source lines
H <value> <value> - hexadd W [<address> [<drive><rec><rec>]] - write
I <value> - input from port X [?] <symbol> - examine symbols(s)
K [<value>] - stack trace XO<symbol> - open map/segment
L [<addr> [<drive><rec><rec>]] - load Z <symbol> <value>
? <expr> - display expression > } <device/file> - Redirect output
! [dos command] - shell escape < { <device/file> - Redirect input
. - display current source line = ~ <device/file> - Redirect both
\ - screen flip * <string> - comment
<expr> ops: + - * / : not seg off by wo dw poi port wport mod and xor or
<type> : Byte, Word, Doubleword, Asciz, Shortreal, Longreal, Tenbytereal
-t
AX=0EC5 BX=0000 CX=002E DX=0000 SP=0400 BP=0000 SI=0000 DI=0000
DS=0EB3 ES=0EB3 SS=0EC7 CS=0EC3 IP=0013 NV UP EI PL NZ NA PO NC
0EC3:0013 8ED8 MOV DS,AX
-t
AX=0EC5 BX=0000 CX=002E DX=0000 SP=0400 BP=0000 SI=0000 DI=0000
DS=0EC5 ES=0EB3 SS=0EC7 CS=0EC3 IP=0015 NV UP EI PL NZ NA PO NC
0EC3:0015 A10A00 MOV AX,[000A] DS:000A=204A
-t
AX=204A BX=0000 CX=002E DX=0000 SP=0400 BP=0000 SI=0000 DI=0000
DS=0EC5 ES=0EB3 SS=0EC7 CS=0EC3 IP=0018 NV UP EI PL NZ NA PO NC
0EC3:0018 F7260C00 MUL Word Ptr [000C] DS:000C=3B2A
-t
AX=5A24 BX=0000 CX=002E DX=0776 SP=0400 BP=0000 SI=0000 DI=0000
DS=0EC5 ES=0EB3 SS=0EC7 CS=0EC3 IP=001C OV UP EI PL NZ NA PE CY
0EC3:001C A30E00 MOV [000E],AX DS:000E=676F
-t
AX=5A24 BX=0000 CX=002E DX=0776 SP=0400 BP=0000 SI=0000 DI=0000
DS=0EC5 ES=0EB3 SS=0EC7 CS=0EC3 IP=001F OV UP EI PL NZ NA PE CY
0EC3:001F 89161000 MOV [0010],DX DS:0010=6172
-t
AX=5A24 BX=0000 CX=002E DX=0776 SP=0400 BP=0000 SI=0000 DI=0000
DS=0EC5 ES=0EB3 SS=0EC7 CS=0EC3 IP=0023 OV UP EI PL NZ NA PE CY
0EC3:0023 CC INT 3
-q
C:\Masm32\Asm16>
Got it!! Thank you very much!!
:dazzled:
Damn still bad luck
C:\masm32\bin>Symdeb multiply.exe
'Symdeb' is not recognized as an internal or external command,
operable program or batch file.
C:\masm32\bin>
at the bottom of this post is an attachment...
http://www.masm32.com/board/index.php?topic=18481.msg156179#msg156179
extract the SymDeb.exe file and place it in the masm32\bin folder, then try again :U
Quote from: dedndave on March 13, 2012, 02:45:53 PM
at the bottom of this post is an attachment...
http://www.masm32.com/board/index.php?topic=18481.msg156179#msg156179
extract the SymDeb.exe file and place it in the masm32\bin folder, then try again :U
Got it.. I hope thats right..
C:\masm32\bin>SymDeb multiply.exe
Microsoft (R) Symbolic Debug Utility Version 4.00
Copyright (C) Microsoft Corp 1984, 1985. All rights reserved.
Processor is [80286]
-t
AX=1756 BX=0000 CX=002E DX=0000 SP=0400 BP=0000 SI=0000 DI=0000
DS=1744 ES=1744 SS=1758 CS=1754 IP=0013 NV UP EI PL NZ NA PO NC
1754:0013 8ED8 MOV DS,AX
-
Although its quite different from the tasm debugger!!
but still thanks everyone for the great support. I think i have come the right place to learn the assembly language!!
Cheers!!
SymDeb is a "souped up" version of Debug
as the name implies, it allows symbolic debugging - a feature i rarely use
the feature i do use is the ability to set breakpoints without using INT3
(actually, SymDeb inserts INT3, but does not show it)
look at the commands starting with "b"
Quote from: dedndave on March 13, 2012, 03:00:36 PM
SymDeb is a "souped up" version of Debug
as the name implies, it allows symbolic debugging - a feature i rarely use
the feature i do use is the ability to set breakpoints without using INT3
(actually, SymDeb inserts INT3, but does not show it)
look at the commands starting with "b"
Cool.. i am still trying to grasp the concepts of assembly!! Its getting difficult for me more and more.. anyways i will stick to it and will learn it!!!
Thanks!!
You are wasting your time and energy trying to learn by using code examples from the obsolete DOS 16 bits era.
I know that unfortunately the net (and old teachers) are full of 16 bits examples but this is an mistake :D
Make yourself a favor and move to learning in the Win 32 bits land at least. (and then move to 64 bits).
Otherwise you might not learn ASM and/or consider it vey hard to learn.
Quote from: BogdanOntanu on March 13, 2012, 04:25:47 PM
You are wasting your time and energy trying to learn by using code examples from the obsolete DOS 16 bits era.
I know that unfortunately the net (and old teachers) are full of 16 bits examples but this is an mistake :D
Make yourself a favor and move to learning in the Win 32 bits land at least. (and then move to 64 bits).
Otherwise you might not learn ASM and/or consider it vey hard to learn.
I agree with you 100 % but this time its not just the old teachers behind but its the whole university behind torturing us!! :'(
well - for 16-bit code, you have to learn a lot of stuff that doesn't apply in 32-bit world
in 32-bit code - you hardly ever mess with segment registers and the addressing mode rules are more relaxed
and - you get a bunch of new instructions :P
when writing 16-bit code, you find combinations to do the job
this can add up to a lot of wasted effort because there may be a single instruction to do it
Quote from: dedndave on March 13, 2012, 05:13:52 PM
well - for 16-bit code, you have to learn a lot of stuff that doesn't apply in 32-bit world
in 32-bit code - you hardly ever mess with segment registers and the addressing mode rules are more relaxed
and - you get a bunch of new instructions :P
Sad state out here!! ::)
Anyways i need to get on with it!!
Thanks again for the info!!
I agree that, given a choice, most students should bypass 16-bit code altogether. But running on a 32-bit processor, by using 32-bit registers you can eliminate many of the limitations of 16-bit indirect memory operands, and gain the ability to manipulate 32-bit values in a single instruction.