這本書購於2015.11.30,我大概從2016.3月開始讀,歷時大概三個月,我們學校開《微機原理與匯編語言》這門課,不過讓人感覺很不爽,課本一開始就丟給你一堆東西,意欲讓你記住這一大堆東西,然后開始編程,我對編程語言的學習方面要求比較高,所以開始讀這本王爽老師寫的匯編語言,目前為止,這本書給我的感覺就是,你能學到很多底層的東西,尤其是像鍵盤的讀寫原理,屏幕的顯示,特別是對內存的操作和管理,不像課本上給你一個中斷讓你就能顯示字符之類的,它會一步一步教你怎么把要顯示的東西寫到顯存里面,這本書顯得比較淺顯易懂,讓人感覺不錯,特別是讀了這本書再去看那些難度較高的匯編代碼及微機原理,效率會高很多,下面是我讀這本書的過程中對書中檢測點的解答,僅代表個人觀點。
第一章 檢測點1.1 1) 13 (8kb = 8 * 1024 = 2^13) 2) 1024 0 1023 3) 8*1024 1024 (1 byte = 8 bit,計算機以byte為存儲單位) 4) 1024^3 1024^2 1024 5) 2^6 1 2^4 2^2 (kb = 2^10 Mb = 2^20 Gb = 2^30) 6) 1 1 2 2 4 7) 512 256 (8086的寄存器為16位寄存器,一次可以讀取兩個字節,80386為32位寄存器) 8) 二進制
第二章 檢測點2.1 1) AX = F4A3h AX = 31A3h AX = 3123h AX = 6246h BX = 826Ch CX = 6246h AX = 826Ch AX = 04D8h AX = 0482h AX = 6C82h AX = D882h AX = D888h AX = D810h AX = 6246h 2) mov ax,2 add ax,ax add ax,ax add ax,ax 檢測點2.2 1)00010h 1000fh (0001h+0000h 0001h+ffffh) 2)1001h 2000h (偏移地址的范圍為0000-ffff,內存單元=段地址*16+偏移地址,當偏移地址最小時,段地址最大,偏移地址最大時,段地址最小) 檢測點2.3 4次修改IP,最后IP為0
第三章 檢測點3.1 1) mov ax,1 mov ds,ax mov ax,[1000] AX = 2662h mov bx,[1001] BX = E626h mov ax,bx AX = E626h mov ax,[0000] AX = 2662h mov bx,[0002] BX = D6E6h add ax,bx AX = FD48h add ax,[0004] AX = 2C14h mov ax,0 AX = 0000h mov al,[0002] AX = 00E6h mov bx,0 BX = 0000h mov bl,[000C] BX = 0026h add al,bl AX = 000Ch 2) CS = 2000h,IP = 0,DS = 1000h mov ax,6622h AX = 6622h jmp 0ff0:0100h CS = 0ff0 IP = 0100h mov ax,2000h AX = 2000h mov ds,ax DS = 2000h mov ax,[0008] AX = C389h mov ax,[0002] AX = EA66h mov ax,6622h AX = 6622h 數據和程序表達上沒有區別,只跟存儲的地方有關,存在數據段中即為數據,存在程序段中就是程序 檢測點3.2 1) mov ax,2000h mov ss,ax mov sp,10h 2) mov ax,1000h mov ss,ax mov sp,0
第六章 檢測點6.1 1) mov cs:[bx],ax 2) cs 26或1ah pop cs:[bx]
第九章 檢測點9.1 1) db 8 dup (0) 2) offset start cs 3) CS = 0006h IP = 00BE 檢測點9.2 mov cl,[bx] mov ch,0 jcxz ok inc bx 檢測點9.3 inc cx (因為loop s執行時是先將cx減一再與0比較)
第十章 檢測點10.1 1000 0000 檢測點10.2 ax = 3 檢測點10.3 ax = 1006 檢測點10.4 ax = 9 (call ax時將IPpush到棧中,也就是push 3) 檢測點10.5 1) ax = 3 2) ax = 0001 bx = 0000
第十一章 檢測點11.1 1 1 0 1 1 0 1 1 0 1 1 0 0 0 0 0 1 0 0 1 0 檢測點11.2 0 0 0 1 1 0 0 0 1 1 0 0 1 0 0 0 0 1 0 0 1 1 0 1 1
1 1 0 1 1
1 0 0 0 0
1 0 0 0 0
0 1 1 0 1
檢測點11.3
1)
jna s0
jna s0
2)
jb s0
jb s0
檢測點11.4
ax = 0871h
檢測點12.1 1) 039D:0016 2) 0000:[4N] 0000:[4N+2]
檢測點13.1 assume cs:code,ds:data data segment db 'conversation',0 data ends code segment start: mov ax,cs mov ds,ax mov si,offset show mov ax,0 mov es,ax mov di,200h mov cx,offset showend-offset show cld rep movsb mov ax,0 mov es,ax mov word ptr es:[7ch*4],200h mov word ptr es:[7ch*4+2],0 mov ax,data mov ds,ax mov si,0 mov ax,0b800h mov es,ax mov di,12*160 s: cmp byte ptr [si],0 je ok mov al,[si] mov es:[di],al mov al,2 mov es:[di+1],al inc si add di,2 mov bx,offset s-offset ok int 7ch ok: mov ax,4c00h int 21h show: push bp mov bp,sp add [bp+2],bx pop bp iret showend:nop code ends end start 檢測點13.2 1) 錯誤,不能向BIOS中寫程序 2) 錯誤,19h中斷在操作系統以前,而DOS由操作系統控制即在操作系統以后
檢測點14.1 1) mov al,2 out 70h,al in al,71h 2) mov al,0 out 71h,al mov al,2 in 70h,al 檢測點14.2 在不考慮溢出的情況下: mov ax,__ mov bx,ax shl bx,1 mov cl,3 shl ax,cl add ax,bx
第十五章 檢測點15.1 1) pushf call dword ptr ds:[0] 2) 在中斷向量表中設置新的int9中斷入口地址的時候不讓其發生中斷,即 cli mov word ptr es:[9*4],offset int9 mov word ptr es:[9*4+2],cs sti 恢復中斷向量表int9的源地址時同理: cli push ds:[0] pop es:[9*4] push ds:[2] pop es:[9*4+2] sti
第十六章 檢測點16.1 a[si] b b 1 檢測點16.2 mov ax,data mov es,ax
第十七章 檢測點17.1 IF = 1 DI(disable interupt) IF = 0 EI(enable interupt) 當執行int16中斷時是從緩沖區中讀出字符,若緩沖區為空,則int16應該可以響應int9的中斷,故IF不一定為1