| | |
printing a digit (as a character)
Please support our Assembly advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Oct 2009
Posts: 2
Reputation:
Solved Threads: 0
Hello!
I'm kind of new in assembly programming and I've been struggling with the following problem today:
How to print an integer, using BIOS interrupt 10h, with its 0Eh in AH register, as its function to print a character to the screen...
For example, how to print the last digit of 2005.
here's what I've tried, using division by 10:
I can't understand why 0 is printed to the screen instead of 5. If i change the line
it prints out 1.
... am I missing something? is it because I use decimal format for integers instead of the hexadecimal one?
Thank you in advance!
I'm kind of new in assembly programming and I've been struggling with the following problem today:
How to print an integer, using BIOS interrupt 10h, with its 0Eh in AH register, as its function to print a character to the screen...
For example, how to print the last digit of 2005.
here's what I've tried, using division by 10:
Assembly Syntax (Toggle Plain Text)
mov ax, 2005 mov cx, 10 div cx ; now, AH should contain the remainder (5) and AL = 200 mov al, ah ; because AL should contain the character to print add al, 48 ; because ASCII code for 5 is 53 (decimal). mov ah, 0Eh; the function for the 10h interrupt int 10h
Assembly Syntax (Toggle Plain Text)
add al, 48 to add al, 49
... am I missing something? is it because I use decimal format for integers instead of the hexadecimal one?
Thank you in advance!
•
•
Join Date: Oct 2009
Posts: 2
Reputation:
Solved Threads: 0
I'm replaying to my post...
I've found the answer to the problem while posting the question and running the code on my computer... I hope I did well by posting it, maybe someone is having the same integer printing related issue.
The thing is I had to write
because with whole CX instead of its low part (CL), after division the remainder is stored somewhere else (I think in DX, and it's not the right one anyway...) so, in the instruction below I should have a 8-bit source.
sorry for bothering
andreib
I've found the answer to the problem while posting the question and running the code on my computer... I hope I did well by posting it, maybe someone is having the same integer printing related issue.The thing is I had to write
Assembly Syntax (Toggle Plain Text)
mov cl, 10 div cl
DIV sourcesorry for bothering

andreib
2005 - 2000 = 5 / 1 = 5 got it???
The actual value of the asci characte '5' is 0x35,
well there you go!
Understanding the DIV instruction:
DIV reg16 = DX:AX / reg16 = quotient AX remainder DX
DIV reg8 = AX / reg8 = quotient AL remainder AH
The actual value of the asci characte '5' is 0x35,
well there you go!
Understanding the DIV instruction:
DIV reg16 = DX:AX / reg16 = quotient AX remainder DX
DIV reg8 = AX / reg8 = quotient AL remainder AH
----------------------------------------------------------
To control a mind violates a man, and all it has been used for is
hurting and afflicting. Nowonder I progam in assembly...
--->Now available http://dotcoding.netai.net/
To control a mind violates a man, and all it has been used for is
hurting and afflicting. Nowonder I progam in assembly...
--->Now available http://dotcoding.netai.net/
![]() |
Similar Threads
- Function to convert integer to single char. (C)
- getline printing null characters (C++)
- Link-listed addressbook (C)
- printing single character on screen (Assembly)
- String to integer conversion (C)
- Using a control to just call the subroutine (VB.NET)
- Encryption of numbers.... (C)
- How do i print int num1; a 5 digit number like 1 2 3 4 5 (Java)
- Easy (I hope) MIPS (SPIM) Question (Assembly)
- reading input ... quick C++ question ... (C++)
Other Threads in the Assembly Forum
- Previous Thread: String to integer
- Next Thread: anyone know how to encrypt?
| Thread Tools | Search this Thread |
Tag cloud for printing a digit (as a character) - division, int10h, integer, print, remainder
.net 3d api array asm asp assembler assembly base c# c++ conversion count counttheoccurenceofanintegerinthe10inputs data debug digit division draw error eweek frequency hardcopy inputs int int10h integer java jsp linux linuxmagazine magazines method occurence page pcmagazine print printing problem publications radix recursion remainder richedit shape size table template textbox webzines win32 windowsce






