Is there anything that can be improved here?
%macro newline 0.nolist
mov ax, 0E0Dh
int 10h
mov al, 0Ah
int 10h
%endmacro
%macro getc 0.nolist
%%get:
mov ah, 11h
int 16h ; get keystroke status
jnz %%pressed
hlt
jmp %%get
%%pressed:
mov ah, 10h
int 16h ; get the pressed key on "modern" keyboards
%endmacro
; %1 = string to write into
%macro scan 1
pushaw
mov di, %1 ; prep for stosb
xor cx, cx
%%get:
getc
cmp al, 13
je %%done ; enter pressed
cmp al, 8
je %%bspace
cmp al, ' '
jb %%get ; ignore most non-printing characters
cmp al, '~'
ja %%get
push bp
mov ah, 0Eh ; print the valid character
int 10h
push bp
stosb ; write the character to the string
inc cx
cmp cx, 80 ; ensure the buffer isn't exceeded
jae near %%done
jmp near %%get ; room for more
%%bspace:
cmp cx, 0
je %%get ; ignore starting bspace
push bp
mov ax, 0E08h
int 10h ; bspace twice, to clear space
mov al, 32
int 10h
mov al, 8
int 10h
pop bp
dec di ; overwrite character position
dec cx ; step back a character
jmp %%get
%%done:
xor ax, ax
stosb ; append null-terminating character (zero)
newline
popaw
%endmacro