删除空格

;
; 
;删除空格:代码1
; author:  wangguolaing
; date:  revised 4/14


.386
.MODEL FLAT


INCLUDE io.h
includelib Kernel32.lib
ExitProcess PROTO NEAR32 stdcall, dwExitCode:DWORD


cr          EQU    0dh  
Lf          EQU    0ah      


.STACK      4096


.DATA
Array    DWORD  's',' ','w',' ',' ','r','r','t' 


count    DWORD  ?
value    DWORD  ?


.CODE
_start:
         lea ebx,Array
            
whileup   :
         mov ecx,count
         cmp ecx,7
         je  endwhile
         add ebx,4
         inc count
         mov eax,[ebx]
         cmp eax,' '
         je  space
         jmp whileup


space   : mov eax,0
          mov [ebx],eax
          jmp whileup


endwhile   :
           lea ebx,Array
           mov count,0
upwhile    : 
            mov eax,count
            cmp eax,8
            je quit
            output [ebx]
            add ebx,4
            inc count
            jmp upwhile
                                                  
quit:       INVOKE ExitProcess, 0   ; exit with return code 0


PUBLIC _start                       ; make entry point public
            END                     ; end of source code  




;
; 
;删除空格:代码2
; author:  wangguolaing
; date:  revised 4/14
.386
.MODEL FLAT
ExitProcess PROTO NEAR32 stdcall, dwExitCode:DWORD
INCLUDE io.h
includelib lib\kernel32.lib
cr equ 0dh
lf equ 0ah


.STACK 4096
.DATA
array byte 50 dup(?)
prompt1 byte "input a string ending with 0:",0
string byte 100 dup(?)
label1 byte cr,lf,"the length of the string is:"
leng dword 11 dup(?)
       byte cr,lf,0


.code
_start:


output prompt1
input string,40
lea esi,string
mov eax,0
lea edi,array


loop1:
mov dl,byte ptr[esi]
cmp dl,0
je end1
cmp dl,20h
je next
mov byte ptr[edi],dl
inc edi
next:
inc eax


add esi,1 ;指向下一个字符
jmp loop1


end1:
output array
dec eax
dtoa leng,eax
output label1




INVOKE ExitProcess,0
PUBLIC _start
END _start


你可能感兴趣的:(汇编语言,80x86)