This blog is about my daily programming technologies I explore and work on. It contains data from my University learning materials to my Profession as Software Engineer. Programming in Asp.net, Windows Forms, JavaScript, HTML, OpenGL, Assembly Language, Dynamics CRM 2011.
Feedjit
Articles for you
Showing posts with label nasm. Show all posts
Showing posts with label nasm. Show all posts
Tuesday, September 22, 2015
Display Analog Clock of System Time in Assembly Language Sir Asim Munir
By
Saqib Khan
at
September 22, 2015
Display Analog Clock of System Time in Assembly Language Sir Asim Munir
2015-09-22T01:24:00-07:00
Saqib Khan
.ASM|Assembly Language|F09B|Islamic University|MASM|nasm|Programming|Sir Asim|System Programming|
Comments
Labels:
.ASM,
Assembly Language,
F09B,
Islamic University,
MASM,
nasm,
Programming,
Sir Asim,
System Programming
Tuesday, December 31, 2013
Simplest and Easiest Inheritance in C++: Easy Implementation of Inheritance in C++ Student/Teacher Program in C++
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | #include<iostream.h>
#include<conio.h>
#define size 20
class person
{
protected:
char name[size];
int id;
public:
person():id(0) {name[size]=' ';}
virtual void getd();
virtual void putd();
virtual int isoutstanding()=0;
};
class student : public person
{
protected:
float gpa;
public:
student():person(){gpa=0;}
void getd();
void putd();
int isoutstanding();
};
class teacher : public person
{
protected:
int publish;
public:
teacher():person(){publish=0;}
void getd();
void putd();
int isoutstanding();
};
//defineing functions for student class
void student::getd()
{
cout<<"Enter the name of student\n";
cin.get(name,size);
cout<<"Enter ID or REG\n";
cin>>id;
cout<<"Enter gpa\n";
cin>>gpa;
}
void student::putd()
{
int i=0;
cout<<"Name of student is\n";
while(name[i]!='\0')
{
cout<<name[i];
i++;
}
cout<<"Reg or ID is\n";
cout<<id;
cout<<"gpa is\n";
cout<<gpa;
}
int student::isoutstanding()
{
if(gpa>=3.5)
return 1;
else
return 0;
}
//defineing methods of teacher
void teacher::getd()
{
cout<<"Enter the name of teacher\n";
cin.get(name,size);
cout<<"Enter ID or REG\n";
cin>>id;
cout<<"Enter number of publishes\n";
cin>>publish;
}void teacher::putd()
{
int i=0;
cout<<"Name of teacher is\n";
while(name[i]!='\0')
{
cout<<name[i];
i++;
}
cout<<"Reg or ID is\n";
cout<<id;
cout<<"Number of publish is\n";
cout<<publish;
}
int teacher::isoutstanding()
{
if(publish>=5)
return 1;
else
return 0;
}
int main()
{
person *pptr[20];
int n=0;
char choice,reply;
do
{
cout<<"Enter your choice";
cin>>choice;
if(choice=='s')
{
pptr[n] = new student;
}
else
{
pptr[n] = new teacher;
}
pptr[n]->getd();
n++;
cout<<"Do you want to run it again\n";
cin>>reply;
}
while(reply=='y');
getche();
return 0;
}
|
By
Saqib Khan
at
December 31, 2013
Simplest and Easiest Inheritance in C++: Easy Implementation of Inheritance in C++ Student/Teacher Program in C++
2013-12-31T01:32:00-08:00
Saqib Khan
C++|Computer Science|F09B|Hardware Programming|Islamic University|MASM|nasm|Programming|System Programming|Visual Studio 2012|
Comments
Labels:
C++,
Computer Science,
F09B,
Hardware Programming,
Islamic University,
MASM,
nasm,
Programming,
System Programming,
Visual Studio 2012
.asm, ASM, MASM, NASM, Assembly Language, To Display Floppy,MAth,Game-IO,DMA information when caps lock is on ; Else : Display Video Mode and No.of Drives installed.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | ;Programmed by Saqib khan
;Purpose: To Display Floppy,MAth,Game-IO,DMA information when caps lock is on
; Else : Display Video Mode and No.of Drives installed.
;Dated: 22nd/May/2012
.model small
.stack 100h
.data
str_floppy_n db 10,"Floppy disk drive not installed.$"
str_floppy_y db 10,"Floppy disk drive installed. $"
str_math_n db 10,"Math coprocessor not installed. $"
str_math_y db 10,"Math coprocessor installed.$"
str_game_y db 10,"Game IO is installed:$"
str_game_n db 10,"Game IO is not installed:$"
str_vid0 db 10,"Video Mode None $"
str_vid1 db 10,"Video Mode:40*25 color $"
str_vid2 db 10,"Video Mode:80*25 color $"
str_vid3 db 10,"Video Mode:80*25 Monochrome $"
str_dma_ok db 10,"DMA is Present $"
str_dma_not db 10,"DMA is not Present $"
str_drives db 10,"No.of drives are: $"
.code
main:
mov ax,@data
mov ds,ax
int 11h ;Interrupt for Equipment installed
mov bx,ax ;Store original Copy
mov ah,2 ;Interrup for Keyboard Special Keys
int 16h ;Call OS to do the job
mov cl,2 ;Offset value for shifting
shl al,cl ;Shift Left al by the value of cl
jc video_mode ;Jump if carry flag is on
floppy_y:
mov ax,bx
and ax, 1 ;Masking value for Floppy disk drive
jz floppy_n ;Jump if zero flag
lea dx,str_floppy_y ;Load address of string
mov ah,9h ;Service # to display string
int 21h ;Call OS to do the job
jmp math_ok ;jmp next block
floppy_n:
lea dx,str_floppy_n ;Load address of string
mov ah,9h ;Service # to display string
int 21h ;Call OS to do the job
math_ok:
mov ax,bx ;Restore the original value
and ax,2 ;Masking value for
jz math_no
lea dx,str_math_y
mov ah,9h
int 21h
jmp dma_ok
math_no:
lea dx,str_math_n
mov ah,9h
int 21h
dma_ok:
mov ax,bx
and ax,256
jz no_dma
lea dx,str_dma_ok
mov ah,9h
int 21h
jmp Game_IO
no_dma:
lea dx,str_dma_not
mov ah,9h
int 21h
Game_IO:
mov ax,bx
and ax,4096
jz no_game_io
lea dx,str_game_y
mov ah,9h
int 21h
no_game_io:
lea dx,str_game_n
mov ah,9h
int 21h
jmp end_lbl
video_mode:
mov ax,bx
mov cl,4
and ax,48
shr al,cl
add al,30h
cmp al,30h
je str0_disp
cmp al,31h
je str1_disp
cmp al,32h
je str2_disp
lea dx,str_vid3
mov ah,9h
int 21h
jmp chk_drives
str0_disp:
lea dx,str_vid0
mov ah,9h
int 21h
jmp chk_drives
str1_disp:
lea dx,str_vid1
mov ah,9h
int 21h
jmp chk_drives
str2_disp:
lea dx,str_vid2
mov ah,9h
int 21h
chk_drives:
lea dx,str_drives
mov ah,9h
int 21h
mov cl,6
mov ax,bx
and ax,192
shr al,cl
inc al
mov dl,al
add dl,30h
mov ah,2h
int 21h
end_lbl:
mov ah,4ch
int 21h
end main
|
By
Saqib Khan
at
December 31, 2013
.asm, ASM, MASM, NASM, Assembly Language, To Display Floppy,MAth,Game-IO,DMA information when caps lock is on ; Else : Display Video Mode and No.of Drives installed.
2013-12-31T01:06:00-08:00
Saqib Khan
.ASM|Computer Science|F09B|Hardware Programming|Islamic University|MASM|nasm|Programming|Sir Asim|System Programming|
Comments
Labels:
.ASM,
Computer Science,
F09B,
Hardware Programming,
Islamic University,
MASM,
nasm,
Programming,
Sir Asim,
System Programming
Switch Case Implementation, Easiest Implementation, Choice Assembly Language, ASM, MASM, NASM Switch CASE
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | ;Programmed by SAQIB KHAN
;Purpose: Obtain Choice from user/Implement case
;Dated: 15th-MAY-2012
.model small
.stack 100h
.data
num1 db 97
num2 db 2
msg_add db 10, "Press 0 for Addition $"
msg_sub db 10, "Press 1 for Subtraction $"
msg_adc db 10, "Press 2 to add with carry $"
message db 10, "Enter your choice: $"
msg_wrong db 10, "Please enter correct choice $"
msg_verify db 10, "First operand sholud be greater than 2nd,Please change input values $"
.code
main:
mov ax,@data
mov ds,ax
lea dx,msg_add ;Display add message
mov ah,9h
int 21h
lea dx,msg_sub ;Display subtract message
mov ah,9h
int 21h
lea dx,msg_adc ;Display add message
mov ah,9h
int 21h
lea dx,message ;Display choice message
mov ah,9h
int 21h
;;;;;;;;;;;;;;;;;;;;
mov ah,1 ;read key from user
int 21h
mov ah,0 ;empty the ah ,upper part of ax
sub al,30h ; subtract 30h to get exact value from ascii
shl al,1 ; multiply number by 2 to get to the case
cmp al,4 ;compare for validity
jg check ;jump if al,greater than 4
mov bx,ax ;mov value of ax to bx for offset
jmp cs:jmptble [bx] ;jumptable
jmptble dw case0,case1,case2 ;cases
check:
lea dx,msg_wrong ;Display wrong choice
mov ah,9h
int 21h
mov dl,10 ;Move to new line
mov ah,2h
int 21h
jmp main ;Loop again to get correct choice
case0: ;Case0- Addition
mov dl,10 ;move to new line
mov ah,2h
int 21h
mov al,num1 ;copy num1 to al
xor ah,ah ;empty ah to zero
add al,num2 ; add num2 to al
call display
jmp endlabel ;jum to endlabel
case1: ;Case1 for subtraction
mov dl,10 ;;Move to new line
mov ah,2h
int 21h
mov cl,num1 ;Copy number1 to cl
cmp cl,num2 ;check if first numbr is smaller than second
jl verify ;jump if num1 is less than num2
mov al,num1 ;copy num1 to al
xor ah,ah ;empty the uper portion of ax
sub al,num2 ;subtract two nmbers
call display
jmp endlabel
case2:
mov dl,10
mov ah,2h
int 21h
mov al,num1
xor ah,ah
adc al,num2 ;adc add 1 value to the sum (if carry flag is 1)
call display
jmp endlabel
verify:
lea dx,msg_verify
mov ah,9
int 21h
display:
mov dl,10 ;mov dl,10 to divide result in ax
div dl ;Dvide ax by 10
mov dl,al ;copy quotient to dl
mov bl,ah ;copy remainder to bl
add dl,30h ;add 30h to get actual number
mov ah,2h ;Service # to display character
int 21h ;Call OS to do the job
add bl,30h ;add 30h to remainder
mov dl,bl ;move to dl to display
mov ah,2h ;Service # to display character
int 21h ;Call OS to do the job
ret
endlabel:
mov ah,4ch
int 21h
end main
|
By
Saqib Khan
at
December 31, 2013
Switch Case Implementation, Easiest Implementation, Choice Assembly Language, ASM, MASM, NASM Switch CASE
2013-12-31T00:22:00-08:00
Saqib Khan
.ASM|F09B|Hardware Programming|MASM|nasm|Programming|Sir Asim|Swith Case|System Programming|
Comments
Labels:
.ASM,
F09B,
Hardware Programming,
MASM,
nasm,
Programming,
Sir Asim,
Swith Case,
System Programming
Subscribe to:
Posts (Atom)
