汇编——显示内存中的数据

data segment
	array db 01H,25H,38H,62H,8DH,9AH,0BAH,0CEH
data ends

code segment 
	assume cs:code,ds:data
start:
	mov ax,data;
	mov ds,ax;
	mov si,offset array
	mov cx,07H
s:  mov dl,ds:[si]
	call look
	call look2
	inc si
	loop s
	
	mov dl,ds:[si]
	call look

	mov ax,4c00H
	int 21H
	
look:
	push cx

    mov ch,dl
	mov cl,4
	shr dl,cl
	and dl,0FH

	cmp dl,9
	ja hex1
	add dl,30H
	jmp t1

hex1:
    sub dl,10
    add dl,'A'

	
t1:
    mov ah,02H
	int 21H
	
    and ch,0FH
	cmp ch,9
	ja hex2
	add ch,30H
	jmp t2

hex2:
    sub ch,10
    add ch,'A'
    
t2:
	mov dl,ch
	mov ah,02H
	int 21H

	mov dl,'H'
	mov ah,02H
	int 21H
	pop cx
	ret

look2:
   	mov dl,','
	mov ah,02H
	int 21H
	ret
code ends
end start

你可能感兴趣的:(汇编)