4 Real mode: memory is limited to 1 MB (2^20 bytes). The address range from
5 0x00000 to 0xfffff. So it's need 20bit address but all regs are 16bit. Solution
6 is 2 16bit vlues where first (called selector) stored in seg reg and second
7 (called offset). The addressing process by formula 16 * selector + offset
8 where multiply by 16 in hex is only to add 0 to the right of the number.
9 Protected mode(32bit): offset expanded to be 32bit which gives seg up to 4GB;
10 seg can be devided in pages (4KB each), virtual memory works w/ pages not seg.
11 Interrupts: mechanism to handle hardware events. Interrupts cause control to be
12 past to interrupt handler, routines that process the interr.At the beginning of
13 physical memory placed table of interrupt vectors. Every inerrupt has number
14 which is index in interrupt's table.
15 Registers(32bit) of 386:
29 Instructions in machine language are numers stored as bytes in memory. Each
30 instruction has its own unique numeric code called its operation code or
32 The general form of assembly instruction is
34 In general instructions have a fixed number of operandes from 0 to 3. Types:
35 register - refer directly to the CPU's register
36 memory - refer to data in memory. The address may be hardcoded or computed
37 using registers. Address always offset from segment begining.
38 immediate - fixed values that are listed in the instruction itself, in code
39 segemnt, but not in data segment
40 implied - not explicitly shown operands. For example,increment instruction
41 adds one to register or memory.
44 The MOV instruction, which moves data from onr location to another.
46 The one restriction - both operands can't be memory. Examples
47 mov eax,3 ; store 3 in eax register (3 immediate operand)
48 mov bx,ax ; store the value of ax into bx
49 The ADD instruction, which used to add integers
50 add eax,4 ; eax = eax +4
51 add al,ah ; al = al +ah
52 The SUB instruction, which substracts integers
53 sub bx,10 ; bx = bx - 10
54 sub ebx,edi ; ebx = ebx - edi
55 The INC and DEC instruction, which increment or decrement value by one
60 Used to instruct assembler to do something or inform assembler of something.
61 Dirvs not translated in machine code. Common uses are:
62 define constants; define memory to store data into; group memory into segments;
63 conditionaly include source code; include other files. Basic dirvs:
64 EQU : symbol equ value
65 used to define symbols, which is named constant. Symbol value can't be changed.
66 %define : constant value
67 same as C #define constant macro.
68 RESx and Dx : x is replaced w/ letter that determines the size (Pic. 1)
69 used in data segement to define room of memory. RESx defines room for data
70 w/o initialize it. Dx defines initial value too. It's very comon to mark memory
71 ______ ________ locations w/ labels, cause possible to refer. For example
72 | | | L1 db 0 ; byte labeled L1 w/ init value 1
73 | unit | letter | L2 dw 1000 ; word labeled L2 w/ init value 1000
74 |______|________| L3 db 110101b ; byte labeled L3 w/ init value 53(dec)
75 | byte | b | L4 db 12h ; byte labeled L4 w/ init value 18(dec)
76 | word | w | L5 db 17o ; byte labeled L5 w/ init value 15(dec)
77 | dword| d | L6 dd 1a92h ; dword labeled L6 w/ init value 1a92(hex)
78 | qword| q | L7 resb 1 ; 1 uninitialized byte
79 | 10B | t | L8 db "A" ; byte labeled L8 w/ init value A(65 ascii)
80 |______|________| Doesn't matter double quotes or single. Consecutive data
81 definitions are stored sequentially.So
82 Pic. 1. letters for RESx and Dx dirvs L2 word stored right after L1 byte.
83 Sequences of memory may be defined:
84 L9 db 0,1,2,3 ; defines 4 bytes
85 L10 db "w","o","r","d",0 ; defines C string "word"
86 L11 db "word",0 ; same as L10