1org 100h 2[map all] 3 4section .bss ; follows=.data 5 buffer resb 123h 6section .data 7 msg db "this is a message", 0 8section .text 9 mov ax, msg 10 call showax 11 mov ax, buffer 12 call showax 13 ret 14 15;----------------- 16showax: 17 push cx 18 push dx 19 20 mov cx, 4 ; four digits to show 21 22.top 23 rol ax, 4 ; rotate one digit into position 24 mov dl, al ; make a copy to process 25 and dl, 0Fh ; mask off a single (hex) digit 26 cmp dl, 9 ; is it in the "A" to "F" range? 27 jbe .dec_dig ; no, skip it 28 add dl, 7 ; adjust 29.dec_dig: 30 add dl, 30h ; convert to character 31 32 push ax 33 mov ah, 2 34 int 21h 35 pop ax 36 37 loop .top 38 39 pop dx 40 pop cx 41 ret 42;-------------------------- 43