Slide 9.6: This book's link library (cont.) Slide 10.1: Programming Laboratory IV: Home |
ParseDecimal32
ParseInteger32
EDX
and the string's length in ECX
.
The binary value is returned in EAX
.
Writing a String “12345” to a File, number.txt |
Reading the String from the File and Incrementing it |
STR_LEN = 6 .data fname BYTE "number.txt", 0 buffer BYTE "12345", 0 msg BYTE "Error!", 0 fhandle DWORD ? .code mov edx, OFFSET fname call CreateOutputFile cmp eax, \ INVALID_HANDLE_VALUE je err mov fhandle, eax mov edx, OFFSET buffer mov ecx, STR_LEN call WriteToFile call WriteInt mov eax, fhandle call CloseFile exit err: mov edx, OFFSET msg call WriteString |
BUFFER_SIZE = 128 .data fname BYTE "number.txt", 0 buffer BYTE BUFFER_SIZE DUP(0) msg BYTE "Error!", 0 fhandle DWORD ? .code mov edx, OFFSET fname call OpenInputFile cmp eax, \ INVALID_HANDLE_VALUE je err mov fhandle, eax mov edx, OFFSET buffer mov ecx, BUFFER_SIZE call ReadFromFile mov edx, OFFSET buffer call ParseInteger32 inc eax call WriteInt mov eax, fhandle call CloseFile exit err: mov edx, OFFSET msg call WriteString |
Output | Output |