Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;we cannot assign a direct memory value to the segment register.
- ;file.asm is TASM directory
- Data segment
- a db 10
- b db 20 ;db stands for Define a Byte
- Data ends
- Code segment
- assume CS:Code, DS:Data
- MOV AX,Data ;can't load directly. etle aavu karvanu
- MOV DS,AX
- XOR AX,AX ;to make 0
- MOV AL,a
- MOV BL,b
- ADD BL,AL
- Int 3
- Code ends
- End
- ;*compile ASM file:
- ;tasm file.asm
- ;*link:
- ;tlink FILE.OBJ
- ;*know starting and ending address:
- ;type FILE.MAP
- ;*to execute:
- ;in DEBUG125 directory:
- ;debug C:\TASM\file.exe
- ;-g=0010 //starting address retrieved from previous step
- ;*int21h
- ;int21h is a function. with arguments (ah,(dl,dx,al))
- ;ah is like case switch. it can be 01,02,09
- ;switch ah:
- ;case 01 to scan character
- ;like scanf(al) //always al
- ;case 02 to print character
- ;like print(dl) //always dl
- ;case 09 to print a string
- ;like print(dx) //always dx
- ;*AIM: take capital A as an input and print small a.
- data segment
- a db 20H
- data ends
- code segment
- assume cs:code, ds:data
- MOV AX,data
- MOV DS,AX
- XOR AX,AX
- MOV AH,1
- Int 21H
- MOV DL,AL
- ADD DL,a
- MOV AH,2
- INT 21H
- INT 03H
- code ends
- end
- ;*printing new line. hex is 0A for new line
- code segment
- assume cs:code
- mov dl,33H
- mov ah,02
- int 21h
- mov dl,0aH //0 is important.
- int 21h
- mov dl,64H
- int 21h
- int 03h
- code ends
- end
- ;*print 2 strings in different lines.
- data segment
- a db 'hey first$'
- b db 'hey second$'
- data ends
- code segment
- assume cs:code, ds:data
- MOV AX,data
- MOV DS,AX
- XOR AX,AX
- mov dx,offset a
- mov ah,09h
- int 21h
- mov dl,0aH
- mov ah,02h
- int 21h
- mov dx,offset b
- mov ah,09h
- int 21h
- int 03h
- code ends
- end
- ;*printing from halfway
- data segment
- a db 'hey first$'
- b db 'hey second$'
- data ends
- code segment
- assume cs:code, ds:data
- MOV AX,data
- MOV DS,AX
- XOR AX,AX
- mov dx,offset a
- add dx, 0004
- mov ah,09h
- int 21h
- mov dl,0aH
- mov ah,02h
- int 21h
- mov dx,offset b
- mov ah,09h
- int 21h
- int 03h
- code ends
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement