| | |
Assembly project problem
![]() |
•
•
Join Date: Apr 2009
Posts: 2
Reputation:
Solved Threads: 0
I am working on homework for my x86 assembly class. The purpose of the program is to open an existing file and display the first 20 lines of the file and then pause, display the next 20 lines, pause, etc. until the end of the file is reached. My professor is really terrible, he rarely ever takes us to the lab so we don't get much practice, and so it's hard to understand. The problem is that it doesn't pause after 20 lines, and once the end of the file is reached, it starts dumping register values and garbage data and then crashes. I am really stuck, can anyone help me? Here is my code:
The irvine32.inc is from our textbook, so hopefully you guys can help me. If you need to know parameters or anything from any of the procedures, just say so and I'll post them, but I'm fairly certain that the problem lies elsewhere.
Assembly Syntax (Toggle Plain Text)
TITLE MASM Template (main.asm) ; Description: ; ; Revision date: INCLUDE Irvine32.inc .data buffer BYTE 500 dup(?) bufSize DWORD ($-buffer)-1 errMsg BYTE "Cannot open file.",0dh,0ah,0 fileprompt BYTE "Enter file to display",0dh,0ah,0 filename BYTE 100 dup(?) fileHandle DWORD ? byteCount DWORD ? lines BYTE 0 asdf BYTE ? .code main PROC mov edx,OFFSET fileprompt call WriteString mov edx,OFFSET filename mov ecx,99 call ReadString invoke CreateFile,ADDR filename,GENERIC_READ,DO_NOT_SHARE,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0 mov fileHandle,eax cmp eax,INVALID_HANDLE_VALUE jne disploop mov edx,OFFSET errMsg call WriteString jmp QuitNow disploop: invoke ReadFile,fileHandle,ADDR buffer,bufSize,ADDR byteCount,NULL cmp byteCount,0 je atEOF mov edi,0 s: mov esi,byteCount mov buffer[esi],0 mov al,buffer[edi] mov asdf,al mov edx,OFFSET asdf call WriteString cmp buffer[edi],13 jne cm inc lines cmp lines,20 je p jmp cm p: mov lines,0 pause cm: cmp byteCount,0 je disploop inc edi jmp s atEOF: invoke CloseHandle,fileHandle QuitNow: exit main ENDP END main
Have a counter increment it when it reaches 20 jmp to pause.
•
•
Join Date: Apr 2009
Posts: 2
Reputation:
Solved Threads: 0
I have that:
but it doesn't work.
Assembly Syntax (Toggle Plain Text)
inc lines cmp lines,20 je p jmp cm p: mov lines,0 pause
![]() |
Similar Threads
- how to fix this problem..urgent.. (ASP.NET)
- Alarm digital clock assembly language for 8085 microprocessor (Assembly)
- Please anybody help to solve error "class not registered" problem in vs 2003 (ASP.NET)
- help nedden in MIPS Assembly (Assembly)
- Am Getting System Errors When running my VB.NET project (VB.NET)
- Please help with the assembly code (Assembly)
- Assembly, machine code and compilers (Assembly)
- mp3 id3 tag viewer (Assembly)
Other Threads in the Assembly Forum
- Previous Thread: x86 NASM loop
- Next Thread: strings in assembly
| Thread Tools | Search this Thread |






