1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
| assume cs:code,ds:data,ss:stack
data segment
array db 88h,0FFh,0Fh,0CCh,3Fh
number db '0123456789ABCDEF'
data ends
stack segment db 128 dup (0) stack ends
code segment
start: mov ax,stack mov ss,ax mov sp,128
call init_reg
call show_byte
mov ax,4c00h int 21h
;==================================================== show_byte: mov si,offset array mov di,160*10+40*2 mov cx,5
showByte: mov al,ds:[si] call show_hex inc si loop showByte
ret
;==================================================== show_hex: jmp showHex
showHex: mov ah,al and al,00001111B shr ah,1 shr ah,1 shr ah,1 shr ah,1
mov bx,0 mov bl,al
mov al,ds:number[bx]
mov bl,ah mov ah,ds:number[bx]
mov es:[di],ah mov es:[di+2],al
add di,6
ret
;==================================================== init_reg: mov bx,0B800H mov es,bx
mov bx,data mov ds,bx ret
code ends
end start
|