王爽《組合語言》第九章實驗9

2021-08-10 17:06:42 字數 1191 閱讀 5659

這個實驗的內容不是太麻煩,雙層的迴圈**前幾章有示例**,

實驗9內容如下:

我的**如下:

assume cs:codesg,ds:datasg

datasg segment

dw 0 ; 儲存外層的迴圈次數

db 2h ; 綠色字

db 24h ; 綠底紅字

db 80h ; 白底藍字

db 0c2h ;紅底綠字

db 'welcome to masm!'; 要顯示的內容

datasg ends

codesg segment

start: mov ax,datasg

mov ss,ax

mov ax,0b800h ;視訊記憶體基位址

mov ds,ax

mov cx,4 ; 迴圈次數

mov bp,2 ; 顏色的基位址

mov dx,3872 ; 儲存第一行字的起始位置,第12行33列

sout:mov ss:[0],cx

mov cx,16

mov bx,dx ; start position

mov si,6 ; start position of string

sin:mov al,ss:[si]

mov [bx],al

mov al,[bp]

mov [bx+1],al

add bx,2

inc si

loop sin

inc bp

add dx,160

mov cx,ss:[0]

loop sout

mov ax,4c00h

int 21h

codesg ends

end start

程式執行後,第一行的綠色字沒有顯示出來,這個我沒有找到原因,剩下的兩行顯示的都是正確的(後來又加了一行紅底綠字),下面是效果圖

王爽 組合語言 第九章實驗9

用單迴圈實現的.assume cs codesg,ds datasg datasg segment db welcome to masm db 02h,02h,02h,02h,02h,02h,02h,02h,42h,42h,42h,71h,71h,71h,71h,71h datasg ends co...

王爽 組合語言 第九章 實驗八

輸入程式 assume cs codesg codesg segment mov ax,4c00h int 21h start mov ax,0 s nop nopmov di,offset s mov si,offset s2 mov ax,cs si mov cs di ax s0 jmp sh...

組合語言 第九章 實驗

可以正常執行。分析,前面的程式都很簡單,沒啥問題,到了 mov ax,cs si mov cs di ax 這裡,由於s2處的jmp short s1指令jmp機器碼為eb,之後記錄的是跳轉的距離,這裡向上跳到s1處,所以jmp short s1只佔2個位元組,所以jmp short s1處的 就被...