After reading the no homework rule I am afraid to even ask anything in this forum but I will try.
I have been working at this assignment for over a week and after reading all my books and all the postings I could find in the internet I still got nowhere :(.
I just want to reasure anyone that is not a lack of trying or wanting someone to do my code for me, it is just that I truly do not understand assembly, it seems...
Anyhow, my problem is that I need to the get the name of a file from the keyboard. This is how I set out to do it:
FILEHAND WORD ? ;File handle
;************************************************************************************
PARLIST LABEL BYTE ; START OF PARAMETER LIST
MAXNLEN Byte 128 ; MAX NUMBER OF DIGITS TO READ IN
TRUE_LENGTH Byte ? ; THE TRUE NUMBER OF DIGITS ENTERED
FILENAME DB 128 (' ')
;PATHNAME DB ' ',0
PROMPTER Byte 'PLEASE TYPE IN THE FILE NAME: ', 0DH, 0AH, '$'
;*********************************************************************************
;***************************************************************************
; request a file name from client
;***************************************************************************
MOV AH,09H ;SET THE STAGE TO REQUEST USER INPUT
LEA DX,PROMPTER ;LOAD ADDRESS OF DISPLAY TO PRINT OUT
INT 21H
MOV AH,0AH ;LOAD CODE FOR KEYBOARD REQUEST
LEA DX,PARLIST ;INPUT NUMBER
INT 21H
CMP TRUE_LENGTH,00 ;WAS AT LESS ONE CHAR READ IN?
JE A80 ;NO, ONLY A CARRIAGE RETURN..SO STOP
MOVZX CX,TRUE_LENGTH
MOV BX,CX
;MOV_LOOP2:
;
; DEC BX ; BX POINT TO THE LAST DIGIT TYPE IN
; MOV AL,FILENAME[BX] ; MOVE DIGIT TO AL
; LOOP MOV_LOOP2 ; HAVE WE MOVED ALL DIGITS?
;
; MOV PATHNAME,AL
I tried this other way too but it does not work either
LOOP1:
DEC BX ;BX POINT TO THE LAST CHARA;
MOV FILENAME[SI+BX],AL ;MOVE CHAR TO AL
MOV FILENAME[BX],AL ;PLACE CHAR INTO REPLY MESSAGE
CMP BX,00H ;HAVE WE MOVED ALL DIGITS?
JNE LOOP1
MOV FILENAME[BX+1],0 ;triying to make an asciiz string out of the file name
B10OPEN PROC NEAR ;Uses AX, BP, CX, DX
;***************************************************************************
;
; Open file, test if valid:
;
;******************************************************************************
PUSHA ;RESERVE GENERAL REGISTERS
MOV AH,3DH ;Request open
MOV AL,00 ;Normal file
LEA DX,FILENAME
INT 21H
JC B20 ;Error?
MOV FILEHAND,AX ;no, save handle
JMP B90
B20: LEA BP,OPENMSG ;yes, message
MOV CX,40 ;length
INC ROW ;SET UP FOR NEXT ROW
MOV COLUMN,ZERO ;SET COLUMN TO ZERO
CALL DISPLAY ;error message
MOV ENDCODE,01 ;yes,
B90: POPA ;RESTORE GENERAL REGISTERS
RET
B10OPEN ENDP
obviously the code is not working and I get an error of does the file exist.
Could you tell me what is it that I am doing wrong?
I am very new at this and do not quite understand, if this posting violates the homework rule I apologize in advance, just let me know and I will not post anything again. As I said, I do not expect anyone to write my code, I just want to understand what I am doing wrong.
Thanks in advance
I figured out!!!!! :lol :lol :lol :dance: :dance:
Hi lola,
welcome to the forum. Your question is fine, you haven't broken the golden "no homework" rule because you have already done most of the work yourself, and you are asking about a specific problem. What we don't like is people who post requesting or demanding that someone does all the work for them.
Congratulations on working out what your bug was, i would suggest that you post the answer here as well, so if someone comes searching on this topic in the future they can see what you did to solve your problem. But that is just a suggestion - you don't have to :P
Also, i'm moving this thread to the 16 bit subforum, which is a more appropriate spot for it.