Lab Manual AMI 80386
Lab Manual AMI 80386
Theory:
• The function 08H of INT 21H can be used to read characters without
echo.
• Hence, we can read the characters of the password using function 08H.
• To display different messages on the screen, we can use function 09H of
INT 21H.
• In following program, the macro disp using function 09H is used to
display different messages on the screen with macro variable msg.
• After reading password, we can validate password by checking length of
entered password with original password.
• If the lengths of both the password are same, then we can compare both
password character by character.
• The following program is written to validate password entered by the
user.
Program:
1
msg_err db 10,13,'Sorry,try again $',10,13
msg_sucdb 10,13,'Password is validate$', 10, 13
msg_aga db 10,13,'Sorry your turn is Over $',10,13
.code
Mov ax,@data ;lnitialise data segment
mov ds,ax
next_tr:
disp msg_ent ;Display message
mov cl,0
mov count_d,ct ;Set length of Password (8 Character long)
mov di,offset pass_d ;lnitialize memory poi,nter
up: mov ah,08h ;Read password through keyboard without echoing
int 21h ;Using function 08H of 1Nl 21H
cmp al,0dh ;Check if end of Character i.e. Carriage return
je exit ;If yes then stop reading characters
mov [di],al
inc di
inc count_d ; Count Characters
movah,02h ; Display'*' instead of character to hide password
mov dl,'*' ; Using function 02H of Int21H
int 21h
jmp up
exit: mov al,count_d ;Compare password by length
cmp al,count_s
jne next_try ;If length are not same, then show error message
lea si,pass_s ;Else
lea di,pass_d
next char: ;Compare passwords Character by Character
mov al,[si]
cmp al,[di]
jne next_try ; If character are not equal, then try again
inc si
inc di
dec count_d
jnz next_char ;If found valid
disp msg_suc ;display success message
2
jmp exit_1 ;else
next_try:
3
Experiment No. 2
Theory:
• We can use the function 02H of BIOS INT 16H to read the status of
Keyboard keys such as Alt, Ctrl, Num-Lock etc.
• To display different messages on the screen, we can use function 09H of
INT 21H.
• In following program, the macro disp using function 09H is used to
display different messages on the screen with macro variable msg.
Program:
4
msg9 db cr,if,'ALT key is Pressed$',cr,lf
msg10db cr,lf,'CtRL key is pressed$',cr,lf
msg11 db cr,Lf,'Left SHIFT is pressed$',cr,lf
msg12 db cr,lf,'Right SHIFT is pressed$',cr,lf
.code
mov aX,@data
mov ds,ax
mov ah,02H ;Function to read Keyboard
int 16h ;Status
disp msg
rcl al, 1 ;Check Status of INSERT Key
jnc dn
disp msg1
jmp ab
dn:
disp msg2
ab: rcl al,1 ;Check CAPS LOCKkey
jnc dn1
disp msg3
jmp ab1
dn1:
disp msg4
ab1: rcl al,1 ;Check NUM LOCKkey
jnc dn2
disp msg5
jmp ab2
dn2:
disp msg6
ab2: rcl al,1 ;Check SCROLL LOCKkey
jnc dn3
disp msg7
jmp ab3
dn3:
disp msg8
ab3: rcl al,1 ;Check ALT Key
jne dn4
disp msg9
dn4: rcl al,1 ;Check CTRLkey
jnc dn5
5
disp msg10 ;Check LEFTSHIFT key
dn5: rcl al,1
jnc dn6
disp msg11
dn6: rcl al,1 ;Check RIGHT SHIFT key
jnc dn7
disp msg12
dn7:
mov ah,4ch ;Exit to DOS
int 21h
ends ;Segment END
6
Experiment No. 3
Theory:
• To simulate CLS command of the DOS, we can use function 06H of INT
10H to Scroll Up Screen with screen coordinate for text i.e. 25 rows and
80 columns.
• With this, the function 02H ofINT 10H is used to set cursor position at
right-top position of the screen.
Program:
7
Experiment No. 4
Title: Program to simulate DEL (Delete file) and REN (Rename file)
command
Theory:
Program:
8
movah,62h ;Get PSP address
int 21h
moves,bx
mov si, offset f_name .Read Command Tail from PSP
mov di,81h ;Store it in file name variable
up: mov al,es:[di]
cmp al,20h
jz next1
cmp al,0dh
jz next
mov [si],al
inc si
next1: inc di
dec bl
jnz up
next:
Movah,41h ;Function to deLete file
mov dx,offset f_name
int 21h
jnc done
prompt msg2
jmp done1
done:
prompt msg3 ;Exit to DOS
done1:
mov ah,4ch
mov al,00
int 21h
end
9
2. Program to simulate REN (Rename file) command.
Program:
10
mov si,offset file_s ;Read Command Tale from PSP
mov di,82h ; Read Source file name
up: moval,es:[di]
cmp al,20h
jz next
mov [si],al
inc si
inc di
jnz up
ext:
mov si,offset file_d ;Read destination file name
up1: inc di
moval,es:[di]
cmp al,0dh
jz endf
mov [si],al
inc si
jmp up1
endf:
pop es
movah,56h ;function 56h to rename file
lea dx, file_s ;offset of source file
lea di,file_d ;offset of destination file
int 21h
jnc succ ;if no carry then rename successful
error:
disp msg1 ;display message 1
jmp exit
succ:
disp msg2 ;display message 2
11
exit:
mov ah,4ch ;exit to DOS
mov al,00h
int 21h
ends ;Segment end
end ;Program end
12
Experiment No. 5
Title: Program to display the attribute and date / time of any file.
Theory:
Program:
13
mov ds,ax
disp msg ;Display message
mov si,offset file ;Read file name
movah,01h ;Function to read character
int 21h
cmp al,0dh
je done
mov [si],al
inc si
jmp up
done:
mov ah,43h ;Function to read attribute of file
mov al,0 ;Get file attribute
mov dx,offset file
int 21h
jc exit ;Check attribute if success
mov ax,cx ;Check for READ ONLY
ror ax,1
jnc hide
disp msg_r
hide: ror ax,1 ;Check for HIDDEN
jnc sys
disp msg_h
sys: ror ax,1 ;Check for SYSTEM
jnc dir
disp msg_s
dir: ror ax,1 ;Check for DIRECTORY
ror ax,1
jnc arch
disp msg_d
arch: ror ax,1 ;Check for ARCHIVE
jnc exit_1
14
disp msg_a
jmp exit_1
exit:
disp msg_1
exit_1:
mov ah,4ch ;Exit to DOS
int 21h
ends ;Segment END
end ;Program END
• The function 57H of INT 2IH can be used to get or set date and time of
the specified file whose handle in BXregister.
• Before using function 57H of INT 21H, the file must be opened using
3DH function of INT 2IH who’s offset in DXregister.
• The Hex to ASCII conversion macro is used to display date and time in
decimal format as function 57H returns date and time in hexadecimal
format.
• The function 01H of INT 2IH is used to read file name through keyboard.
Program:
15
push dx
push si
movcx,00h
mov bx,0ah
mov ax,num
rpt:
mov dx,00
div bx
add dl,'0'
push dx
inc cx
cmp ax,0ah
jge rpt
add al,'0'
mov [si],al
rpt3: pop ax
inc si
mov [si],al
loop rpt3
inc si
moval, ‘$’
mov [si], al
pop si
pop dx
pop cx
pop bx
pop ax
endm
;Macro to display messages
push ax
16
push dx
movah,09h
lea dx,msg
int 21h
pop dx
pop ax
endm
.data
file db 13 dup(0)
msg db 10,13,'Enter the File Name: $',10,13
msg_err db 10,13,'File not found ........ $',10,13
nl db 10,13,' $',10,13
dash db ‘-$’
dot db ':$'
space db ' $'
am db ' am$'
pm db ' pm$'
handle dw ?
date dw 0
time dw 0
num dw 0
result db 10 dup('$')
.code
mov ax,@data ;Initialise data segment
mov ds,ax
disp msg ;Display message
mov si,offset file
up: ;Read File name
movah,01h ;Function to read character
int 21h
17
cmp al,0dh
je done
mov [si],al
inc si
jmp up
done:
movah,3dh ;Function to Open file
mov al,0
mov dx,offset file
int 21h
jnc next
jmp exit
next:
mov handle,ax
movah,57h ;Get Date and Time of
mov al,0 ;Specified File
mov bx,handle
int 21h
jnc next_1
jmp exit
next_1:
mov date,dx
mov time,cx
disp nl
movax,date ;Show DATE
and ax,1fh
mov num,ax
mov si,offset result
hex2asc num
disp result
18
disp dash
movax,date ;Show Month
mov cl,5
shr ax,cl
and ax,0fh
mov num,ax
mov si,offset result
hex2asc num
disp result
disp dash
movax,date ;Show Year
mov cl,9
shr ax,cl
and ax,7fh
add ax,1980
mov num,ax
mov si,offset result
hex2asc num
disp result
disp space
movax,time ;Show HOUR
mov cl,0bh
shr ax,cl
cmp ax,12
jle dn
sub ax,12
dn: mov num,ax
mov si,offset result
hex2asc num
disp result
19
disp dot
movax,time ;Show MINUTE
mov cl,05
shr ax,cl
and ax,1fh
mov num,ax
mov si,offset result
hex2asc num
disp result
movax,time ;Show AM/ PM
mov cl,0bh
shr ax,cl
cmp ax,12
jle dn1
disp pm
jmp exit_1
dn1:disp am
jmp exit_1
exit:
disp msg_err
exit_1:
movah,4ch
int 21h
ends
end
20
Experiment No. 6
Theory:
• Same as that of the program for DEL command simulation, we can use
PSP to get the command line argument.
• The function 39H of INT 2lH can be used to make the directory in the
current directory.
• The name of the directory can be read through keyboard using function
0lH of INT 2lH.
Program:
21
msg1 db 'Directory Not Present..$', 10, 13
22
disp msg2
exit:
movah,4ch ;Exit to DOS
moval,00h
int 21h
end start
end
• Same as that of the program for DEL command simulation, we can use
PSP to get the command line argument.
• The function 3AH of INT 21H can be used to remove or delete directory
in the current directory.
• The name of the directory can be read through keyboard using function
0lH of INT 21H.
Program:
23
jmp begin
msgl db 'Directory Not Present.. $',10,13
msg2 db 'Directory Removed Successfully ... $'
dir_name db 13 dup(0)
begin:
movax,cs ;Set DSto CS
mov ds,ax
movah,62h ;Get PSP address
int 21h
moves,bx
mov si,offset dir_name ;Read Command Tale from PSP
mov di,8lh ;i.e. file name to be deleted
up: moval,es:[di]
cmp al,20h
jz next1
cmp al,0dh
jz next
mov [si],al
inc si
next1: inc di
dec bl
jnz up
next:
movah,3ah ;Function to delete directory
mov dx,offset dir_name
int 21h
jnc succ ;if no carry, then success
error:
disp msg1 ;Display message1
jmp exit
24
succ: ;Display message2
disp msg2
exit:
movah,4ch ;Exit to DOS
moval,00h
int 21h
end start
end
25
Experiment No. 7
Theory:
Program:
26
int 21h
cmp al,0dh
je done
mov [si],al
inc si
jmp up
done:
movah,3bh ; Function to Change Directory
mov dx,offset path
int 21h
jnc exit
disp msg_err
exit:
mov ah,4ch ;Exit to DOS
int 21h
ends ;Segment END
end ;Program END
• The function 19H of INT 21H can be used to get current disk drive and
the function 47h of INT 21H can be used to get the current path or in
other word we can say 'Present working directory.
Program:
;BUILD - TLINKpwd
;RUN - pwd
.model small
.data
path_name db 64 dup('$')
msg db 'Current Directory :$'
char db 0
msg1 db 'Path not found $'
27
.code
mov ax,@data ;Initialise data
mov ds,ax
movah,09h
mov dx,offset msg
int 21h
mov ah,19h ;Request to get Current Drive
int 21h
cmp al,00 ;IF AL=00 then A:
mov char,al
je a_drv
cmp al,01 ;If AL=01 then B:
mov char,al
je b_drv
cmp al,02 ;If AL=02 then C:
mov char,al
je c_drv
cmp al,03 ;If AL=03 then 0:
mov char,al
je d_drv
cmp al,04 ;If AL-04 then E:
mov char,al
je e_drv
cmp al,5 ;If AL-05 then F:
mov char,al
je f_drv
cmp al,6 ;If AL-06 then G:
mov char,al
je g_drv
jmp exit
28
a_drv:
movah,02h ;DispLay A
mov dl,'A'
int 21h
jmp dn
b_drv:
movah,02h ;DispLay B
mov dl,'B'
int 21h
jmp dn
c_drv:
movah,02h ;Display C
mov dl,'C'
int 21h
jmp dn
d_drv:
movah,02h ;Display D
mov dl,'D'
int 21h
jmp dn
e_drv:
movah,02h
mov dl,'E' ;Display E
int 21h
jmp dn
f_drv:
movah,2
mov dl,'F'’ ;Display F
int 21h
jmp dn
29
g_drv: mov ah,2 ;Display G
mov dl,'G'
int 21h
dn:
movah,02h ;Display :
mov dl,':'
int 21h
movah,02h ;Display \
mov dl,'\'
int 21h
movah,47h ;Function to get Current
mov dl,0
mov si,offset path_name
int 21h
jc exit1
movah,09h
mov dx,offset path_name
int 21h
jmp exit
exit1: mov ah,9 ;Display Current Path
mov dx,offset msg1
int 21h
exit:
movah,4ch ;Exit to DOS
int 21h
ends
end
30
Experiment No. 8
Title: Program to display the status of Flag register and Machine Status
Word register of 286 on the screen.
Theory:
• The content of flag register cannot be read directory into any general
purpose register.
• So,using PUSHF and POP instruction we can read flag register in to any
general purpose register.
• The LMSW instruction can be used to read MSW of286.
• The directive .286p is required to build the instruction set of 286.
Program:
;ASSEMBLE- TASMflag286
;BUILD – TUNKflag286
;RUN - flag286
.model small
.286p
disp macro msg ;Macro to display string
push ax
push dx
movah,09h
mov dx,offset msg
int 21h
pop dx
pop ax
endm
.data
flag dw ?
carry_s db 10,13,'Carry flag is Set$',10,13
carry_r db 10,13,'Carry flag is reset$',10,13
parity_o db 10,13,'Parity is ODD$',10, 13
parity_e db 10,13,'Parity is EVEN$',10, 13
31
a_carry_s db 10,13,'Auxilary Carry is Set$', 10, 13
a_carry_r db 10,13,'Auxilary Carry is reset$', 10, 13
sign_s db 10,13,'Sign flaq is Set$', 10, 13
sign_r db 10,13,'Sign flag is reset$', 10, 13
zero_s db 10,13,'Zero flag is set$',10,13
zero_r db 10,13,'Zero flag is reset$', 10, 13
int_s db 10,13,'Interrupt is Set$',10,13
int_r db 10,13,'Interrupt is Reset$', 10, 13
trap_s db 10,13,'Trap flag is set$', 10, 13
trap_r db 10,13,'Trap flag is reset$',10,13
dir_s db 10,13,'Direction flag is set$', 10, 13
dir_r db 10,13,'Direction flag is Reset$', 10, 13
of_s db 10,13,'Overflow flag is Set$',10,13
of_r db 10,13,'Overflow flag is reset$', 10, 13
iopl db 10, 13,'IOPL is : $'
zer db '0$',10,13
one db '1$',10,13
two db '2$'10,13
three db '3$',10,13
nt_s 10,13,'Nested Task Flag is Set$', 10, 13
nt_r db 10,13,'Nested Task Flag is Reset$', 10, 13
prt_e db 10,13,'Protection Enable ... $', 10, 13
prt_d db 10,13,'Protection Diable... $', 10, 13
cop_p db 10,13,'Co-processor Present...$', 10, 13
cop_a db 10,13,'Co-Processor Absent .... $', 10, 13
emu_p db 10,13,'Co-processor Software Present$', 10,13
emu_a db 10, 13,'Co-processor Software Absent$', 10, 13
task_e db 10,13,'Task Switch is enabled$', 10, 13
task_d , db 10,13,'Task Switch is disabled$', 10, 13
.code
32
movax,@data ;Initialize data segment
mov ds,ax
pushf
pop ax
ror ax,1 ;Check carry flag
jnc dn ;Display carry flag status
disp carry_s
jmp pari
dn: disp carry_r
pari: ror ax,1
ror ax,1 ;Check parity flag
jnc dn1 , ;display parity flag status
disp parity_o
jmp a_c
dn1: disp parity_e
a_c: ror ax,1 ;Check auxiliary carry flag
ror ax,1 ;Display auxiliary carry flag status
jnc dn2
disp a_carry_s
jmp zero
dn2: disp a_carry_r
zero: ror ax,1 ;Check Zero flag
ror ax,1 ;Display Zero flag status
jnc dn3
disp zero_s
jmp sign
dn3: disp zero_r
sign: ror ax,1 ;Check Sign flag
jnc dn4 ;Display Sign Flag status
disp sign_s
33
jmp trap
dn4: disp sign_r
trap: ror ax,1 ;Check trap flag
jnc dn5 ;Display trap flag status
disp trap_s
jmp inte
dn5: disp trap_r
inte: ror ax,1 ;Check interrupt flag
jnc dn6 ;Display interrupt flag status
disp int_s
jmp dir
dn6: disp int_r
dir: ror ax,1 ;Check direction flag
jnc dn7 ;Display direction flag status
disp dir_s
jmp over
dn7: disp dir_r
over: ror ax,1 ;Check Overflow flag
jnc dn8 ;Display overflow flag status
disp of,s
jmp iop
dn8: disp of_r
iop: disp iopl ;Check IOPL
push ax ;Display IOPL level
and aX,03h
cmp al,0
jne ones
disp zer
jmp exit
ones: cmp al, 1
34
jne twos
disp one
jmp exit
twos: cmp al,2
jne threes
disp two
jmp exit
threes: cmp al,3
jne exit
disp three
exit: pop ax
ror ax,1 ;Check Nested Task if Any
ror ax,1
ror ax,1 ;Display the status of nested task
jnc nt
disp nt_s
jmp msw
nt: disp_nt_r
msw:
lmsw ax ;read MSWof 80286
ror ax,1 ;Check Protection Mode
jnc dn10 ;Display the status of Protection Mode
disp prt_e
jmp mon
dn10: disp prt_d
mon: ror ax,1 ;Check the presence of Co-processor
jnc dn11 ;Display the status of Co-processor
disp cop_p
jmp emu
dnll: disp cop_a
35
emu: ror ax,1 ;Check the emulation Co-processor S/W
jnc dn12 ;Display the status
disp emu_p
disp emu_p
jmp task
dn12: disp emu_a ;Check the status of task switch
task: ror ax,1 ;Display the status
jnc dn13
disp task_e
jmp terminate
dn13: disp task_d
terminate:
movah,4ch ;Exit to DOS
int 21h
ends
end
36
Experiment No. 9
Title: Program to display the status of Flag register and Machine Status
Word register of 386 on the screen.
Theory:
• The content of flag register cannot be read directory into any general
purpose register.
• So, using PUSHFD and POP instruction we can read flag register in to
any general purpose register.
• Instead of LMSW instruction in 286, CRO is nothing but 32 bit MSW in
386, so MOV EAX,
• CRO instruction can be used to read MSW of 386.
• The directive .386 is required to build the instruction set of 386.
• So, we can check paging memory management is either enable or disable.
Program:
;ASSEMBlE – TASMflag386
;BUIlD - TUNK flag386
;RUN - flag386
.model small
.386p
disp macro msg ; Macro to diaply string
push ax
push dx
movah,09h
mov dx,offset msg
int 21h
pop dx
pop ax
endm
.data
flags dd ?
carry_s db 10,13,'Carry flag is Set$',10,13
carry_r db 10,13,'Carry flag is reset$', 10, 13
37
parity_o db 10,13,'Parity is 000$',10,13
parity_e db 10, 13,'Parity is EVEN$',10, 13
a_carry_s db 10,13,'Auxilary Carry is Set$', 10, 13
a_carry_r db 10,13,'Auxilary Carry is reset$', 10, 13
sign_s db 10,13,'Sign flag is Set$', 10, 13
sign_r db 10,13,'Sign flag is reset$', 10, 13
zero_s db 10,13,'Zero flag is set$', 10, 13
zero_r db 10,13,'Zero flag is reset$', 10, 13
int_s db 10,13,'Interrupt is Set$', 10, 13
int_r db 10, 13,'Interrupt is Reset$',10,13
trap_s db 10,13,'Trap flag is set$', 10, 13
trap_r db 10,13,'Trap flag is reset$', 10, 13
dir_s db 10,13,'Oirection flag is set$', 10, 13
dir_r db 10,13,'Oirection flag is Reset$', 10, 13
of_s db 10,13,'Overflow flag is Set$',10,13
of_r db 10,13,'Overflow flag is reset$', 10, 13
iopl db 10,13,'IOPL is : $'
zer db '0$',10,13
one db '1$',10,13
two db '2$',10,13
three db '3$',10,13
nt_s db 10,13,'Nested Task Flag is Set$', 10, 13
nt_r db 10,13,'Nested Task Flag is Reset$', 10, 13
prt_e db 10,13,'Protection Enable... $', 10, 13
prt_d db 10,13,'Protection Diable... $', 10, 13
cop_p db 10,13,'Co-ptocessor Present...$', 10, 13
cop_a db 10, 13,'Co-Processor Absent.. ..$', 10, 13
emu_p db 10,13,'Co-processor Software Present$', 10, 13
emu_a db 10, 13,'Co-processor Software Absent$', 10, 13
task_e db 10,13,'Task Switch is enabled$', 10, 13
38
task_d db 10,13,'Task Switch is disabled$', 10, 13
res_e db 10,13,'Resume Flag is Enable$', 10, 13
res_d db 10,13,'Resume Flag is Oisable$', 10, 13
vm_e db 10,13,'Virtual 8086 mode Enable$', 10, 13
vm_d db 10,13,'Virtual 8086 Mode Oisable$', 10, 13
pg_e db 10,13,'Paging Enable$', 10, 13
pg_d db 10,13,'Paging Oisable$', 10, 13
.code
mov ax,@data ;Initialize data segment
mov ds,ax
pushfd
pop eax
ror eax,1 ;Check carry flag
jnc dn ;Display carry flag status
disp carry_s
jmp pari
dn: disp carry_r
pari: ror eax,1
ror eax,1 ;Check parity flag
jnc dn1 ;display parity flag status
disp parity_o
jmp a_c
dnl: disp parity_e
a_c: ror eax,1 ;Check auxilary carry flag
ror eax,1 ;Display auxilary carry flag status
jnc dn2
disp a_carry_s
jmp zero
dn2: disp a_carry_r
zero: ror eax,1 ;Check Zero flag
39
ror eax,1 ;Display Zero flag status
jnc dn3
disp zero_s
jmp sign
dn3: disp zero_r
sign: ror eax,1 ;Check Sign flag
jnc dn4 ;Display Sign Flag status
disp sign_s
jmp trap
dn4: disp sign_r
trap: ror eax,1 ;Check trap flag
jnc dn5 ;Display trap flag status
disp trap_s
jmp inte
dn5: disp trap_r
inte: ror eax,1 ;Check interrupt flag
jnc dn6 ;Display interrupt flag status
disp int_s
jmp dir
dn6: disp int_r
dir: ror eax,1 ;Check direction flag
jnc dn7 ;Display direction flag status
disp dir_s
jmp over
dn7: disp dir_r
lover: ror eax,1 ;Check Overflow flag
jnc dn8 ;Display overflow flag status
disp of_s
jmp iop
dn8: disp of_r
40
iop: disp iopl ;Check IOPL
push eax ;Display IOPL level
and eax,03h
cmp al,0
jne ones
disp zer
jmp exit
ones: cmp al,1
jne twos
disp one
jmp exit
twos: cmp al,2
jne threes
disp two
jmp exit
threes:cmp al,3
jne exit
disp three
exit: pop eax
ror eax,1 ;Check Nested Task if Any
ror eax,1
ror eax,1 ;Display the status of nested task
jnc nt
disp nt_s
jmp m1
nt: disp nt_r
m1: ror eax,1 ;Check Resume Flag
ror eax,1 ;Displau status of resume flag
jnc m2
disp res_e
41
jmp vm
m2: disp res_d
vm: ror eax,1 ;Check virtual 8086 mode
jnc m3 ; Display status
disp vm_e
jmp msw
m3: disp vm_d
msw:
moveax,cr0 ;read MSWof 80386
ror eax,1 ;Check Protection Mode
jnc dn10 ;Display the status of Protection Mode
disp prt_e
jmp mon
dn10: disp prt_d
mon: ror eax,1 ;Check the presence of Co
jnc dn11 ;Display the status of Co
disp cop_p
jmp emu
dn11: disp cop_a
emu: ror eax,1 ;Check the emulation Co-processor S/W
jnc dn12 ;Display the status
disp emu_p
jmp task
dn12: disp emlca
task: ror eax,1 ;Check the status of task switch
jnc dn13 ;Display the status
disp task_e
jmp pg
dn13: disp task_d
pg: mov eax,cr0
42
rol eax,1 ;Check Paging
jnc pgl ;Display status
disp pg_e
jmp terminate
pg1: disp pg_d
terminate: ;Exit to DOS
movah,4ch
int 21h
ends
end
43
Experiment No. 10
Theory:
• The CPUID instruction takes no parameters as CPUID implicitly uses the
EAX register to determine the main category of information returned. In
Intel's more recent terminology, this is called the CPUID leaf.
• CPUID should be called with EAX = 0 first, as this will return in the
EAX register the highest EAX calling parameter (leaf) that the CPU
supports.
• To obtain extended function information CPUID should be called with
the most significant bit of EAX set. To determine the highest extended
function calling parameter, call CPUID with EAX = 80000000h.
• EAX=0: Get vendor ID : This returns the CPU's manufacturer ID string –
a twelve-character ASCII string stored in EBX, EDX, ECX.
• The highest basic calling parameter (largest value that EAX can be set to
before calling CPUID) is returned in EAX.
Program:
.data
s0:
.asciz "Largest basic function number supported: %i\n"
s1:
.asciz "Vendor ID: %.12s\n"
.text
.align32
.globl_start
pushq %rbp
pushq %rbx
movq %rsp,%rbp
subq $16,%rsp
xorl %eax,%eax
44
cpuid
movl %ebx,0(%rsp)
movl %edx,4(%rsp)
movl %ecx,8(%rsp)
movq $s0,%rdi
movl %eax,%esi
xorb %al,%al
xorb %al,%al
call printf
movq%rbp,%rsp
popq %rbx
popq %rbp
movl $1,%eax
int $0x80
45