Results 1 to 3 of 3

Thread: Please help with this code!!!

  1. #1
    Guest

    Post

    THIS JUST WONT WORK!!!!!!

    Code:
    start:
    	mov	ds, cs
    	jmp	main
    
    TheTitle	db	"Size	[size.com]", 10, 13,
    		db	"Copyright (C) 2000-2001 Jake E Bush. All rights reserved.", 10, 13, 10, 13,
    		db	"usage: size [file-name]", 10, 13, 10, 13,
    		db	"[file-name]", 10, 13,
    		db	"	Points to the file you want the size of.", 10, 13, "$"
    TooMany	db	"Too many parameters.", 10, 13, "$"
    Error1	db	"Missing file sharing software.", 10, 13, "$"
    Error2	db	"File not found.", 10, 13, "$"
    Error3	db	"Path not found or file does not exist.", 10, 13, "$"
    Error4	db	"No handle available.", 10, 13, "$"
    Error5	db	"Access denied.", 10, 13, "$"
    Error6	db	"Access mode not permitted.", 10, 13, "$"
    Error7	db	"Unknown error.", 10, 13, "$"
    FileHandle	dw	0
    
    main:
    	call	Argc
    
    	;If none
    	cmp	cx, 0
    	je	none
    
    	;If one
    	cmp	cx, 1
    	je	one
    
    	;If more than one
    	cmp	cx, 2
    	jae	two
    
    none:
    	mov	ah, 9
    	mov	dx, offset TheTitle
    	int	21h
    	jmp	exit
    
    two:
    	mov	ah, 9
    	mov	dx, offset TooMany
    	int	21h
    	jmp	exit
    
    one:
    	xor	bx, bx
    	mov	bl, [0080h]
    	mov	word ptr [BX+0082h], 240Ah
    	;mov	dx, 0082h
    	;mov	ah, 09
    	;int	21h
    
    	;Open file
    	xor	cx, cx
    	mov	ah, 3dh
    	mov	al, 0h
    	mov	dx, 0082h
    	int	21h
    
    	jc	error
    
    	mov	FileHandle, ax
    
    	;CloseFile
    	mov	ax, 3eh
    	mov	bx, FileHandle
    	int	21h
    
    	jmp	exit
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    error:
    	cmp	al, 01h
    	je	er1
    	cmp	al, 02h
    	je	er2
    	cmp	al, 03h
    	je	er3
    	cmp	al, 04h
    	je	er4
    	cmp	al, 05h
    	je	er5
    	cmp	al, 0ch
    	je	er6
    	jmp	er7
    
    er1:
    	mov	ah, 9
    	mov	dx, offset Error1
    	int	21h
    	jmp	exit
    er2:
    	mov	ah, 9
    	mov	dx, offset Error2
    	int	21h
    	jmp	exit
    er3:
    	mov	ah, 9
    	mov	dx, offset Error3
    	int	21h
    	jmp	exit
    er4:
    	mov	ah, 9
    	mov	dx, offset Error4
    	int	21h
    	jmp	exit
    er5:
    	mov	ah, 9
    	mov	dx, offset Error5
    	int	21h
    	jmp	exit
    er6:
    	mov	ah, 9
    	mov	dx, offset Error6
    	int	21h
    	jmp	exit
    er7:
    	mov	ah, 9
    	mov	dx, offset Error7
    	int	21h
    	jmp	exit
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    exit:
    	ret
    
    ;=======================================================================================
    Argc		proc
    	;call	Argc
    	;[cx] = The number of arguments
    		push	ds
    		push	ax
    		push	bx
    
    		mov	ah, 62h			;Get PSP DOS call
    		int	21h
    		mov	ds, bx			;Point DS at PSP.
    
    		mov	bx, 80h			;Pointer to start of cmd line-1
    		mov	cx, 0			;Start cnt at zero
    CntLoop1:	inc	bx			;Move on to next char.
    		cmp	byte ptr [bx], ' '	;Skip all spaces here.
    		je	CntLoop1
    		mov	al, [bx]
    		cmp	al, 13			;See if carriage return
    		je	ArgcDone
    ;
    ; We just headed into a word of some sort. Skip all the chars in this argument.
    ;
    		inc	cx			;First, count this argument
    ;
    		cmp	al, '"'			;See if it's a string.
    		je	GotString1
    		cmp	al, "'"
    		je	GotString1
    ;
    ; If not a string, skip to next space or CR.
    ;
    SkipWord1:	inc	bx
    		cmp	byte ptr [bx], ' '
    		je	CntLoop1
    		cmp	byte ptr [bx], 13
    		je	ArgcDone
    		jmp	skipWord1
    ;
    ; If we've got a string, skip to the delimiter or to the end of the line.
    ;
    GotString1:	inc	bx
    		cmp	al, [bx]		;See if the delimiter
    		je	CntLoop1
    		cmp	byte ptr [bx], 13	;See if EOLN
    		jne	GotString1
    ;
    ; Come down here when we're done:
    ;
    ArgcDone:	pop	bx
    		pop	ax
    		pop	ds
    		ret
    Argc		endp
    ;=======================================================================================
    
    end start

  2. #2
    Lively Member
    Join Date
    Jan 2000
    Posts
    102
    is mov ds, cs a valid command?

    itay.

  3. #3
    Fanatic Member
    Join Date
    Jan 2003
    Posts
    1,004
    no.

    The MOV instruction does not support seg -> seg.
    "Can't" and "shouldn't" are two totally separate things.

    All questions should be answered. All answers should be true. That is why I post.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width