Terminate but Stay Resident (TSR) program of Real Time Clock (Assembly x86)
April 23, 2016
Categorised in: Assembly Codes, MIT Codes
code segment para assume cs:code org 100h ;prog seg prefix addrss hex no of 256 jmp initze savint dd ? ;for saving address of es:bx. count dw 0000h ;count of 17 tics. hours db ? mins db ? sec db ? testnum: push ax ;store all the contents of register push bx ;(not to change original values of register) push cx push dx push cs push es push si push di mov ax,0b800h ;starting address of display, to access screen memory mov es,ax ;es has base and bx has offset by default mov cx,count inc cx mov count,cx cmp cx,011h ;hexadecimal value of 17 jne exit mov cx,0000h mov count,cx call time exit: pop di pop si pop es pop ds pop dx pop cx pop bx pop ax jmp cs:savint ;jump to normal isr ;——————convert procedure——————– convert proc and al,0f0h ror al,4 add al,30h call disp mov al,dh and al,0fh add al,30h call disp ret endp ;————————time procedure—————- time proc mov ah,02h ;character outpuT int 1ah ;this gives system clk mov hours,ch mov mins,cl mov sec,dh mov bx,0f90h ;location for displaying clk mov al,hours mov dh,hours call convert mov al,’:’ call disp mov al,mins mov dh,mins call convert mov al,’:’ call disp mov al,sec mov dh,sec call convert ret endp ;———————–display procedue—————- disp proc mov ah,0ffh ;for setting attribute. 0ffh -> grey background + blink. 0fh -> black background and no blink mov es:bx,ax ;write into video buffer inc bx inc bx ;two times increment bcoz for e.g. 12 is in hours then ‘:’ ret endp ;——————initialization———————— initze: push cs ;code segment pop ds ;pop data segment cli ;clear int flag so that our program can run mov ah,35h ;get original interrupt vector i.e. obtains address of current interrupt handler routine mov al,08h ;intrrupt no. 08 -> for timer int 21h mov word ptr savint,bx ;base is saved to savint temporarily mov word ptr savint+2,es ;offset is saved. +2 because 2 bytes of base is skipped. mov ah,25h ;set int vector to our ISR mov al,08h mov dx,offset testnum ;new add for intrrupt ;before it was es:bx now it is ds:dx for setting. ;offset is keyword int 21h mov ah,31h ;make prog resident(request tsr) mov dx,offset initze ;size of program sti ;set intrrupt flag int 21h code ends end
Pratik Kataria is currently learning Springboot and Hibernate.
Technologies known and worked on: C/C++, Java, Python, JavaScript, HTML, CSS, WordPress, Angular, Ionic, MongoDB, SQL and Android.
Softwares known and worked on: Adobe Photoshop, Adobe Illustrator and Adobe After Effects.