Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Carter P.A.PC assembly language.2005.pdf
Скачиваний:
15
Добавлен:
23.08.2013
Размер:
1.07 Mб
Скачать

1.5. SKELETON FILE

25

that seems the most natural. The biggest (i.e. most significant) byte is stored first, then the next biggest, etc. For example, the dword 00000004 would be stored as the four bytes 00 00 00 04. IBM mainframes, most RISC processors and Motorola processors all use this big endian method. However, Intel-based processors use the little endian method! Here the least significant byte is stored first. So, 00000004 is stored in memory as 04 00 00 00. This format is hardwired into the CPU and can not be changed. Normally, the programmer does not need to worry about which format is used. However, there are circumstances where it is important.

1.When binary data is transfered between di erent computers (either from files or through a network).

2.When binary data is written out to memory as a multibyte integer and then read back as individual bytes or vice versa.

Endianness does not apply to the order of array elements. The first element of an array is always at the lowest address. This applies to strings (which are just character arrays). Endianness still applies to the individual elements of the arrays.

1.5Skeleton File

Figure 1.7 shows a skeleton file that can be used as a starting point for writing assembly programs.

26

CHAPTER 1. INTRODUCTION

skel.asm

1%include "asm_io.inc"

2segment .data

3;

4; initialized data is put in the data segment here

5;

6

7segment .bss

8;

9; uninitialized data is put in the bss segment

10 ;

11

12segment .text

13global _asm_main

14_asm_main:

15

enter

0,0

; setup routine

16

pusha

 

 

17

18;

19; code is put in the text segment. Do not modify the code before

20; or after this comment.

21;

22

23

24

25

26

popa

mov

eax, 0

; return back to C

leave

ret

skel.asm

Figure 1.7: Skeleton Program

Соседние файлы в предмете Электротехника