程式設計:在螢幕中間分別顯式綠色、綠底紅色、白底藍色的字串『welcome to masm!』
思路:
首先分別求出綠色、綠地紅色、白底藍色所對應的屬性值。分別為02h
,24h
,71h
。
將』welcome to masm!'以及上述三個屬性值分別寫入記憶體中的資料段。
定位螢幕中間的記憶體位址,由題知,每一頁25行,每行80個字元,160個位元組。我們需要將三行內容顯示在螢幕**,故我們要從第12行的**開始顯示,12行**的位址為:b8000+(11×160+64)=b8720h,我們將b872作為目標段位址。
定義乙個大迴圈,迴圈3次,列印三條語句。其中es
定位目標段位址,di
定位目標偏移位址,si
定位資料來源的偏移位址。
定義兩個小迴圈,巢狀在大迴圈中,第乙個小迴圈負責將字元從資料段拷貝至視訊記憶體,第二個小迴圈負責將字元的屬性從資料段拷貝至視訊記憶體。
**:
assume cs:codesg,ds:datasg,ss:stacksg
datasg segment
db 'welcome to masm!'
db 02h,
24h,
71hdatasg ends
stacksg segment
dw 8
dup(0)
stacksg ends
codesg segment
start:
mov ax,datasg
mov ds,ax
mov ax,stacksg
mov ss,ax
mov sp,
10h
mov bx,
0 mov ax,
0b872h
mov cx,
3s0:
push cx
push ax
push bx
mov es,ax
mov si,
0 mov di,
0 mov cx,
10hs1:
mov al,ds:
[si]
mov es:
[di]
,al inc si
add di,
2 loop s1
mov di,
1 pop bx
mov al,ds:
10h[bx]
inc bx
mov cx,
10hs2:
mov es:
[di]
,al add di,
2 loop s2
pop ax
add ax,
0ah pop cx
loop s0
mov ax,
4c00h
int21hcodesg ends
end start
執行結果:
王爽 組合語言 實驗9
assume cs code data segment db welcome to masm db 00000010b,00100100b,01110001b data ends code segment start mov ax,data mov ds,ax mov si,07c0h 臨時,可調整...
《組合語言》實驗 實驗
注意 db定義位元組型別變數,乙個位元組資料百佔1個位元組單度元,讀完乙個,偏移量加1 dw定義字型別變問量,乙個字資料佔2個位元組單元,讀完乙個,權偏移量加2 dd定義雙字型別變數版,乙個雙字資料佔4個位元組單元,讀完乙個,權偏移量加4 一開始用了乙個暫存器表示所有項,但是後來發現四個資料佔的位元...
組合語言實驗1 2
小寫字母變為大寫字母 data segment notic db please input the word 0ah,0dh data ends code segment assume cs code,ds data start mov ax,data mov ds,ax 填入ds mov cx,1...