J'utilise l'assembly 8086 16BIT avec tasm assembler. J'essaie d'imprimer une variable int, et pour cela, j'ai besoin de convertir ma variable contant en chaîne. J'ai essayé de construire une procédure qui le fait sans succès. c'est complètement faux et ne fonctionne pas.Convertir un entier en chaîne 8086 tasm
pouvez-vous m'aider à construire ceci/expliquer comment construire cela?
Merci les gars!
Ceci est mon code de base en ce moment:
stepCounter db 0
push offset stepCounter ; Copy the OFFSET of "parameter" into the stack
call toString
proc toStringPrint
push bp
mov bp, sp
mov ax, [bp + 4] ;number
div 10; div number(in ax) by 10
mov [bx], ah
;mov dx, []
;mov ah, 9h
;int 21h
pop bp
ret 4
endp toString
EDIT
merci! c'est mon code maintenant: mais son impression encore rien
proc toStringPrint
push bp
mov bp, sp
mov si, [bp+4];number
mov ax, [si]
divide:
cmp al, 0
je Print
mov cl, 10
div cl; div number(in ax) by 10
mov [bx], ah
dec bx
jmp divide
Print:
mov dx, [bp + 6]
mov ah, 9h
int 21h
pop bp
ret 4
endp toStringPrint
EDIT 2 Ceci est le code actuel, planter encore l'application et toujours imprimer 219:
stepCounter dW 0
;this is how i call the PROC:
mov cx, [stepCounter]
push cx
call toStringPrint
proc toStringPrint
push bp
mov bp, sp
mov si, [bp+4] ;number location in memory(I think)
mov ax, [si]
mov cl, "$"
mov [bx], cl
divide:
mov ah, 0
mov cl, 10
div cl ; div number(in ax) by 10
dec bx
add ah, 48 ;Make into a character
mov [bx], ah
cmp al, 0
jne divide
Print:
mov dx, bx
mov ah, 9h
int 21h
pop bp
ret 4
endp toStringPrint
S'il vous plaît nous montrer le code qui ne va pas et ne fonctionne pas. Cela nous donnerait quelque chose à travailler. Maintenant, votre question est admissible à la clôture. –
@SepRoland Merci! Je modifie le post! – Eden
Il n'y a pas de div immédiat. Déplacer 10 dans 'bx', disons, et faire' div bx' - aussi, n'oubliez pas d'effacer 'dx' avant le' div' car c'est 'dx: ax' qui se divise. –