Strip control codes and extended characters from a string: Difference between revisions

m
→‎{{header|8086 Assembly}}: added a version that only strips control codes
m (→‎{{header|8086 Assembly}}: fixed inconsistent formatting)
m (→‎{{header|8086 Assembly}}: added a version that only strips control codes)
Line 50:
mov ax,03h
int 10h ;clear screen
mov si,offset StringStrip
call PrintString_PartiallyStripped
call NewLine
mov si,offset StringStrip
call PrintString_Stripped
 
 
mov ax,4C00h
int 21h ;return to DOS
Line 75 ⟶ 78:
jmp PrintString_Stripped
Terminated:
ret
PrintString_PartiallyStripped:
;strips control codes but not extended ascii.
;The null terminator isn't stripped of course.
lodsb
cmp al,0
jz Terminated_PartiallyStripped
cmp al,21h
jb PrintString_PartiallyStripped
cmp al,7Fh
je PrintString_PartiallyStripped ;delete counts as a control code
mov ah,02h
mov dl,al
int 21h
jmp PrintString_PartiallyStripped
Terminated_PartiallyStripped:
ret
 
NewLine:
mov ah,02h
mov dl,13 ;carriage return
int 10h
mov ah,02h
mov dl,10 ;line feed
int 10h
ret
end start</lang>
 
{{out}}
<pre>
abcdefÉ
abcdef
</pre>
1,489

edits