Move cursor in Assembly Language
How to move the cursor in Assembly Language?
Solution:
Example Code:
TITLE READ WHOLE SCREEN AND COPY CONTENT INTO SAVEBUFF
.model small
.stack
.data
hi db "Hi",'$'
.code
print macro string
mov ax,0900h
mov dx,0
mov dx,offset string
int 21h
endm
;-------------------------------------------------------------------------------------------------
start:
main proc
mov ax,@data
mov ds,ax
;move cursor from where copy data will start from screen into saveBuff
mov ax,0200h
mov dx,0200h; move cursor to 3rd row of 0th column
mov bx,0; video page = 0
int 10h
print hi
mov ax,4c00h
int 21h
main endp
end start
end
Solution:
TITLE READ WHOLE SCREEN AND COPY CONTENT INTO SAVEBUFF
.model small
.stack
.data
hi db "Hi",'$'
.code
print macro string
mov ax,0900h
mov dx,0
mov dx,offset string
int 21h
endm
;-------------------------------------------------------------------------------------------------
start:
main proc
mov ax,@data
mov ds,ax
;move cursor from where copy data will start from screen into saveBuff
mov ax,0200h
mov dx,0200h; move cursor to 3rd row of 0th column
mov bx,0; video page = 0
int 10h
print hi
mov ax,4c00h
int 21h
main endp
end start
end
Write to file in Assembly Lanugage
.model small
.stack
.data
buffer db "I'm writing.",'$'
file db "myfile.txt",0
.code
mov ax,@data
mov ds,ax
mov dx, offset file
;mov al,0 ;Open file (read-Only)
mov al,1 ; Write only
;mov al,2 ; Read & Write
mov ah,3dh ; Load File handler and store in ax
int 21h
mov cx,10 ; no. of bytes to be written. I want only first 10 bytes to be written in my already created file
mov bx,ax ; Move file Handler to bx
mov dx,offset buffer ; load offset of string which is to be written to file
mov ah,40h
int 21h
mov ah,4ch
int 21h
end
.stack
.data
buffer db "I'm writing.",'$'
file db "myfile.txt",0
.code
mov ax,@data
mov ds,ax
mov dx, offset file
;mov al,0 ;Open file (read-Only)
mov al,1 ; Write only
;mov al,2 ; Read & Write
mov ah,3dh ; Load File handler and store in ax
int 21h
mov cx,10 ; no. of bytes to be written. I want only first 10 bytes to be written in my already created file
mov bx,ax ; Move file Handler to bx
mov dx,offset buffer ; load offset of string which is to be written to file
mov ah,40h
int 21h
mov ah,4ch
int 21h
end
Read from file Assembly Language
.model small
.stack
.data
buffer db 5000 dup("$")
file db "myfile.txt",0
.code
mov ax,@data
mov ds,ax
mov dx, offset file
mov al,0 ;Open file (read-Only)
;mov al,1 ; Write only
;mov al,2 ; Read & Write
mov ah,3dh ; Load File handler and store in ax
int 21h
mov bx,ax ; Move file Handler to bx
mov dx,offset buffer
mov ah,3fh
int 21h
mov ah,9h
int 21h
mov ah,4ch
int 21h
end
.stack
.data
buffer db 5000 dup("$")
file db "myfile.txt",0
.code
mov ax,@data
mov ds,ax
mov dx, offset file
mov al,0 ;Open file (read-Only)
;mov al,1 ; Write only
;mov al,2 ; Read & Write
mov ah,3dh ; Load File handler and store in ax
int 21h
mov bx,ax ; Move file Handler to bx
mov dx,offset buffer
mov ah,3fh
int 21h
mov ah,9h
int 21h
mov ah,4ch
int 21h
end
3fh not working Assembly Language
Problem: 3fh not working in Assembly Language
Solution: Don't do mov cx,0 before calling interrupt for input.
Solution: Don't do mov cx,0 before calling interrupt for input.
Displaying 2 digit number Assembly
TITLE Displaying 2 digit number in Assembly
.model small
.stack
.data
.code
mov ax,2579; 2579 will be displayed
mov cx,0
mov bx,10
loop1:
cmp ax,0
je next1
mov dx,0
div bx
push dx
inc cx
jmp loop1
next1:
mov ah,2h
loop2:
pop dx
add dx,48
int 21h
loop loop2
;exit:
mov ax,0
mov ah,4ch
int 21h
end
NEG in Assembly Language
¢NEG X
X :=
–X
NEG in Assembly Language
TITLE NEG Command in Assembly Language
.MODEL small
.STACK 1000H
.DATA
V1 DW 7
V2 DW 2
.CODE
;LOAD DATA
MOV AX,@DATA
MOV DS,AX
;V1 = V1 + (-V2)
mov BX,V2
NEG BX
ADD V1,BX
;PRINT V1
MOV DX,V1
ADD DX,48
MOV AH,2H
INT 21H
;RETURN CONTROL
mov ah,4ch
int 21h
END
Subscribe to:
Posts (Atom)