組合語言 實現在指定字串中搜尋字元 A

2021-07-28 23:05:40 字數 1008 閱讀 3315

我也不知道我以前怎麼會寫這種東西的,留個紀念…

;用串操作指令設計程式,實現在指定字串中搜尋字元『a』,

;若該字條串中有字元』a』,

;則將第乙個』a』字元在該字串中的位置記錄在bx暫存器中,

;若不包含,則使bx=0ffffh。

;在程式開始查詢指定字元前要求在螢幕上輸出提示資訊:

;the program is running!查詢結束後輸出資訊:the program is over!

datas segment

string db 'cdafx246hk'

no dw 10

false dw 0ffffh

str1 db 'the program is running!$'

str2 db 0dh,0ah,'the program is over!$'

datas ends

stacks segment

dw 20 dup(?)

stacks ends

codes segment

assume cs:codes,ds:datas,ss:stacks

start:

mov ax,datas

mov ds,ax

mov es,ax

lea dx,str1

mov ah,09h

int 21h

mov bx,false

lea di,string

mov al,'a'

mov cx,no

repne scasb

cmp cx,0

je count

dec di

mov bx,di

count:

lea dx,str2

mov ah,09h

int 21h

mov ah,4ch

int 21h

codes ends

end start

組合語言實現字串的輸入,輸出

1.了解 int 21h 的09h 號中斷呼叫 輸出字串 lea dx,字串的開頭 或 mov dx,offset字串的開頭 mov ah,09h int 21h 2.在定義字串的時候要在末尾加上 作為字串的結束標誌。3.了解 int 21h 的0ah 號中斷呼叫 輸入字串 lea dx,字串的開頭...

用組合語言實現在210實現流水燈

用組合語言實現在210實現流水燈 參考朱有鵬arm裸機程式設計 1 makefile的解釋 1 首先簡單的解釋一下這個的makefile 目標檔案 led.bin 依賴的檔案led.o 也就是led.bin不存在的時候,或者led.o更新的時候,會執行這個makefile 那麼就執行後面的命令 第二...

計算字串長度 組合語言

設有一字串存放在以 buf 為首址的資料區中,其最後一字元 作為結束標誌,計算該字串的長度並輸出 datas segment buf db 20,20 dup datas ends stacks segment stacks ends codes segment assume cs codes,ds...