Godly T.Alias - B.Tech CSE, National Institute of Technology Calicut Follow me on GitHub
;"ORG0x0100";;JMP "start;;message:db"MC170202278";length:dw20";clrscr; pushes;push ax;push cx;push di;mov ax, "0xb800";moves, ax ; xor di, di ; mov ax, 0x0720 ; mov cx, 2000 ; cld ; repstosw ; pop dipop cxpop axpopesret"subroutine to print a string";;takes the x position, y position, attribute, address of string and;its length as parametersprintstr: push bpmovbp, sppushespush axpush cxpushsipush dimov ax, 0xb800moves, ax ; point es to video basemov al, 80 ; load al with columns per rowmul byte [bp+10] ; multiply with y positionadd ax, [bp+12] ; add x positionshl ax, 1 ; turn into byte offsetmovdi,ax ; point di to required locationmovsi, [bp+6] ; point si to stringmov cx, [bp+4] ; load length of string in cxmov ah, [bp+8] ; load attribute in ahcld ; auto increment modenextchar: lodsb ; load next char in alstosw ; print char/attribute pairloopnextchar ; repeat for the whole stringpop dipopsipop cxpop axpopespopbpret 10start: call clrscr ; call the clrscr subroutinemov ax, 10push ax ; push x positionmov ax, 15;push ax ; push y positionmov ax, 0x12 ; blue on black attributepush ax ; push attributemov ax, messagepush ax ; push address of messagepush word [length] ; push message lengthcallprintstr ; call the printstr subroutinemov ax, 0x4c00 ; terminate programint 0x21
;"ORG0x0100";
ReplyDelete;JMP "start;
;message:db"MC170202278";
length:dw20";
clrscr;
pushes;
push ax;
push cx;
push di;
mov ax, "0xb800";
moves, ax ;
xor di, di ;
mov ax, 0x0720 ;
mov cx, 2000 ;
cld ;
repstosw ;
pop di
pop cx
pop ax
popes
ret
"subroutine to print a string";
;takes the x position, y position, attribute, address of string and
;its length as parameters
printstr: push bp
movbp, sp
pushes
push ax
push cx
pushsi
push di
mov ax, 0xb800
moves, ax ; point es to video base
mov al, 80 ; load al with columns per row
mul byte [bp+10] ; multiply with y position
add ax, [bp+12] ; add x position
shl ax, 1 ; turn into byte offset
movdi,ax ; point di to required location
movsi, [bp+6] ; point si to string
mov cx, [bp+4] ; load length of string in cx
mov ah, [bp+8] ; load attribute in ah
cld ; auto increment mode
nextchar: lodsb ; load next char in al
stosw ; print char/attribute pair
loopnextchar ; repeat for the whole string
pop di
popsi
pop cx
pop ax
popes
popbp
ret 10
start: call clrscr ; call the clrscr subroutine
mov ax, 10
push ax ; push x position
mov ax, 15;
push ax ; push y position
mov ax, 0x12 ; blue on black attribute
push ax ; push attribute
mov ax, message
push ax ; push address of message
push word [length] ; push message length
callprintstr ; call the printstr subroutine
mov ax, 0x4c00 ; terminate program
int 0x21