Calling Int15 properly?
Calling Int15 properly?
In my OS I am trying to display amount of RAM at boot. I've already enabled the A20 line. Now I am trying to get the BIOS to to display the amount of RAM. It is Int15/AH=88h, where AX is the amount in KB. Can anyone help me call this properly? Thanks.
RE:Calling Int15 properly?
mov al,16h
out 70h,al
in al,71h
mov ah,al
mov al,15h
out 70h,al
in al,71h
mov [mem],ax
ret
This is direct probing for conventional memory. When It compiles it says that symbol 'mem' undefined. Also, will the returned value be in hex and how can I display it?
out 70h,al
in al,71h
mov ah,al
mov al,15h
out 70h,al
in al,71h
mov [mem],ax
ret
This is direct probing for conventional memory. When It compiles it says that symbol 'mem' undefined. Also, will the returned value be in hex and how can I display it?
RE:Calling Int15 properly?
First off, hex is a measurement to represent data, in an alternative format, other than other formats such as binary.
The processor sees everything as binary, 0 & 1. Hex is used by people to make reading binary numbers easier.
So the binary value 1010 would be A in hex. Just a representation, because we dont want to be reading a long line of 0's and 1's across a page when 1 hex character will represent 4 binary numbers, thus cutting down what needs to be read and making things nicer.
Second, the symbol mem is undefined because you either haven't a) defined it, i.e. typed something along the lines of
mem RESB 2
or b) you haven't referenced it, i.e. if you have declared it under another asm file, you need to make it global from the file that does have it in like this.
[GLOBAL mem]
and then import it into the file you're using above using extern, like this.
[EXTERN mem]
Then you can reference it. The whole point of this is to control modularity and to try to stop possible errors in naming of functions and variables between files.
btw, example code above is in nasm formating.
As for fetching the amount of RAM in your previous message, try this link for int numbers used by BIOS's to find some that will show your memory information.
Ralf Brown's Interrupt List
http://www.osdev.org/servlet/FollowServ ... nks&num=15
Moose.
The processor sees everything as binary, 0 & 1. Hex is used by people to make reading binary numbers easier.
So the binary value 1010 would be A in hex. Just a representation, because we dont want to be reading a long line of 0's and 1's across a page when 1 hex character will represent 4 binary numbers, thus cutting down what needs to be read and making things nicer.
Second, the symbol mem is undefined because you either haven't a) defined it, i.e. typed something along the lines of
mem RESB 2
or b) you haven't referenced it, i.e. if you have declared it under another asm file, you need to make it global from the file that does have it in like this.
[GLOBAL mem]
and then import it into the file you're using above using extern, like this.
[EXTERN mem]
Then you can reference it. The whole point of this is to control modularity and to try to stop possible errors in naming of functions and variables between files.
btw, example code above is in nasm formating.
As for fetching the amount of RAM in your previous message, try this link for int numbers used by BIOS's to find some that will show your memory information.
Ralf Brown's Interrupt List
http://www.osdev.org/servlet/FollowServ ... nks&num=15
Moose.
RE:Calling Int15 properly?
Thanks,
I didn't ask what hex was, I asked if the value would be returned in hex. And yes, it was. It was displayed as a kinda double bar turning left thing....
Anyone know a good routine to convert hex to decimal? Thanks.
I didn't ask what hex was, I asked if the value would be returned in hex. And yes, it was. It was displayed as a kinda double bar turning left thing....
Anyone know a good routine to convert hex to decimal? Thanks.
RE:Calling Int15 properly?
You obviously don't understand the concept of hex, however... that's why Moose was describing it.
The value you printed isn't "returned as hex"... it's a value, plain and simple... it has no format, per se. It can be represented as anything, visually: binary, string, hex, integer, etc.
That character you saw was _not_ hex. It seems like you're trying to copy an integer to the screen, which, of course, you can't do! The video buffer expects an array of ascii characters, and that's how it's interpreting your value. Essentially, you're seeing the ascii equivalent of that integer (although... not quite, as the integer is probably two or four bytes... and you're only seeing one byte of it).
If you want to display that value as an actual number (aka, a string of digits) then you'll have to perform a conversion, which shouldn't be hard to devise in your head. All you have to do is continually divide by 10 and concatenate the remainders.
Again, note, there is _nothing_ hex about this. A number is a number, is a number... 10 == 0xA == 1010b. To the computer they're all stored the _exact_ same way...
Cheers,
Jeff
The value you printed isn't "returned as hex"... it's a value, plain and simple... it has no format, per se. It can be represented as anything, visually: binary, string, hex, integer, etc.
That character you saw was _not_ hex. It seems like you're trying to copy an integer to the screen, which, of course, you can't do! The video buffer expects an array of ascii characters, and that's how it's interpreting your value. Essentially, you're seeing the ascii equivalent of that integer (although... not quite, as the integer is probably two or four bytes... and you're only seeing one byte of it).
If you want to display that value as an actual number (aka, a string of digits) then you'll have to perform a conversion, which shouldn't be hard to devise in your head. All you have to do is continually divide by 10 and concatenate the remainders.
Again, note, there is _nothing_ hex about this. A number is a number, is a number... 10 == 0xA == 1010b. To the computer they're all stored the _exact_ same way...
Cheers,
Jeff
RE:Calling Int15 properly?
Hex IS decimal, its another numbering system, a method of displaying values.
And more technically, it should be said that hex is denary. Decimal would allow for points. Hex doesn't officialy support decimal points. Get a decimal number like 1.5 in a calculator on your pc, convert the number to hex, and the .5 will be stripped.
Your graphics adapter will only print ascii codes to the screen, so you need to convert your returned numbers (your hex) into ascii. Realise this, its already denary too. So take your number and divide by 10 each time, like carbonbased said.
123/10 12.3/10 1.23. 1 + 30h = 31h (ascii 1 character). print, take remainder
23/10 2.3. 2 + 30h = 32h (ascii 2 character). print, take remainder
3 + 30h = 33h (ascii 3 character). print. now your finished.
Moose.
And more technically, it should be said that hex is denary. Decimal would allow for points. Hex doesn't officialy support decimal points. Get a decimal number like 1.5 in a calculator on your pc, convert the number to hex, and the .5 will be stripped.
Your graphics adapter will only print ascii codes to the screen, so you need to convert your returned numbers (your hex) into ascii. Realise this, its already denary too. So take your number and divide by 10 each time, like carbonbased said.
123/10 12.3/10 1.23. 1 + 30h = 31h (ascii 1 character). print, take remainder
23/10 2.3. 2 + 30h = 32h (ascii 2 character). print, take remainder
3 + 30h = 33h (ascii 3 character). print. now your finished.
Moose.
RE:Calling Int15 properly?
Sorry, I just worded the response wrong.
I tried to write such a function, but I couldn't get it right (stupid me, no math libraries). Could anyone who has implimented a hex2asc routine humour me and post that bit of code?
Thanks bunches!
I tried to write such a function, but I couldn't get it right (stupid me, no math libraries). Could anyone who has implimented a hex2asc routine humour me and post that bit of code?
Thanks bunches!
RE:Calling Int15 properly?
Thanks for that. Would you mind terribly if I "yoinked" (used) pieces of your code, as long as I didn't take credit?
RE:Calling Int15 properly?
Do you mean as long as you did make credit?
If you're going to use the code itself, i dont mind if you keep the header in the top of the file.
If you're going to re-write it, then it would be your own work anyway.
Moose.
If you're going to use the code itself, i dont mind if you keep the header in the top of the file.
If you're going to re-write it, then it would be your own work anyway.
Moose.