:$Hi! Please excuse me if this is a stupid piece of programming code I wrote. I just started to learn how to program in x86 assmbly and apparently it's gonna be quite a while before I get the hang of it.
Well with this program I want to convert the value in AX into an integer and display it on the screen. I tried to define ten byte variables to represent each bit of the integer and add the value of AX to them "one" at a time. I know this is not the best and usual way to convert something to decimal but the idea just poped out and I wanted to implement it in a program. I haven't the slightest clue why it doesn't work so could you please kindly take a look at it and help me out? Thank you very much! Here's the code:
.8086
DATA SEGMENT
STORY DB 10 DUP(30H)
DATA ENDS
;-------------------------------------
STACK SEGMENT STACK
DB 100 DUP(?)
STACK ENDS
;-------------------------------------
CODE SEGMENT
ASSUME CS:CODE, DS:DATA, SS:STACK
MOV AX, DATA
MOV DS, AX
MOV AX, STACK
MOV SS, AX
;-------------------------------------
MAIN PROC FAR
MOV AX, 3
CV_START:
SUB BP, BP
DEC AX
CV_CARRY:
INC STORY[BP]
CMP STORY[BP], 3AH
JNE CV_NEXT
MOV STORY[BP], 30H
INC BP
JMP CV_CARRY
CV_NEXT:
CMP AX, 0
JE OUTPUT
JNE CV_START
;--------------------------------------------
OUTPUT:
MOV BP, 9
MOV CX, 10
OUT_LOOP:
MOV DL, STORY[BP]
MOV AH, 02
INT 21H
LOOP OUT_LOOP
LEAVE:
MOV AH, 4CH
INT 21H
MAIN ENDP
CODE ENDS
END MAIN