Pentium Assembly Language Programming using DOS Debugger
The first reason to work with assembler is that it provides the opportunity of knowing more the operation of your PC, which allows the development of software in a more consistent manner. The second reason is the total control of the PC which you can have with the use of the assembler. Another reason is that the assembly programs are quicker, smaller, and have larger capacities than ones created with other languages. Lastly, the assembler allows an ideal optimization in programs, be it on their size or on their execution.
Assembler language Basic concepts
CPU Registers
The 8086 CPU is 16 bit processor, which has 4 internal registers, each one of 16 bits. The first four, AX, BX, CX, and DX are general use registers and can also be used as 8 bit registers, if used in such a way it is necessary to refer to them for example as: AH and AL, which are the high and low bytes of the AX register. This nomenclature is also applicable to the BX, CX, and DX registers.
The registers known by their specific names:
AX Accumulator
BX Base register
CX Counting register
DX Data register
DS Data Segment register
ES Extra Segment register
SS Battery segment register
CS Code Segment register
BP Base Pointers register
SI Source Index register
DI Destiny Index register
SP Battery pointer register
IP Next Instruction Pointer register
F Flag register
Debug program
To create a program in assembler two options exist, the first one is to use the TASM or Turbo Assembler, of Borland, and the second one is to use the debugger - on this first section we will use this last one since it is found in any PC with the MS-DOS, which makes it available to any user who has access to a machine with these characteristics.
Debug can only create files with a .COM extension, and because of the characteristics of these kinds of programs they cannot be larger that 64 kb, and they also must start with displacement, offset, or 0100H memory direction inside the specific segment.
Debug provides a set of commands that lets you perform a number of useful operations:
A Assemble symbolic instructions into machine code
D Display the contents of an area of memory
E Enter data into memory, beginning at a specific location
G Run the executable program in memory
N Name a program
P Proceed, or execute a set of related instructions
Q Quit the debug program
R Display the contents of one or more registers
T Trace the contents of one instruction
U Unassembled machine code into symbolic code
W Write a program onto disk
It is possible to visualize the values of the internal registers of the CPU using the Debug program. To begin working with Debug, type the following prompt in your computer:
C:/>Debug [Enter]
On the next line a dash will appear, this is the indicator of Debug, at this moment the instructions of Debug can be introduced using the following command:
-r[Enter]
AX=0000 BX=0000 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000
DS=0D62 ES=0D62 SS=0D62 CS=0D62 IP=0100 NV EI PL NZ NA PO NC
0D62:0100 2E CS:
0D62:0101 803ED3DF00 CMP BYTE PTR [DFD3],00 CS:DFD3=03
All the contents of the internal registers of the CPU are displayed; an alternative of viewing them is to use the "r" command using as a parameter the name of the register whose value wants to be seen. For example:
-rbx
BX 0000
:
This instruction will only display the content of the BX register and the Debug indicator changes from "-" to ":"
When the prompt is like this, it is possible to change the value of the register which was seen by typing the new value and [Enter], or the old value can be left by pressing [Enter] without typing any other value.
Assembler structure
In assembly language code lines have two parts, the first one is the name of the instruction which is to be executed, and the second one are the parameters of the command. For example:
add ah bh
Here "add" is the command to be executed; in this case an addition, and "ah" as well as "bh" are the parameters.
For example:
mov al, 25
In the above example, we are using the instruction mov, it means move the value 25 to al register.
The name of the instructions in this language is made of two, three or four letters. These instructions are also called mnemonic names or operation codes, since they represent a function the processor will perform.
Sometimes instructions are used as follows:
add al,[170]
The brackets in the second parameter indicate to us that we are going to work with the content of the memory cell number 170 and not with the 170 value, this is known as direct addressing.
Creating basic assembler program
The first step is to initiate the Debug, this step only consists of typing debug[Enter] on the operative system prompt.
To assemble a program on the Debug, the "a" (assemble) command is used; when this command is used, the address where you want the assembling to begin can be given as a parameter, if the parameter is omitted the assembling will be initiated at the locality specified by CS:IP, usually 0100h, which is the locality where programs with .COM extension must be initiated. And it will be the place we will use since only Debug can create this specific type of programs.
Even though at this moment it is not necessary to give the "a" command a parameter, it is recommendable to do so to avoid problems once the CS:IP registers are used, therefore we type:
a 100[enter]
mov ax,0002[enter]
mov bx,0004[enter]
add ax,bx[enter]
nop[enter][enter]
What does the program do?, move the value 0002 to the ax register, move the value 0004 to the bx register, add the contents of the ax and bx registers, the instruction, no operation, to finish the program. In the debug program, after this is done, the screen will produce the following lines:
C:\>debug
-a 100
0D62:0100 mov ax,0002
0D62:0103 mov bx,0004
0D62:0106 add ax,bx
0D62:0108 nop
0D62:0109
Type the command "t" (trace), to execute each instruction of this program, example:
-t
AX=0002 BX=0000 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000
DS=0D62 ES=0D62 SS=0D62 CS=0D62 IP=0103 NV EI PL NZ NA PO NC
0D62:0103 BB0400 MOV BX,0004
You see that the value 2 moves to AX register. Type the command "t" (trace), again, and you see the second instruction is executed.
-t
AX=0002 BX=0004 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000
DS=0D62 ES=0D62 SS=0D62 CS=0D62 IP=0106 NV EI PL NZ NA PO NC
0D62:0106 01D8 ADD AX,BX
Type the command "t" (trace) to see the instruction add is executed, you will see the follow lines:
-t
AX=0006 BX=0004 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000
DS=0D62 ES=0D62 SS=0D62 CS=0D62 IP=0108 NV EI PL NZ NA PE NC
0D62:0108 90 NOP
The possibility that the registers contain different values exists, but AX and BX must be the same, since they are the ones we just modified. To exit Debug use the "q" (quit) command.
Storing and loading the programs
It would not seem practical to type an entire program each time it is needed, and to avoid this it is possible to store a program on the disk, with the enormous advantage that by being already assembled it will not be necessary to run Debug again to execute it.
The steps to save a program that it is already stored on memory are:
Obtain the length of the program subtracting the final address
from the initial address, naturally in hexadecimal system.
Give the program a name and extension.
Put the length of the program on the CX register and order Debug to write the program on the disk. By using as an example the following program, we will have a clearer idea
of how to take these steps:
When the program is finally assembled it would look like this:
0C1B:0100 mov ax,0002
0C1B:0103 mov bx,0004
0C1B:0106 add ax,bx
0C1B:0108 int 20
0C1B:010A
To obtain the length of a program the "h" command is used, since it will show us the addition and subtraction of two numbers in hexadecimal. To obtain the length of ours, we give it as parameters the value of our program's final address (10A), and the program's initial address (100). The first result the command shows us is the addition of the parameters and the second is the subtraction.
-h 10a 100
020a 000a
The "n" command allows us to name the program.
-n test.com
The "rcx" command allows us to change the content of the CX register to the value we obtained from the size of the file with "h", in this case 000a, since the result of the subtraction of the final address from the initial address.
-rcx
CX 0000
:000a
Lastly, the "w" command writes our program on the disk, indicating how many bytes it wrote.
-w
Writing 000A bytes
To save an already loaded file two steps are necessary:
Give the name of the file to be loaded.
Load it using the "l" (load) command.
To obtain the correct result of the following steps, it is necessary that the above program be already created.
Inside Debug we write the following:
-n test.com
-l
-u 100 109
0C3D:0100 B80200 MOV AX,0002
0C3D:0103 BB0400 MOV BX,0004
0C3D:0106 01D8 ADD AX,BX
0C3D:0108 CD20 INT 20
The last "u" command is used to verify that the program was loaded on memory. What it does is that it disassembles the code and shows it disassembled. The parameters indicate to Debug from where and to where to disassemble. Debug always loads the programs on memory on the address 100H, otherwise indicated.
Activity 1.1: Enter the following program instructions in assembly code at the offset memory location 100h by typing A 100 at the DEBUG program prompt then press Enter-key.
MOV AX, 2864 |
ADD AX, 3749 |
MOV BX, AX |
SUB BX, 2805 |
NOP |
Activity 1.2: Use DEBUG command U 100 to unassembled the instructions in Activity 1.1. What is the machine code corresponding to each assembly code instruction?
Assembly code | Machine Code |
MOV AX, 2864 | |
ADD AX, 3749 | |
MOV BX, AX | |
SUB BX, 2805 | |
NOP | |
Activity 1.3: How many bytes does it need to represent each instruction in binary?
Assembly code | Number of bytes |
MOV AX, 2864 | |
ADD AX, 3749 | |
MOV BX, AX | |
SUB BX, 2805 | |
NOP | |
Activity 1.4: What are the contents of CS, IP, AX, and BX? Use DEBUG command R to display these information?
Register | Content |
CS | |
IP | |
AX | |
BX | |
Activity 1.5: Predict the contents of the following registers after execution of each instruction: CS, IP, AX, and BX.
Register | MOV AX, 2864 | ADD AX, 3749 | MOV BX, AX | SUB BX, 2805 |
CS | | | | |
IP | | | | |
AX | | | | |
BX | | | | |
Debug Flag symbols
Status Flag | Set (1) Symbol | Clear (0) Symbol |
CF | CY(Carry) | NC(No carry) |
PF | PE (Even parity) | |
AF | AC(Auxiliary carry) | NA (No Auxiliary carry) |
ZF | ZR(zero) | NZ(No zero) |
SF | NG(negative) | PL (plus) |
OF | OV(Overflow) | NV(no overflow) |
Control Flags | | |
DF | DN(Down) | UP(up) |
IF | EI(Enable Interrupt) | DI(disable interrupt) |
Activity 1.6
a) Run the program given in by trace command given in Activity 1.1 and note the status of each flag for each instruction.
b) For each of the following instructions, give new destination contents and new setting of CF, SF, ZF , PE , and OF. Suppose that the flags are initially 0 in each part of this question.
i) ADD AX, BX AX=7FFFH and BX=0001H
ii) SUB AL, BL AL=01H, and BL=FFH
iii) DEC AL AL =00H
iv) ADD AL, BL AL=80H and BL=FFH
Working with Memory locations
Debugger’s “E” command can be used to change the content of a memory location. The “D n” command is used to display the content of memory location “n.” In assembly language, a memory location’s content can be accessed by specifying its address within square brackets. For example, following sequence of 80x86 assembly transfer the content of memory location 200 to 201:
Mov Al, [200]
MOV [201],AL
INT 20
The result of execution is shown below:
Note that locations 200 and 2001 now contain same value.
Activity 2.1
Write an assembly language program to add the 10 values saved in locations starting from address 200. Save the result in location 300.
Definitely consider that that you said. Your favourite justification appeared
ReplyDeleteto be at the web the simplest factor to bear in mind of. I
say to you, I definitely get irked while other folks
consider concerns that they just don't know about. You controlled to hit the nail upon the top as smartly as outlined out the whole thing with no need side-effects , folks can take a signal. Will likely be back to get more. Thanks
Also visit my homepage :: internet radio
Tennis balls, wiffle balls, ping pong balls,
ReplyDeleteand golf balls can also be used. If you want to enjoy the game thoroughly then you need to get on
board of a reliable online bingo site to get the maximum enjoyment
as well as benefit of the game. In our next article, we'll be tackling using SNES4i - Phone to do exactly that - play those old favorites, like Chono Trigger, Super Ghouls and Ghosts, or even Super Mario Bros 3.
My web blog; videos von youtube downloaden
When you're happy with your game, why not share it with the world. Hochbetten können außergewöhnlich ein Ort zum Spielen sein. This setup offer players a medium amount of flexibility over their hit or win line selection.
ReplyDeletemy web page ... fiestaonline.gamigo.com
my webpage :: spielespielen24.de
Few travellers on a Mashobra tour can resist
ReplyDeletethe temptation of seeking blessings at the Mahasu Devta Temple.
replica cartier earrings. One situation had me pose as bait
to draw the enemies out so my ally could dispatch them. With an average annual fee
of 10,000 pounds, representing between 25% - 36% of professional incomes this has
risen assiduously by 41% in the last five years. These applications are delivered with a lot more flexibility at a fraction of the cost compared to desktop applications. It is hard to believe that we are unable to provide the minimum required comfort to our old ones, destitute women and even orphans. Today, the scenario is entirely different. FIFA has stated that a player named as a goalkeeper can only play in goal and that this rule will be enforced. Today, the company has over 1. There is a rarely discussed addiction that can be as enslaving as drugs and as devastating to self-respect, self-confidence and healthy functioning as alcoholism.
Also visit my web page: dev.lefam.org
Also see my web page: sources
Knee braces are designed for a particular kind of knee injury or knee problem
ReplyDeletefirst and foremost, and then you should consider the sport
of skiing. Wenn du ein Mädchen ansprechen willst, um auch eine Antwort zu kriegen und eine Unterhaltung
anzufangen, dann musst du mit deiner Anschreib-Mail hervorstechen.
Inclusion of beans (navy beans, kidney beans, lima beans
and white beans) and legumes to the diet is one of the most effective way-outs to bauch weg extra pounds.
Also visit my blog ... Www.Ot.Ufc.Br
Moreover, over the internet there are 2 main versions of
ReplyDeletethis game that is the RA deluxe with 10 pay lines and the
classic RA with 9 pay lines. Hochbetten können außergewöhnlich ein Ort zum Spielen sein.
You can join the millions of people who play online bingo.
My web site ... africanamericansupersite.com
Also see my page: http://www.spielespielen24.de
My brother suggеѕtеԁ I might like
ReplyDeletethis web site. He was totally right. This publish truly mаde my day.
You can not belieѵе ѕimply hоw so muсh time Ι
haԁ spent fοr this іnformatіon!
Thanks!
Fеel fгee to surf to my web page: mouse click the next site
Usually, a brand new website takes about six months to one year to appear in the SERPs of Google, assuming the service provider is worth their salt.
ReplyDelete''. The tools include efficient internet marketing, proper usage of keywords, flawless content and creating
social media buttons. The main aim of SEO is to
get search engines positioning a certain website well in
results for specific keywords. Since Google organic rank can bring in thousands of potential customers, search engine position service firms have made a business of promising high positions in search engine results pages.
It would cut the marketing project to fit it into your budget.
Domain Authority is influenced by:. Second tool for power suite
is website auditor. The title is supposed to explain the
article, and the title is what your readers see when they search
for content. Most of the XML sitemap generators online are simple enough for
anyone to use. So, most move slowly when deciding on who
becomes the company's SEO. The growth management of small business can be accomplished with SEO as an integral part of your overall Internet marketing strategy. Moving your hosting to a nearby country such as Canada or an offshore Caribbean host may provide the same latency times, but reduce the risk of having your website brought down by a mistake. Here you will need an SEO agency such as Webfirm to try and run damage limitation. This was the beginning of the thought process for my new business. Why. Law firms face various challenges and have issues in remaining at the top in the market. However with passing time the complexity in this field has increased and performing an SEO task is not a simple thing to do. What is the magic formula. com is one of the premier portals on the World Wide Web which has been formulated with the intention of providing SEO Hosting options for webmasters around the world who seek a way to ensure that their websites reach the top ranks of all major search engines.
My weblog ... julez-blog.de
Eνerуone loveѕ іt ωheneveг
ReplyDeletepeοple come together and shаre views.
Great blog, keep it up!
Ηere is my wеblog - Online Radio
Hello Dear, aгe yοu genuinely ѵisitіng thіs web sitе οn a
ReplyDeleteregular basis, if so afterwaгd you will abѕolutеly obtain good know-how.
Here is my blog poѕt: http://www.diigo.com/user/waterhot37?domain=http
Also see my web site > click through the up coming page
Wіth dοzens of rаԁio aррs for i - Phone available in i - Tunes, thеre іѕ an aρp for eѵeгy cаtegoгy of music lover to love.
ReplyDeletePeгhaps the bеst thing to dο is keep
an eyе on the promοtional dealѕ аnd
be ready to pounce quicκly whеn а suіtable one сomeѕ up.
Even if you have a good tωo way radio, it iѕn't bad to have some kind of receive only radio to get information on.
Here is my blog videos von youtube downloaden
Tennis balls, wiffle balls, ping pong balls, and golf balls can also be used.
ReplyDeleteYou will eventually run into the Download Location menu with two options:
Wii System Menu and SD Card. The full version has no ads
and offers goal alerts for the leagues and teams of your choice.
Look at my homepage; radiosender
You can learn about those fundamental lessons by simply
ReplyDeleteplaying video games. Is someone you know who runs a
version of Windows out of space on their thumbdrive, with no more space
for homework or work assignments on them. So all you gaming maniacs, log
on to your internet connected by service provider like Verizon Fi - OS Internet and have a blast of a time.
My page just click the up coming website
You can also buy bundle deals, whiсh most гaԁio ѕtatіonѕ offer,
ReplyDeletetο ԁecreasе the oveгall ad cost.
Yet anothеr ωаy to construct а dеvicе
tο harnеss energy from radio waves іs using аn antеnna, cοnnected to a ѕerieѕ of dioԁes
and a сapacitoг bаnk that is eaгthed.
Aԁditionally, sοme new attributes mаke it evеn еаѕier to maκe
гadiο buttοns ԁο exасtly whаt you ωant them to do.
Ѕtop by my web site Read Much more
And then, you'll probably see that the battery's charge won't be as durable as before. However, it is still possible to insect the terminals and make sure there is no corrosion. Mobile computing is continuously getting better with best performance, smarter processors, light weight and handy designs, but as we all know, the main power of the mobile computing device (weather it is laptop, mobile, PDA or e-book reader) resides in it's battery
ReplyDeletecapacity.
Also visit my site - just click the next website page - labmundo.org
When the laptop division went to Lenovo, as in the T61, the design and appearance
ReplyDeletedeclined. Stored energy printers. Official Picture of
President Reagan by the Executive Office of the Presidency used under Public Domain.
As a rule of thumb, if an app has been successful in i -
OS or Android format, it is likely to also be found on Windows Marketplace.
An analysis this change will give us insight into the supposed benefits they entail.
This miniature machine generates a monthly power of
40 k - Wh and is 36 inches tall. Today, the scenario is
entirely different. We're now looking at life lately in entirely new ways. Do you want a top notch gaming PC that can play all the latest games at max or near max settings. We have witnessed this first hand in this business.
Also visit my web-site - catena.projectroom.jp
These five free basketball game apps for the i - Phone will surely
ReplyDeletehelp you get your game on. You will eventually run into
the Download Location menu with two options: Wii
System Menu and SD Card. Each child is given 30 seconds to race to the pile and make
as many matches as possible before time runs out.
Here is my website spiele spielen
If there is a change in the search engine algorithms, it is also up to the service provider to keep a watch on such activities.
ReplyDeleteSEO consulting takes the burden off your shoulders and lets you relax and do the work
you want to do while allowing the expertise of the SEO consultant to
work for you, and we all know the best way to run a business is with maximum results for minimum stress.
It would be optimum thought to select the local SEO service after checking the rank of
their website. This will not only help you find the best service provider but will help you build an idea about
the recent SEO market. Is professional search engine marketing the thing that you
need. Meta Name and Meta Description Tags are two
of the important ones. Since keyword analysis is needed for both SEO (search engine optimization) and SEM,
we often confuse using these terms. This is because there
is a stiff competition in this particular field and the market is flooded with lots of
firms that provide proficient SEO experts India services at the economical costs.
Moreover, some companies are not able to get the desired results and their techniques might
even have bad effects on the business's website. Most of the XML sitemap generators online are simple enough for anyone to use. Arrange the H1, H2 and H3 tags serially with proper hierarchy. If the comments are created for solely promotional purposes, they will probably get deleted. Now, if it takes you three years to referrer 3000 members which means that you receive US$3000 per month. An SEO strategy should combine a number of elements that work together to get results for you. These professionals follow ethical SEO strategy and effectively implement it that finally increases your website visibility. SEO companies may only offer this type of service. With most visitors noting the first 3-5 web links of the first page, further sustained SEO efforts bring the company web link to that web positioning high up as much as possible. SEO is becoming the most rewarding career nowadays. Such companies know the best about industry and market trends. November 2012.
My page - Linkpyramide
What Ӏ didn't know was how I would get all of what I wanted in just six hours. Internal or External Sound Mixer "All windows systems come with a internet sound mixer they all differ so you may need to review your manual or online sources to figure out how to enable or use it. Proffering multifarious benefits to the advertisers, it is a quintessential resort for companies big or small.
ReplyDeleteFeel free to surf to my site; just click the next website page
Please supplement charge before use when the battery has
ReplyDeletebeen kept for a long time. Their producers imagine this can make the user a lot more mindful in the
should change the batteries, lessening the prospect of the discover program failing through ability loss.
If a LED is used instead of a bulb, the connections will require a bit more attention.
Feel free to visit my homepage :: beingsbook.com/blogs/29396/71042/have-you-created-a-website-that
UgemiVarma Kenneth Shamburger https://wakelet.com/wake/36pTZ3zuar71zdleCR5gr
ReplyDeletesethobuni