Link list/file stamps/clusters Odds and ends remaining for test 2
Linklist output C:\Masm615>list
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 ENDM ListNode ; tail node
Linked list continued.code main PROC mov esi,OFFSET LinkedList ; Display the integers in the NodeData members. NextNode: ; Check for the tail node. mov eax,(ListNode PTR [esi]).NextPtr cmp eax,NULL je quit ; Display the node data. mov eax,(ListNode PTR [esi]).NodeData call WriteDec call Crlf ; Get pointer to next node. mov esi,(ListNode PTR [esi]).NextPtr jmp NextNode quit: exit main ENDP END main
Linklist2 a linklist on the stack C:\Masm615>linklist2 enter numbers to quit 34 enter numbers to quit 56 enter numbers to quit 333 enter numbers to quit 12 enter numbers to quit 90 enter numbers to quit 609 enter numbers to quit 45 enter numbers to quit 32 enter numbers to quit 665 enter numbers to quit 435 enter numbers to quit 354 enter numbers to quit 09 enter numbers to quit 54 enter numbers to quit C:\Masm615>
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 to quit",0 ;;;;LinkedList LABEL PTR ListNode ListNode ; tail node…not used.code
Linklist2 main main PROC push nullval 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 doneInput 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 doneInput:
continued NextNode: ; Check for the tail node. mov eax,(ListNode PTR [esi]).NextPtr cmp eax,NULL je quit ; Display the node data. mov eax,(ListNode PTR [esi]).NodeData call WriteDec call Crlf ; Get pointer to next node. mov esi,(ListNode PTR [esi]).NextPtr jmp NextNode quit: exit main ENDP END main
Date stamp year month day Year = and is added to 1980 Month=1..12 Day=1..31
Time stamp 15 0 hoursminutes seconds Hour=0..23 Minute=0..59 Seconds=
Cluster chain example- just links are shown eoc File starting cluster=1, filesize=7
Cluster chain example#2- just links are shown eoc File starts in cluster 5, size5
Arraysum recusive include irvine32.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 writeDec main endp
continued arraysum proc call writedec call crlf cmp esi,0 jl L2 add eax,dword ptr array[esi] sub esi,4 call arraysum L2:ret arraysum endp end main
output
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 mov edx,offset message call writeString call crlf invoke arraysum, ADDR array,lengthof array call writedec call crlf exit main endp
continued arraysum proc USES esi ecx,pArray:ptr Dword,sz:Dword mov ecx,sz xor eax,eax mov esi,pArray 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...
Array search recursive (using registers) include irvine32.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 writeInt ;;will write -1 for not found main endp
Recursive search proc search proc mov ebx,-1 cmp esi,0 jl L2 cmp eax,dword ptr array[esi] jnz skip mov ebx,esi shr ebx,2 jmp l2 skip: sub esi,4 call search L2:ret search endp end main
Writes last subscript then found value First run…look for Second run look for found in position 7