Code Assembly: In ra màn hình xâu nghịch đảo
org 100h
jmp start
; tao xau nghich dao
string1 db ' toi khong mo hoa $'
start: lea bx, string1
mov si, bx
next_byte: cmp [si], 'a'
je found_the_end
inc si
jmp next_byte
found_the_end: dec si
; now bx points to beginning,
; and si points to the end of string.
; do the swapping:
do_reverse: cmp bx, si
jae done
mov al, [bx]
mov ah, [si]
mov [si], al
mov [bx], ah
inc bx
dec si
jmp do_reverse
; reverse complete, print out:
done: lea dx, string1
mov ah, 09h
int 21h
; wait for any key press....
mov ah, 0
int 16h
ret
;------------------------------------------
0 nhận xét:
Đăng nhận xét