Студопедия

КАТЕГОРИИ:


Архитектура-(3434)Астрономия-(809)Биология-(7483)Биотехнологии-(1457)Военное дело-(14632)Высокие технологии-(1363)География-(913)Геология-(1438)Государство-(451)Демография-(1065)Дом-(47672)Журналистика и СМИ-(912)Изобретательство-(14524)Иностранные языки-(4268)Информатика-(17799)Искусство-(1338)История-(13644)Компьютеры-(11121)Косметика-(55)Кулинария-(373)Культура-(8427)Лингвистика-(374)Литература-(1642)Маркетинг-(23702)Математика-(16968)Машиностроение-(1700)Медицина-(12668)Менеджмент-(24684)Механика-(15423)Науковедение-(506)Образование-(11852)Охрана труда-(3308)Педагогика-(5571)Полиграфия-(1312)Политика-(7869)Право-(5454)Приборостроение-(1369)Программирование-(2801)Производство-(97182)Промышленность-(8706)Психология-(18388)Религия-(3217)Связь-(10668)Сельское хозяйство-(299)Социология-(6455)Спорт-(42831)Строительство-(4793)Торговля-(5050)Транспорт-(2929)Туризм-(1568)Физика-(3942)Философия-(17015)Финансы-(26596)Химия-(22929)Экология-(12095)Экономика-(9961)Электроника-(8441)Электротехника-(4623)Энергетика-(12629)Юриспруденция-(1492)Ядерная техника-(1748)

Structure of assembly program log.exe




В моей работе я исследовал алгоритмы работы логических операций на основе полученных данных в течении семестра. Я использовал логические опарторы И(and), ИЛИ(or), Исключающие ИЛИ(xor) и Отрицание(not).

The AND instruction is used for supporting logical expressions by performing bitwise AND operation. The bitwise AND operation returns 1, if the matching bits from both the operands are 1, otherwise it returns 0. For my example I use HEX

5FFF and 2345. In binary system 5FFF is 10111111111111, 2345 is 10001101000101. Then, when I used command AND I get HEX 0234.

10001101000101

That 0234 HEX.

In 13 line i use MOV instruction that is used for moving data from one storage space to another. The MOV instruction takes two operands. First operand is ax and second is 5FFFh. I copy in register AX hex number 5FFF.

Register AX I used for arithmetic operation with my logic operator.

Потом я провожу логическую операцию И. Для ее использования нужно 2 операнда. First operand is ax and second is 2345h. Cохраняю результат копируя значения АХ в переменную REZ.

 

Переменную REZ я инициализировал в 4 строке. Инициализируется переменная в несколько этапов. Изначально мы выделяем память в сегменте стека. Segmented memory model divides the system memory into groups of independent segments referenced by pointers located in the segment registers. Each segment is used to contain a specific type of data. One segment is used to contain instruction codes, another segment stores the data elements, and a third segment keeps the program stack.

In the light of the above discussion, we can specify various memory segments as −

· Data segment − It is represented by .data section and the .bss. The.data section is used to declare the memory region, where data elements are stored for the program. This section cannot be expanded after the data elements are declared, and it remains static throughout the program.

The.bss section is also a static memory section that contains buffers for data to be declared later in the program. This buffer memory is zero-filled.

· Code segment − It is represented by .text section. This defines an area in memory that stores the instruction codes. This is also a fixed area.

· Stack − This segment contains data values passed to functions and procedures within the program.

В программе я выделил 256 байт командой DB 256 DUP(0)

DB – одно слово(1 байт, 8 бит)

256 – количество байтов

DUP – дубликат

(0)- стартовое значения слова.

 

В сегменте даты я занимался последним шагом объявление переменной.

rez Dw 1 DUP(0)

rez – название

DW – 2 слова(2 байта, 16 бит)

Информацию о регистрах можно посмотреть в таблице 4.

В 2 программе я использовал логический оператор ИЛИ.

The OR instruction is used for supporting logical expression by performing bitwise OR operation. The bitwise OR operator returns 1, if the matching bits from either or both operands are one. It returns 0, if both the bits are zero.

 

Я показал использование инструкции ИЛИ для 1 байта. Для примера были взяты числа 29 HEX и 45 HEX.

Командой Mov поместил в переменную ax число 29HEX.

Дальше использовал логический оператор OR и к первому операнду AX додал второй операнд 45 HEX. В результате получил число 6D HEX.

00101001
01000101
01101101

Number 29 HEX in binary system is 00101001, 45 HEX in binary system is 01000101, 6D in binary system is 01101101, so answer is correct.

Дальше для сохранения результата я использовал команду OFFSET.

mov bx, OFFSET REZ

OFFSET will get the address of a variable which already has it's address allocated. This in turn means, OFFSET could be used to get the address of global variables only. We cannot receive the address of a local variable by using OFFSET as the address of a local variable is not decided during assembly time.
BX – base register. Used as a pointer to data (located in segment register DS, when in segmented mode).

Для переменной REZ я выделяю память в ячейку BX.

Mov [bx],ax

На выделеную память копирую значение з регистра AX.

 

В программе 3 я использовал два оператора XOR и NOT.

The XOR instruction implements the bitwise XOR operation. The XOR operation sets the resultant bit to 1, if and only if the bits from the operands are different. If the bits from the operands are same (both 0 or both 1), the resultant bit is cleared to 0.

The NOT instruction implements the bitwise NOT operation. NOT operation reverses the bits in an operand. The operand could be either in a register or in the memory.

В программе как и для оператора AND я использовал числа 5FFF и 2345.
Использовав логический оператор XOR на первый операнд подал число 5FFF HEX, а на второе 2345 HEX. После этого использовал оператор NOT

10001101000101
00110010111010
11001101000101

Registers meanings in table 6

 

Table 3

Operand 1 Operand 2 Result of logic operation AND(RESULT)
5FFF    

 

Table 4

Command The contents of registers
ax bx cx dx cs ds di si Flags
c z s p a d
mox ax,5FFFH 5FFF       48BE 48BD                
mov dx,2345 5FFF       48BE 48BD                
And ax,dx         48BE 48BD                
Mov rez,ax         48BE 48BD                

 

Table 5

Command The contents of registers
ax bx cx dx cs ds di si Flags
c z s p a d
mox ax,29H         48BE 48BD                
or ax,45h 006D       48BE 48BD                
mov bx, OFFSET REZ 006D       48BE 48BD                
Mov [bx],ax 006D       48BE 48BD                

 

 

Table 6

Command The contents of registers
ax bx cx dx cs ds di si Flags
c z s p a d
mov ax,0         48BE 48BD                
mox ax,5FFFH 5FFF       48BE 48BD                
Xor ax,2345h 56D6       48BE 48BD                
Not ax A929       48BE 48BD                
Mov rez,ax A929       48BE 48BD                

 




Поделиться с друзьями:


Дата добавления: 2017-01-14; Просмотров: 237; Нарушение авторских прав?; Мы поможем в написании вашей работы!


Нам важно ваше мнение! Был ли полезен опубликованный материал? Да | Нет



studopedia.su - Студопедия (2013 - 2024) год. Все материалы представленные на сайте исключительно с целью ознакомления читателями и не преследуют коммерческих целей или нарушение авторских прав! Последнее добавление




Генерация страницы за: 0.009 сек.