1 / 21

Link list/file stamps/clusters

Link list/file stamps/clusters. Odds and ends remaining for test 2. Linklist output. C:Masm615>list 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15. Linked list part1. ; This program shows how the STRUC directive ; and the REPT directive can be combined to

molimo
Download Presentation

Link list/file stamps/clusters

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

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

  3. Linked list part1 ; This program shows how the STRUC directive ; and the REPT directive can be combined to ; create a linked list at assembly time. INCLUDE Irvine32.inc ListNode STRUCT NodeData DWORD ? NextPtr DWORD ? ListNode ENDS TotalNodeCount = 15 NULL = 0 Counter = 0 .data LinkedList LABEL PTR ListNode REPT TotalNodeCount Counter = Counter + 1 ListNode <Counter, ($ + Counter * SIZEOF ListNode)> ENDM ListNode <0,0> ; tail node

  4. Linked list continued .code main PROC movesi,OFFSETLinkedList ; Display the integers in the NodeData members. NextNode: ; Check for the tail node. moveax,(ListNode PTR [esi]).NextPtr cmpeax,NULL je quit ; Display the node data. moveax,(ListNode PTR [esi]).NodeData call WriteDec call Crlf ; Get pointer to next node. movesi,(ListNode PTR [esi]).NextPtr jmpNextNode quit: exit main ENDP END main

  5. Linklist2 a linklist on the stack C:\Masm615>linklist2 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:\Masm615>

  6. Linklist2…build arbitrary size list (up to stack allocation) ListNode STRUCT NodeData DWORD ? NextPtr DWORD ? ListNode ENDS TotalNodeCount = 15;;;not used NULL = 0 Counter = 0 .data nullval dword 0 prompt byte "enter numbers... 999 to quit",0 ;;;;LinkedList LABEL PTR ListNode ListNode <0,0> ; tail node…not used .code

  7. Linklist2 main main PROC push nullval push nullval;;;this is the tail ptr movesi,esp;;;current node address more: movedx,offset prompt call writestring call crlf call readint;;;;;;here is where we get data cmp eax,999 je doneInput movebp,esi push ebp ;;;this is the next node ptr push eax;;;this is the data movesi,esp;;;now this is the address of current node jmp more doneInput:

  8. continued NextNode: ; Check for the tail node. moveax,(ListNode PTR [esi]).NextPtr cmpeax,NULL je quit ; Display the node data. moveax,(ListNode PTR [esi]).NodeData call WriteDec call Crlf ; Get pointer to next node. movesi,(ListNode PTR [esi]).NextPtr jmpNextNode quit: exit main ENDP END main

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

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

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

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

  13. Arraysum recusive include irvine32.inc .data array dword 100, 200, 400, 300,700,900,800,500,600 .code main proc movesi,lengthof array decesi shl esi,2;esi is last subscript moveax,esi call writedec call crlf xoreax,eax call arraysum call writeDec main endp

  14. continued arraysum proc call writedec call crlf cmp esi,0 jl L2 add eax,dwordptr array[esi] sub esi,4 call arraysum L2:ret arraysum endp end main

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

  16. Proto example from text: arraysum include irvine32.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 movedx,offset message call writeString call crlf invoke arraysum, ADDR array,lengthof array call writedec call crlf exit main endp

  17. continued arraysum proc USES esiecx,pArray:ptrDword,sz:Dword movecx,sz xoreax,eax movesi,pArray top: add eax,[esi] add esi,4 loop top ret arraysum endp end main

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

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

  20. Recursive search proc search proc mov ebx,-1 cmp esi,0 jl L2 cmpeax,dwordptr array[esi] jnz skip movebx,esi shr ebx,2 jmp l2 skip: sub esi,4 call search L2:ret search endp end main

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

More Related