當前位置:編程學習大全網 - 編程軟體 - 求匯編程序設計題解 已知內存BUF 緩沖區的內容為 A,5,D,7,8,編程顯示數字的個數

求匯編程序設計題解 已知內存BUF 緩沖區的內容為 A,5,D,7,8,編程顯示數字的個數

xor ebx ;清空ebx,用bl取字節,bh記錄數字個數

xor ecx ;ecx記錄循環次數

lea eax,BUF ;把BUF的首地址給eax

a1:

mov bl,dword ptr [eax] ;取字節開始

cmp bl,30h ;判斷ASCII是否小於0

jl a2 ;是的話跳轉

cmp bl,39h ;判斷ASCII是否大於9

jg a2 ;是的話跳轉

inc bh ;bl是數字,bh加1 ,inc指令是將bh+1的意思

a2:

inc eax ;指向下壹個字符

inc ecx

cmp ecx,4h ;判斷ecx是否大於4

jg a3 ;大於4跳到a3,即退出

jmp a1 ;如果ecx小於等於4,則執行這句轉到a1,繼續壹輪新循環

a3:

16位版本,用masm編譯,之後用debug運行,最後bh中的結果就是妳要的數值

assume cd:codesg,ds:datasg

datasg segment

bd 'A5D78'

datasg ends

codesg segment

start:

mov ax,datasg ;初始化操作

mov ds,ax

mov bx,0

mov cx,5

mov ah,0

s:

mov al,[bx] ;定位第壹字符

cmp al,30h ;是否小於0

jl a ;是則跳轉

cmp al,39h ;是否大於9

jg a ;是則跳轉

inc ah ;記錄數字個數的寄存器

a:

inc bx

loop s 循環五次,直到cx=0為止

codesg ends

end start

  • 上一篇:UG怎麽在曲面上寫字?
  • 下一篇:《了不起的蓋茨比》的內容
  • copyright 2024編程學習大全網