26278 total geeks with 3498 solutions
Recent challengers:
 Welcome, you are an anonymous user! [register] [login] Get a yourname@osix.net email address 

Articles

GEEK

User's box
Username:
Password:

Forgot password?
New account

Shoutbox
MaxMouse
It's Friday... That's good enough for me!
CodeX
non stop lolz here but thats soon to end thanks to uni, surely the rest of the world is going good?
stabat
how things are going guys? Here... boring...
CodeX
I must be going wrong on the password lengths then, as long as it was done on ECB
MaxMouse
lol... the key is in hex (MD5: of the string "doit" without the "'s) and is in lower case. Maybe i should have submitted this as a challenge!

Donate
Donate and help us fund new challenges
Donate!
Due Date: May 31
May Goal: $40.00
Gross: $0.00
Net Balance: $0.00
Left to go: $40.00
Contributors


News Feeds
The Register
Streaming music
works for us, say
US and UK indie
labels
Look behind you,
NetApp: Angry
investor is coming
for YOU
Last time CO2 was
this high, the
world was
underwater? NO,
actually
Boffins find "scary
radio
attack"*
against pacemakers
Pakistan signs up
for China"s GPS
rival
Intel releases
"Beacon Mountain"
Android-on-Atom dev
tool
US boffin builds
32-way Raspberry Pi
cluster
Massive EXPLOSION
visible to naked
eye SEEN ON MOON
Yahoo! Japan says
22 MEELLION User
IDs may have been
nabbed
Nintendo throws
flaming legal
barrel at YouTubing
fans
Slashdot
Music and Movies
Could Trigger
Mobile Malware
Ask Slashdot:
Wiring Home
Furniture?
Medical Firm Sues
IRS For 4th
Amendment Violation
In Records Seizure
Military Dolphins
Discover 1800s
Torpedo
Apple Mobile
Devices Cleared For
Use On US Military
Networks
Mice, Newts
Retrieved After a
Month Orbiting
Earth At 345 Miles
Up
IBM Takes System/z
To the Cloud With
COBOL Update
Google"s Nexus Q
Successor Hits the
FCC
Yahoo Board
Approves a $1.1B
Pricetag For Tumblr
Trade Group: US
Software Developer
Wages Fell 2% Last
Year
Article viewer

Writing machine code using debug



Written by:dimport
Published by:sefo
Published on:2003-06-21 07:19:46
Topic:Assembly
Search OSI about Assembly.More articles by dimport.
 viewed 14087 times send this article printer friendly

Digg this!
    Rate this article :
Debug is a little tool that comes with windows. Whilst its not as easy to use as 3rd party utilities of its nature, its still pretty cool, and free (knowledge of hexadecimal assumed).

Straight to business, open an ms dos prompt and type ‘debug’
The prompt should now be a simple’-’ from here you can issue debug commands.
First off we’re going to look at the registers, type ’r’ and press enter, the output i got was:

AX=0000 BX=0000 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000
DS=2422 ES=2422 SS=2422 CS=2422 IP=0100 NV UP EI PL NZ NA PO NC
2422:0100 C3 RET

AX, BX, CX and DX are registers, which at the moment are empty (we‘ll be manipulating these shortly).
SP is the stack pointer, IP is the instruction pointer which, as its name suggests points to the next instruction to be executed.
Obviously 0100 isnt a memory address so its coupled with the CS register, so the instruction pointer, when i did that dump, was pointing to the segment at 2422:0100.

As you can see on the last line, also displayed is the instruction there at the time, now for the aforementioned register manipulation, issue the following commands at the debug prompt:
r AX
4

Now type ‘r’ again to do another dump and the value of AX should change to reflect the value you just placed into it. (it should say AX=0004)
Repeat the process substituting AX for BX and 4 for, lets say, 2. Do another dump and you’ll see you have a value in the AX and BX registers. To add these two values together is going to be a bit trickier. First off we need to get the instruction into memory and then get the instruction pointer to point at it, issue the following commands at the debug prompt:

e 100 #selects the address 0100h
01 #places 01h at the above address
e 101 #selects the address 0101h
D8 #places D8h at the above address

Now do a dump, the last line should say:

2422:0100 01D8 ADD AX,BX

01D8 is the x86 machine code for adding the AX and BX registers (where mine says 2422, yours will probably be different), either way the next instruction to be performed is to add the values contained in the AX and BX registers (which remember you put values in earlier).
To execute this instruction type ‘t’ at the debug prompt. ‘t’ stands for trace, when you execute the instruction another dump is automatically performed to show you the results of the instruction:

AX=0006 BX=0002 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000
DS=2422 ES=2422 SS=2422 CS=2422 IP=0102 NV UP EI PL NZ NA PE NC
2422:0102 8AC3 MOV AL,BL

As you can see the value of the calculation is stored in AX, the original value remains in BX, the instruction pointer is now pointing at 0102h.

Executing this instruction would have unpredictable results so reset the pointer by typing ‘r IP’ at the debug prompt to reset the instruction pointer.
Now thst you know the basics, i'll quickly run through how to multiply.
The machine code for multiplying the AX and BX registers is F7E3, so:

e 100
F7
e 101
E3

See if you can figure out how to subtract and divide (you’ll have to find out the x86 machine code for the operation.

This article was originally written by pigsbig78

Did you like this article? There are hundreds more.

Comments:
tomalam
2009-12-26 17:01:06
Stop your search and take a look at this Web 2.0 Magazine style <a href="http://www.youjoomla.com/"> Joomla Templates </a> with beautiful typography, CSS3 font shadows , 4 colors styles , multiple layout options and demo fully loaded with ready to go content, JComments Joomla comment extension and many YouJoomla extensions pre-installed for faster start
tomalam
2009-12-26 17:01:52
Stop your search and take a look at this Web 2.0 Magazine style Joomla Templates with beautiful typography, CSS3 font shadows , 4 colors styles , multiple layout options and demo fully loaded with ready to go content, JComments Joomla comment extension and many YouJoomla extensions pre-installed for faster start
Anonymous
2009-12-31 10:45:49
hi
here is iqbal
Thank you for the nice article. I am very glad to find and read this type of article...........


<a href="http://www.vegastopdogs.com/"> NFL Football Picks </a>
Anonymous
2010-01-02 08:22:34
HI
I would like to thank you for the efforts you have made in writing this
article. I am hoping the same best work from you in the future as well……………………….
<a href="http://plexus-it.com/"> Microsoft Exchange Server </a>
Anonymous
2010-01-09 17:35:37
hi
Thinking of having your own website or you own domain names that are parked but bringing in very little revenue or have a website with little content not listed or indexed by any search engine?


http://www.flowmonitorinc.com/


wellgood
2010-02-06 00:22:31
Good post. I always try to understand this site and its all the post. I always like this post to learn and acquire something. Thanks.


<a href="http://pasangiklanmurah.com/"> kerja keras adalah energi kita </a>


Anonymous
2010-02-11 06:01:12
Nice post.I want to know about your all post.Your post is very wall.Thanks

<a href="http://www.carirumahdijual.com/"> rumah dijual </a>
ObatAsamUrat
2011-06-16 07:25:55
This specific blog site appears to be redeem a substantial ammount involving website visitors. How would you support it? It gives you a great particular person pose in items. I reckon that obtaining something helpful as well as large to present home elevators is a vital issue.
kaos distro
Anonymously add a comment: (or register here)
(registration is really fast and we send you no spam)
BB Code is enabled.
Captcha Number:


Blogs: (People who have posted blogs on this subject..)
jackier
jackier on Mon 13th Oct 10am
111
sefo
Sneak - encryption on Fri 17th Nov 12pm
I'm developing the win32 version of sneak: http://snarkles.net/scripts/sneak/sneak. php The ASM source code is available on cyberarmy svn (for members only - free) Check the forum for details: http://www.cyberarmy.net/forum/sneak/mes sages/295244.
sefo
Geek Toolbar on Mon 13th Nov 8am
This a very simple and small toolbar I wrote in my spare time. I use the same set of tools very often and I find it very annoying to look for them in the start menu, on the desktop or in explorer. http://www.osix.net/modules/folder/index .php?tid=134
sefo
BinScan and Alternate Data Stream on Thu 27th Jul 9am
BinScan I created this tool to quickly identify modifications in the PE, use of a TLS callback and Alternate Data Streams. -> Some modifications done in the PE structure of an executable can prevent debuggers or other tools to open the executable.
sefo
Wmf Creator on Wed 26th Jul 7am
Now that the blog is online, I'll be able to share two or three tools I wrote. The first one I'd like to share is WMF Creator. I already put a link in the comments of my article: Wmf Exploit but I thought it would look nicer here. This tool will tak

Test Yourself: (why not try testing your skill on this subject? Clicking the link will start the test.)
Reverse Engineering by Geek_Freek

A test to check your assembly and reversing skills.
Assembly Language - non compiler specific by TroPe

You can test your assembly knowledge by taking this test. It starts out relatively easy, but gets progressively hards very quickly! If you know assembly, or just want to see what you DONT know about assembly, this test is for you. A more advanced assembly


     
Your Ad Here
 
Copyright Open Source Institute, 2006