欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

汇编语言 输出16进制数

程序员文章站 2024-02-02 15:54:04
...

依次在屏幕上输出01H, 25H, 38H, 62H, 8DH, 9AH, BAH, CEH

代码:

DATAS SEGMENT
	N DB 8
    ARRY DB 01H, 25H, 38H, 62H, 8DH, 9AH, 0BAH, 0CEH
DATAS ENDS

STACKS SEGMENT
    ;此处输入堆栈段代码
STACKS ENDS

CODES SEGMENT
    ASSUME CS:CODES,DS:DATAS,SS:STACKS
START:
    MOV AX,DATAS
    MOV DS,AX
    mov cx,8
    dec n
    lea si,arry
loop1:
	mov ax,0
	mov al,[si]
	inc si
	call print
	mov dl,' '
	mov ah,2
	int 21h
loop loop1
    MOV AH,4CH
    INT 21H
    
    print proc near
    	mov dx,0
    	mov dl,16
    	div dl
    	mov bl,al
    	mov bh,ah
    	cmp bl,10
    	jge next1
    	mov dl,bl
    	add dl,'0'
    	mov ah,2
    	int 21h
    	jmp next2
    next1:
    	sub bl,10
    	mov dl,bl
    	add dl,'A'
    	mov ah,2
    	int 21h
    next2:
    	cmp bh,10
    	jge next3
    	add bh,'0'
    	mov dl,bh
   		jmp next4
    next3:
    	sub bh,10
    	add bh,'A'
    	mov dl,bh
    next4:
    	mov ah,2
    	int 21h
    ret
    print endp
    
CODES ENDS
    END START