Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Dec2String PROC NEAR
- PUBLIC Dec2String
- Dec2StringInit: ;Initialize function.
- PUSH AX ;Push arguments on the stack.
- PUSH SI
- MOV CX, MAX_PWR10 ;Initialize CX as maximal power of 10.
- CMP AX, 0 ;Check for sign
- JG Positive
- JZ Dec2StringLoop ;If zero, jump to loop directly.
- ;JL Negative
- Negative:
- MOV BYTE PTR [SI], '-' ;If negative, start with a minus sign.
- NEG AX
- INC SI
- JMP Dec2StringLoop ;Enter the main loop.
- Positive:
- MOV BYTE PTR [SI], '+' ;If positive, start with a plus sign.
- INC SI
- ;JMP Dec2StringLoop ;Enter the main loop.
- Dec2StringLoop:
- CMP CX, 0 ;Loop while pwr10 > 0
- JZ EndLoop
- ;JG LoopBody
- LoopBody:
- DIV CX ;AX <- quotient, DX <- reminder.
- ADD AX, ASCII_OFFSET ;Translate the quotient to ASCII.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement