Студопедия

КАТЕГОРИИ:

АвтомобилиАстрономияБиологияГеографияДом и садДругие языкиДругоеИнформатикаИсторияКультураЛитератураЛогикаМатематикаМедицинаМеталлургияМеханикаОбразованиеОхрана трудаПедагогикаПолитикаПравоПсихологияРелигияРиторикаСоциологияСпортСтроительствоТехнологияТуризмФизикаФилософияФинансыХимияЧерчениеЭкологияЭкономикаЭлектроника



Mov DS,AX ;on the data segment




Читайте также:
  1. Segment 3
  2. Segment 3
  3. Segment 4
  4. Segment 7

At first the meaning of the name data (i.e. an address of the segment with a name data) is loaded by an instruction mov into the ALU register AX and then it is removed into the segment register DS. Such double-steps operation is necessary due to the specificity of the microprocessor architecture (it doesn’t able to place the necessary address directly from the memory into the segment register, that is why we have to use AX register as a “trans-shipping point”.

The destination of the given program is the output on the screen a text string “The program is working!”, which has been described in the data segment. In order to execute this operation, we use not one program of the operational system. The fact is that there are no instructions of input/output in the assembly; for these purposes a long sequence of instructions of the processor is used. This sequence of instructions could be placed in the considered program, but DOS includes a large quantity of standard programs, which execute frequently used operations, including input/output ones, that is why it is rather useful to apply to DOS for help in such situations.

In order to apply to DOS , it is necessary to load in the ALU register AH the number of the required function and in some other registers – the initial data for the execution of this function, and after that it is necessary to execute an instruction int 21h, which will hand over administration to DOS. The output on a screen may be executed by function with a number 09h, which demands a presence of the full address of the string to be outputted in registers DS:DX. The register DS has been initiated already, so there is to place the offset of the string into the register DX. This offset of the string to be outputted is associated with the name msg. There is no necessity to point out the length of the outputted string, because the DOS function 09h outputs on the screen the whole string starting from the address, which has been pointed out, and completing by symbol of dollar “$”, which has been providently included in the text.

What is to be done for the program’s completion? In reality a completion of a program is a rather difficult sequence of operations, which includes, in particular, clearing out the memory, which has been occupied by the executed program, call the system program, which will output on the screen the request of DOS and will wait another instructions. All these operations executes the DOS function with a number 4Ch. This function supposes, that there is a code of our program completion in the AL register, which it will hand over to DOS. If the program has completed successfully, then the code of completion must be equal to 0, that is why in the program in one sentence, namely mov AX,4C00h both registers (AH and AL) are loaded simultaneously (in AH the number 4Ch is loaded, and in AL the code 0 is loaded). After it we call DOS by already familiar function int 21h.



 

7.What is to be done for the program’s completion (in the assembly)? How is it recommendable to program input/output operations in assembly?

 

8.Why is it necessary to use a stack in a program? Describe the stack organization. What size should have a stack?

The stack segment must be defined with the STACKdirective following the SEGMENTdirective. This definition tells DOS which segment address to load into the SSregister.



The size of the stack segment is dictated by the definition of some data within the segment. Enough stack space must be defined to cover any possible need the program may have, plus the needs of DOS and any interrupt service routines (including loaded TSR’s) that may be active while the program is running. If enough space is not defined, there may be a stack crash, which will terminate the program and possibly crash the machine. Decide how much stack space is realistically needed, and allocate twice as much. Use the DB and DUP directives to allocate space.

The segments are order independent. They may be placed in any order without changing the way the segments work together, nor the way the assembler treats them. However, it is recommended the convention of defining the stack segment first, the data segment second, and the code segment third be used.

1.Variables and space for the stack must be allocated during assembly. The DB, DW, DD, and DUPdirectives are the most common means to do this.

 

 

2. DWallocates word sized (16 bit) variables typically, to contain register sized values. DDallocates double word sized (32 bit) variables, typically for full addresses containing both segment and offset.

 

These definitions have a form as such:


Дата добавления: 2015-09-14; просмотров: 5; Нарушение авторских прав







lektsii.com - Лекции.Ком - 2014-2021 год. (0.012 сек.) Все материалы представленные на сайте исключительно с целью ознакомления читателями и не преследуют коммерческих целей или нарушение авторских прав
Главная страница Случайная страница Контакты