DOS Print 32-битное значение сохраняется в EAX с шестнадцатеричным выводом (для 80386 +)
(на 64-битной ОС используйте DOSBOX)
.code
mov ax,@DATA ; get the address of the data segment
mov ds,ax ; store the address in the data segment register
;-----------------------
mov eax,0FFFFFFFFh ; 32 bit value (0 - FFFFFFFF) for example
;-----------------------
; convert the value in EAX to hexadecimal ASCIIs
;-----------------------
mov di,OFFSET ASCII ; get the offset address
mov cl,8 ; number of ASCII
P1: rol eax,4 ; 1 Nibble (start with highest byte)
mov bl,al
and bl,0Fh ; only low-Nibble
add bl,30h ; convert to ASCII
cmp bl,39h ; above 9?
jna short P2
add bl,7 ; "A" to "F"
P2: mov [di],bl ; store ASCII in buffer
inc di ; increase target address
dec cl ; decrease loop counter
jnz P1 ; jump if cl is not equal 0 (zeroflag is not set)
;-----------------------
; Print string
;-----------------------
mov dx,OFFSET ASCII ; DOS 1+ WRITE STRING TO STANDARD OUTPUT
mov ah,9 ; DS:DX->'$'-terminated string
int 21h ; maybe redirected under DOS 2+ for output to file
; (using pipe character">") or output to printer
; terminate program...
.data
ASCII DB "00000000",0Dh,0Ah,"$" ; buffer for ASCII string
Альтернативный вывод строки непосредственно в видеобуфер без использования программных прерываний:
;-----------------------
; Print string
;-----------------------
mov ax,0B800h ; segment address of textmode video buffer
mov es,ax ; store address in extra segment register
mov si,OFFSET ASCII ; get the offset address of the string
; using a fixed target address for example (screen page 0)
; Position`on screen = (Line_number*80*2) + (Row_number*2)
mov di,(10*80*2)+(10*2)
mov cl,8 ; number of ASCII
cld ; clear direction flag
P3: lodsb ; get the ASCII from the address in DS:SI + increase si
stosb ; write ASCII directly to the screen using ES:DI + increase di
inc di ; step over attribut byte
dec cl ; decrease counter
jnz P3 ; repeat (print only 8 ASCII, not used bytes are: 0Dh,0Ah,"$")
; Hint: this directly output to the screen do not touch or move the cursor
; but feel free to modify..