org 100h
mov ah, 0x9 ;for printing
mov dx, offset hello;loading offset of hello world in dx
int 0x21 ;dos interrupt to print
mov ax, 4ch;terminating program
int 21h
hello: db 'Hello world $';$ is used for terminating string
Printing with color using interrupts
;This program shows how to print with colours
;colours are from 0 to 255
;numbers 16 and onward will give colorful background
org 100h
xor ax,ax ;same as, mov ax,0
lea dx, message
mov bl,10 ;different number will produce different colours
mov ah, 9
int 10h ;interrupt for colours
int 21h
mov ah,4ch;terminating
int 21h
;we can also declare variables or strings here
message dw 'Smile please :)','$'
Printing using video memory
jmp start
str db "Hello world"
start:
mov ax, 0xb800;for accessing video memory, as we want to print some thing on screen
mov es, ax
xor di, di ; same as mov di, 0
xor si, si ; same as mov si, 0
;printing string
print:
mov al, [str+si] ;moving value from str to al
mov byte es:[di],al ;printing value of al
mov byte es:[di+1],0x07;color attribute,you can change it
add si, 1;Moving si one index forward
add di, 2;Moving di two index forward
;because di has char and di+1 has color attribute so, next char should be at di+2
cmp di, 22;str is of 11 byte, which means str will end when di=22
jne print
MOV AH, 4CH ;terminate program
INT 21H
Printing with color using video memory
;colours are from 0 to 255
;numbers 16 and onward will give colorful background
org 100h
jmp start
str db "Hello world"
start:
mov ax, 0xb800;for accessing video memory, as we want to print some thing on screen
mov es, ax
xor di, di ; same as mov di, 0
xor si, si ; same as mov si, 0
;printing string
print:
mov al, [str+si] ;moving value from str to al
mov byte es:[di],al ;printing value of al
;******************************************************
mov byte es:[di+1],10d;I have changed it to get colours
;******************************************************
add si, 1;Moving si one index forward
add di, 2;Moving di two index forward
;because di has char and di+1 has color attribute so, next char should be at di+2
cmp di, 22;str is of 11 byte, which means str will end when di=22
jne print
MOV AH, 4CH ;terminate program
INT 21H
;shapes are in between 1 to 5 asci
org 100h
mov ax,0d;taking 64 in decimal
mov cx,0;counter
loop:
add ax,1
add cx,1
mov dx ,ax
mov ah , 2h
int 21h ; interrupt for printing
cmp cx,6
jne loop
end:
MOV AH,4CH;terminating program
INT 21H
No comments:
Post a Comment