jump16 macro selector,offsetv
db 0eah
dw offsetv
dw selector
endm
ju***2 macro selector,offsetv
db 0eah
dw offsetv
dw 0
dw selector
endm
descriptor struc
limitl dw 0
basel dw 0
basem db 0
attributes dw 0
baseh db 0
descriptor ends
pdesc struc
limit dw 0
base dd 0
pdesc ends
datalen = 16
.386p
dseg segment use16
gdt label byte
dummy descriptor <>
;code32 descriptor <0ffffh,,,0cf98h,>
;code32_sel = 08h
;code16 descriptor <0ffffh,,,08f98h,>
;code16_sel = 10h
;datas descriptor <0ffffh,,10h,0c092h,>
;datas_sel = 18h
;datad descriptor <0ffffh,80a0h,0bh,0cf92h,>
;datad_sel = 20h
;stacks descriptor <0ffffh,0,0,8f92h,>
;stacks_sel = 28h
;normal descriptor <0ffffh,0,0,92h,0>
;normal_sel = 30h
;gdtlen = $-gdt
code32 descriptor <0ffffh,,,0cf98h,>
code32_sel = 08h
code16 descriptor <0ffffh,,,8f98h,>
code16_sel = 10h
datas descriptor <0ffffh,,10h,0c092h,>
datas_sel = 18h
datad descriptor <0ffffh,80a0h,0bh,0cf92h,>
datad_sel = 20h
stacks descriptor <0ffffh,0,0,8f92h,>
stacks_sel = 28h
normal descriptor <0ffffh,0,0,92h,0>
normal_sel = 30h
gdtlen = $-gdt
vgdtr pdesc
varss dw ?
dseg ends
cseg1 segment use16 'real'
assume cs:cseg1,ds:dseg
start:
mov ax,dseg
mov ds,ax
mov bx,16
mul bx
add ax,offset gdt
adc dx,0
mov word ptr vgdtr.base,ax
mov word ptr vgdtr.base+2,dx
mov ax,cseg2
mul bx
mov code32.basel,ax
mov code32.basem,dl
mov code32.baseh,dh
mov ax,cseg3
mul bx
mov code16.basel,ax
mov code16.basem,dl
mov code16.baseh,dh
mov ax,ss
mul bx
mov stacks.basel,ax
mov stacks.basem,dl
mov stacks.baseh,dh
mov varss,ss
lgdt qword ptr vgdtr
clicall ea20
mov eax,cr0
or eax,1
mov cr0,eax
jump16 code32_sel,
toreal:
mov ax,dseg
mov ds,ax
mov ss,varss
call da20
stimov ah,4ch
int 21h
ea20 proc
push ax
in al,92h
or al,2
out 92h,al
pop ax
retea20 endp
da20 proc
push ax
in al,92h
and al,0fdh
out 92h,al
pop ax
retda20 endp
cseg1 ends
cseg2 segment use32 'pm32'
assume cs:cseg2
spm32:
mov ax,stacks_sel
mov ss,ax
mov ax,datas_sel
mov ds,ax
mov ax,datad_sel
mov es,ax
xor esi,esi
xor edi,edi
mov ecx,datalen
cldnext:
lodsb
push ax
call toascii
mov ah,7
shl eax,16
pop ax
shr al,4
call toascii
mov ax,7
stosd
mov al,' '
stosw
loop next
ju***2 code16_sel,
toascii proc
and al,0fh
add al,90h
daaadc al,40h
daaret
toascii endp
code32len = $
cseg2 ends
cseg3 segment use16 'pm16'
assume cs:cseg3
spm16:
xor si,si
mov di, datalen*6
mov ah,7
mov cx,datalen
again:
lodsb
stosw
loop again
mov ax,normal_sel
mov ds,ax
mov es,ax
mov eax,cr0
and eax,0fffffffeh
mov cr0,eax
jump16 ,
cseg3 ends
end start
楊季文 80x86組合語言程式設計 例項一
jump macro selector,offsetv db 0eah dw offsetv dw selector endm echoch macro ascii mov ah,2 mov dl,ascii int 21h endm descriptor struc limitl dw 0 bas...
80x86組合語言 分類統計
組合語言的程式設計題!急 有100個學生成績,存放在以data為首址的位元組儲存單元中。試統計其中90 含90 以上的人數,60 90 含60 之間的人數,60以下的人數,分別存入max,middle,min三個變數中。15 分鐘前 做而論道 十七級 最快回答 assume ds qq,cs cc ...
組合語言 80x86定址方式
1 立即定址方式 立即定址方式中指令的運算元是8位或16位立即數,並直接出現在指令中。例如 mov al,10h 源運算元為立即定址 執行後al 10h mov ax,0a48h 源運算元為立即定址 執行後ax 0a48h 立即定址只能用於源運算元,不能用於目的運算元。2 暫存器定址方式 暫存器定址...