1 Replies - 2996 Views - Last Post: 01 April 2012 - 06:01 AM

#1 amitchhajer   User is offline

  • D.I.C Head
  • member icon

Reputation: 7
  • View blog
  • Posts: 78
  • Joined: 30-January 10

Simulation of Type dos command in 8086 assembly

Posted 04 November 2010 - 10:43 PM

Description: The code can be directly copied. To run compile the code using TASM and then make the exe using TLINK. After exe is made, run the exe with filename of existing text file with extension.It is simulation of type command of dos..which is used to read the contents of file and display it on screen
.model small

.data
str1 db 10h dup(0)				; will save filename in this
buff db 1h dup(0)   				; buffer to save data
str2 db 10,13,'File Not Found $' 		; will print this in case file not found

.code
mov ax,@data
mov ds,ax

mov ah,62h					; reading psp contents
int 21h

mov es,bx

mov si,0080h					; 80h contains the lenght of command tail
mov al,es:[si]
mov cl,al
dec cl

mov si,0082h					; 82h starts the text of command tail
lea di,str1					; saving it in str1, in this case the filename
read:
mov al,es:[si]
mov [di],al
inc si
inc di
loop read

mov ah,3dh					; opening the file using 3dh of int 21h
lea dx,str1					; dx contain the filename in ASCIIZ format, i.e 0's at the end
int 21h
jnc mylabel					; there is carry generated if any error	

mov ah,09h					; printing str2 on error else skip
lea dx,str2
int 21h

mylabel:
mov bx,ax					; file handle of the open file is stored in AX, need to move it in BX to read the open the file with handle AX, better store AX somewhere
label1:
mov ah,3fh
mov cx,0001h
lea dx,buff					; reading data in buff of size 1
int 21h
cmp ax,0000h					; printing till ax=0000h, i.e end-of-file
jz end1						; will break and jump to end1 label on end of file

mov cx,0001h
lea si,buff					; printing data in buff
label2:
mov dl,[si]
mov ah,02h					; interrupt on print on screen
int 21h
inc si
loop label2
jmp label1

end1:
mov ah,4ch					; normal end of any assembly program
int 21h
end



Is This A Good Question/Topic? 0
  • +

Replies To: Simulation of Type dos command in 8086 assembly

#2 piseaakash   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 0
  • Joined: 01-April 12

Re: Simulation of Type dos command in 8086 assembly

Posted 01 April 2012 - 06:01 AM

even if we remove the lines mov ah,62h int 21h this code works..what is the reason behind this???
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1