Link listfile stampsclusters Odds and ends remaining for

  • Slides: 21
Download presentation
Link list/file stamps/clusters Odds and ends remaining for test 2

Link list/file stamps/clusters Odds and ends remaining for test 2

Linklist output • • • • C: Masm 615>list 1 2 3 4 5

Linklist output • • • • C: Masm 615>list 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

Linked list part 1 ; This program shows how the STRUC directive ; and

Linked list part 1 ; This program shows how the STRUC directive ; and the REPT directive can be combined to ; create a linked list at assembly time. INCLUDE Irvine 32. inc List. Node STRUCT Node. Data DWORD ? Next. Ptr DWORD ? List. Node ENDS Total. Node. Count = 15 NULL = 0 Counter = 0. data Linked. List LABEL PTR List. Node REPT Total. Node. Counter = Counter + 1 List. Node <Counter, ($ + Counter * SIZEOF List. Node)> ENDM List. Node <0, 0> ; tail node

Linked list continued. code main PROC mov esi, OFFSET Linked. List ; Display the

Linked list continued. code main PROC mov esi, OFFSET Linked. List ; Display the integers in the Node. Data members. Next. Node: ; Check for the tail node. mov eax, (List. Node PTR [esi]). Next. Ptr cmp eax, NULL je quit ; Display the node data. mov eax, (List. Node PTR [esi]). Node. Data call Write. Dec call Crlf ; Get pointer to next node. mov esi, (List. Node PTR [esi]). Next. Ptr jmp Next. Node quit: exit main ENDP END main

Linklist 2 a linklist on the stack C: Masm 615>linklist 2 enter numbers. .

Linklist 2 a linklist on the stack C: Masm 615>linklist 2 enter numbers. . . 999 to quit 34 enter numbers. . . 999 to quit 56 enter numbers. . . 999 to quit 333 enter numbers. . . 999 to quit 12 enter numbers. . . 999 to quit 90 enter numbers. . . 999 to quit 609 enter numbers. . . 999 to quit 45 enter numbers. . . 999 to quit 32 enter numbers. . . 999 to quit 665 enter numbers. . . 999 to quit 435 enter numbers. . . 999 to quit 354 enter numbers. . . 999 to quit 09 enter numbers. . . 999 to quit 54 enter numbers. . . 999 to quit 999 54 9 354 435 665 32 45 609 90 12 333 56 34 C: Masm 615>

Linklist 2…build arbitrary size list (up to stack allocation) List. Node STRUCT Node. Data

Linklist 2…build arbitrary size list (up to stack allocation) List. Node STRUCT Node. Data DWORD ? Next. Ptr DWORD ? List. Node ENDS Total. Node. Count = 15; ; ; not used NULL = 0 Counter = 0. data nullval dword 0 prompt byte "enter numbers. . . 999 to quit", 0 ; ; Linked. List LABEL PTR List. Node <0, 0>. code ; tail node…not used

Linklist 2 main PROC push nullval; ; ; this is the tail ptr mov

Linklist 2 main PROC push nullval; ; ; this is the tail ptr mov esi, esp; ; ; current node address more: mov edx, offset prompt call writestring call crlf call readint; ; ; here is where we get data cmp eax, 999 je done. Input mov ebp, esi push ebp ; ; ; this is the next node ptr push eax; ; ; this is the data mov esi, esp; ; ; now this is the address of current node jmp more done. Input:

continued Next. Node: ; Check for the tail node. mov eax, (List. Node PTR

continued Next. Node: ; Check for the tail node. mov eax, (List. Node PTR [esi]). Next. Ptr cmp eax, NULL je quit ; Display the node data. mov eax, (List. Node PTR [esi]). Node. Data call Write. Dec call Crlf ; Get pointer to next node. mov esi, (List. Node PTR [esi]). Next. Ptr jmp Next. Node quit: exit main ENDP END main

Date stamp Year = 0. . 119 and is added to 1980 Month=1. .

Date stamp Year = 0. . 119 and is added to 1980 Month=1. . 12 Day=1. . 31 month day 15 year 9 8 5

Time stamp Hour=0. . 23 Minute=0. . 59 Seconds=0. . 59 hours seconds minutes

Time stamp Hour=0. . 23 Minute=0. . 59 Seconds=0. . 59 hours seconds minutes 0 15 11 10 5 4

Cluster chain example- just links are shown 2 3 4 8 1 2 3

Cluster chain example- just links are shown 2 3 4 8 1 2 3 4 9 10 eoc 5 6 7 8 9 10 File starting cluster=1, filesize=7 11 12 13 14 15 16

Cluster chain example#2 - just links are shown 6 7 11 1 2 3

Cluster chain example#2 - just links are shown 6 7 11 1 2 3 4 5 6 7 12 eoc 8 9 10 File starts in cluster 5, size 5 11 12 13 14 15 16

Arraysum recusive include irvine 32. inc. data array dword 100, 200, 400, 300, 700,

Arraysum recusive include irvine 32. inc. data array dword 100, 200, 400, 300, 700, 900, 800, 500, 600. code main proc mov esi, lengthof array dec esi shl esi, 2; esi is last subscript mov eax, esi call writedec call crlf xor eax, eax call arraysum call write. Dec main endp

continued arraysum proc call writedec call crlf cmp esi, 0 jl L 2 add

continued arraysum proc call writedec call crlf cmp esi, 0 jl L 2 add eax, dword ptr array[esi] sub esi, 4 call arraysum L 2: ret arraysum endp end main

output 32 0 600 1100 1900 2800 3500 3800 4200 4400 4500 <I inserted

output 32 0 600 1100 1900 2800 3500 3800 4200 4400 4500 <I inserted crlf here> 4500

Proto example from text: arraysum include irvine 32. inc arraysum PROTO, parray: PTR DWORD,

Proto example from text: arraysum include irvine 32. inc arraysum PROTO, parray: PTR DWORD, sz: DWORD. data array dword 10, 20, 30 , 40, 60, 50, 70, 80 message byte "here is the sum", 0. code main proc mov edx, offset message call write. String call crlf invoke arraysum, ADDR array, lengthof array call writedec call crlf exit main endp

continued arraysum proc USES esi ecx, p. Array: ptr Dword, sz: Dword mov ecx,

continued arraysum proc USES esi ecx, p. Array: ptr Dword, sz: Dword mov ecx, sz xor eax, eax mov esi, p. Array top: add eax, [esi] add esi, 4 loop top ret arraysum endp end main

output • here is the sum • 360 • Press any key to continue.

output • here is the sum • 360 • Press any key to continue. . .

Array search recursive (using registers) include irvine 32. inc. data array dword 100, 200,

Array search recursive (using registers) include irvine 32. inc. data array dword 100, 200, 400, 300, 700, 900, 800, 500, 600. code main proc mov esi, lengthof array dec esi shl esi, 2; esi is last subscript mov eax, esi call writedec call crlf mov eax, 501; ; ; wont find it call search mov eax, ebx call write. Int ; ; will write -1 for not found main endp

Recursive search proc mov ebx, -1 cmp esi, 0 jl L 2 cmp eax,

Recursive search proc mov ebx, -1 cmp esi, 0 jl L 2 cmp eax, dword ptr array[esi] jnz skip mov ebx, esi shr ebx, 2 jmp l 2 skip: sub esi, 4 call search L 2: ret search endp end main

Writes last subscript then found value First run…look for 501 32 -1 Second run

Writes last subscript then found value First run…look for 501 32 -1 Second run look for 500 32 +7 found in position 7