組合語言-偏移地址綜合應用-雙重迴圈實現
阿新 • • 發佈:2018-11-27
要求:
db '1.helloworld '
db '2.apple '
db '3.stevejobs '
db '4.macbook '
將上述內容從第三個資料開始向後三個都變成大寫,結果如下:
db '1.HELloworld '
db '2.APPle '
db '3.STEvejobs '
db '4.MACbook '
程式碼實現:
assume cs:code,ds:data
data segment
db '1.helloworld '
db '2.apple '
db '3.stevejobs '
db '4.macbook '
data ends
stack segment
dw 0,0,0,0,0,0,0,0
dw 0,0,0,0,0,0,0,0
stack ends
code segment
start:
mov ax,stack
mov ss,ax
mov sp,32
mov ax,data
mov ds,ax
mov es,ax
mov cx,4
mov bx,0
mov si,2
upLetter:
push cx ;壓棧儲存上一次迴圈資料
push si
mov cx,3
upRow:
mov dl,ds:[bx+si]
and dl,11011111B
mov es:[bx+si],dl
inc si
loop upRow
pop si ;出棧,逆向彈出
pop cx
add bx,16
loop upLetter
mov ax,4c00h
int 21h
code ends
end start