Professional Documents
Culture Documents
Assembly Questions Solution
Assembly Questions Solution
Q1. Write a procedure “read-char” that inputs a character using DOS function it returns the character
in AL register.
read-char proc
mov ah,01h
int 21h
ret
read-char endp
Q2. Write a procedure ‘read-strin g’ that inputs a string from keyboard using read-char procedure , this
procedure is passed an offset of buffer in SI by the caller.
read-string proc
l1: call read-char
mov [si] , al
inc si
cmp al,13
jne l1
ret
read-string endp
Q3.
Write a character which checks whether the character is small or not and uses carry flag, the character is
in AL register.
Is-small proc
Comp al, ‘a’
Jl no
Cmp al,’z’
Jg no
Stc ; c = 1 for yes small
ret
no:
clc
ret
Is-small endp
Q4. Write a program using above procedure to split a given string of alphabets into two buffers , one for
small and other for capital letters.
main proc
Mix db “aAbBcCdDeE”
Solution.
Small db 20 DUP(0)
Capital db 20 DUP(0)
Lea BX , Mix
Lea SI, Small
Lea DI , Capital
Call split-string
endp
Split-string proc
mov cx, lengthof Mix
L2:
mov al,[bx]
call is-capital
jnc no ; no
; yes capital
mov [si],al
inc si
jmp L1
;
; no not capital
No:
mov [di], al
Inc di
;
; put in buffer
L1:
dec cx
jnz L2
RET
Split-string endp