| | |
Displaying contents of registers..?
![]() |
•
•
Join Date: Dec 2008
Posts: 18
Reputation:
Solved Threads: 0
Hello, I'm having this little problem, and I will thank you if you help me with it.
What I'm trying to do is to display the contents of various 16-bit registers (e.g. AX, BX, CX, DX), however without success;
Well, what I tried to do is to check the total clusters and total free clusters on the hard-drive using DOS interrupt 21h and function 36h. It returns the number of total clusters into DX.
I tried to print the DX using the function 09h of the same interrupt, however I'm getting gibberish whenever i'm trying to do so.
In short - How can I convert number from registers such as AX or DX into strings, so I can print them to the screen?
What I'm trying to do is to display the contents of various 16-bit registers (e.g. AX, BX, CX, DX), however without success;
Well, what I tried to do is to check the total clusters and total free clusters on the hard-drive using DOS interrupt 21h and function 36h. It returns the number of total clusters into DX.
I tried to print the DX using the function 09h of the same interrupt, however I'm getting gibberish whenever i'm trying to do so.
In short - How can I convert number from registers such as AX or DX into strings, so I can print them to the screen?
0
#2 Oct 18th, 2009
The reason jibberish is output to the consol is because
DX is to contain the offset of a dollar-sign '$' terminated string.
To print out the value contained in the registers you will
have to convert their value into the ASCII representation
of a hexadecimal/decimal/etc.. value.
To print out the value of the AX register in hex for example:
DX is to contain the offset of a dollar-sign '$' terminated string.
Assembly Syntax (Toggle Plain Text)
mov dx, offset msg mov ah, 0x9 int 0x21 int 0x20 msg db 'hello world$'
have to convert their value into the ASCII representation
of a hexadecimal/decimal/etc.. value.
To print out the value of the AX register in hex for example:
Assembly Syntax (Toggle Plain Text)
mov ax, 0x1234 call printw int 0x20 printw: push ax shr ax, 8 call printb pop ax push ax and ax, 0xff call printb pop ax ret printb: push ax shr al, 4 call printasc pop ax and al, 0xf call printasc ret printasc: add al, 0x30 cmp al, 0x39 jle printasc_e add al, 0x7 printasc_e: mov dl, al mov ah, 0x2 int 0x21 ret
----------------------------------------------------------
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
- Displaying contents of a text file (PHP)
- haskell - displaying contents of a list (Legacy and Other Languages)
- problem with displaying data from hql query (JSP)
- problem in displaying the contents of linkedlist (C++)
- Displaying cookie contents in safari? (JavaScript / DHTML / AJAX)
- LC3 displaying numbers in registers (Assembly)
- formatting problems (Windows NT / 2000 / XP)
- Can't display links in toolbar (Web Browsers)
Other Threads in the Assembly Forum
- Previous Thread: Assembly programming motorola 6800 ebook_example codes please...
- Next Thread: help with MIPS snprintf function?
| Thread Tools | Search this Thread |





