risposta
Hai provato int 21h
service 2? DL
è il carattere da stampare.
mov dl,'A' ; print 'A'
mov ah,2
int 21h
Per stampare il valore intero, dovrete scrivere un ciclo di scomporre il numero intero a singoli caratteri. Se stai bene con la stampa del valore in hex, questo è piuttosto banale.
Se non è possibile fare affidamento su servizi DOS, si potrebbe anche essere in grado di utilizzare il BIOS int 10h
con AL
set per 0Eh
o 0Ah
.
Un aiuto incredibile .. cercavo da molto tempo ... ovunque si muovesse ah, 09 che per stampare gli array ma non mov ah, 02 per stampare un singolo valore. – unrealsoul007
funzione di chiamata WinAPI (se u stanno sviluppando win-applicazione)
f si scrive un'applicazione Windows (anche con) in asm o C ... Quindi, le funzioni saranno una funzione WinAPI. È come rispondere "* dovresti vedere un dottore *" a qualcuno che dice "* Sono malato *". – user2284570
linguaggio Assembly ha mezzi diretti di stampare nulla. Il tuo assemblatore può o non può venire con una libreria che fornisce tale servizio, altrimenti devi scriverlo da solo, e sarà una funzione abbastanza complessa. Devi anche decidere dove stampare le cose - in una finestra, sulla stampante? In assembler, niente di tutto ciò è fatto per te.
Potresti avere un po 'di fortuna nel chiamare MessageBoxA dell'API Win32, anche se Win16 supporta quel particolare metodo per la risposta di qualcun altro.
PRINT_SUM PROC NEAR
CMP AL, 0
JNE PRINT_AX
PUSH AX
MOV AL, '0'
MOV AH, 0EH
INT 10H
POP AX
RET
PRINT_AX:
PUSHA
MOV AH, 0
CMP AX, 0
JE PN_DONE
MOV DL, 10
DIV DL
CALL PRINT_AX
MOV AL, AH
ADD AL, 30H
MOV AH, 0EH
INT 10H
PN_DONE:
POPA
RET
PRINT_SUM ENDP
Si prega di aggiungere alcune frasi che non fanno parte del codice per i dettagli della risposta ... – user2284570
mov al,3 ;print ♥
mov dl,al
;call print service(2) to print from dl
mov ah,2
int 21h
;return to DOS
mov ah,76 ;76 = 4ch
int 21h ;call interrupt
mov al,4 ; input
; print AL
or al,30h ; Important! =>Convert an integer from 0-9 to its ASCII encoding
mov i,al
MOV AH, 2 ;
MOV DL, i ; Print Character.
INT 21H ;
Very Thanks Kay. –
Non è necessario rimbalzare il valore tramite 'i' in memoria. 'mov dl, al' funzionerebbe bene. –
Sono passati 4 anni e dimentico il linguaggio dell'assemblaggio. :( È probabile che tu abbia ragione. Grazie. <3 –
; good example of unlimited num print
.model small
.stack 100h
.data
number word 6432
string db 10 dup('$')
.code
main proc
mov ax,@data
mov ds,ax
mov ax,number
mov bx ,10
mov cx,0
l1:
mov dx,0
div bx
add dx,48
push dx
inc cx
cmp ax,0
jne l1
mov bx ,offset string
l2:
pop dx
mov [bx],dx
inc bx
loop l2
mov ah,09
mov dx,offset string
int 21h
mov ax,4c00h
int 21h
main endp
end main
Aggiungi alcune frasi che non fanno parte del codice per i dettagli della risposta ... – user2284570
formattazione terribile. Downvoted per essere quasi illeggibile con tonnellate di spazi bianchi, nessun rientro e nessun commento. –
DOS valore Stampa 32 bit memorizzato in EAX con uscita esadecimale (per 80386+)
(su 64 bit del sistema operativo utilizzano 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
Alternative stringa di output direttamente al videobuffer senza l'uso di interrupt software:
;-----------------------
; 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..
AH = 09 DS: DX = puntatore alla stringa che termina con "$"
returns nothing
- outputs character string to STDOUT up to "$"
- backspace is treated as non-destructive
- if Ctrl-Break is detected, INT 23 is executed
ref: http://stanislavs.org/helppc/int_21-9.html
.data
string db 2 dup(' ')
.code
mov ax,@data
mov ds,ax
mov al,10
add al,15
mov si,offset string+1
mov bl,10
div bl
add ah,48
mov [si],ah
dec si
div bl
add ah,48
mov [si],ah
mov ah,9
mov dx,string
int 21h
Prova a spiegare parte del tuo codice per favore. – Marcs
È necessario specificare il tipo di macchina e di esercizio sistema, dal momento che I/O è generalmente molto dipendente dalla piattaforma. – unwind
Ha fatto, ha un tag "win16". –
win16 davvero? Stai ancora utilizzando Windows 3.1? –