gettime

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
gtsphere

gettime

Post by gtsphere »

Hello! i found this function written in asm and I was wondering, when it passes back the seconds in al, how would i print them out after the function is called?? And Also, i had to port this code into code usable for AS. If you see anything wrong, please let me know! thanks!

Code: Select all


gettime:
push %cx
mov $0x02, %ah
int $0x1a
mov %dh, %al
and $0x04, %al
mov %dh, %ah
mov $0x04, %cl
shr %cl, %ah
aad
pop %cx
ret

gtsphere

Re:gettime

Post by gtsphere »

okay I am now able to print out the values in asm but they are smilies or arrows and then the alphabet and then the 0-9 and it repeats, so i'm guessing it is counting correctly cause its going at 1 char per second.

My question is now, how do i correclty output the NUMERIC second??

i am trying to find an algorithm for it, but no luck, please help out!
distantvoices
Member
Member
Posts: 1600
Joined: Wed Oct 18, 2006 11:59 am
Location: Vienna/Austria
Contact:

Re:gettime

Post by distantvoices »

either you do this with printf
or you write something similar to this:

unsigned int value; //your buffer
unsigned int rest; //remainder
unsigned int divisor=10 //for conversion to decimal
unsigned char *rein;
unsigned char *raus;
unsigned int counter
unsigned char buffer[32]; //say it is 32 bytes long
rein=raus=buffer[0];
counter=0;
while(value){
rest=value%divisor;
*rein++=('0'+rest);
counter++;
if(rein=&buffer[0]+32) rein=&buffer[0];
}

//ready for output:
while(counter){
putch(*raus++);
if(raus=&buffer[0]+32)raus=&buffer[0];
counter--;
}

this should do the work. I have coded something like that in my printf function and it does its job pretty well
;)

stay safe gosh
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image
gtsphere

Re:gettime

Post by gtsphere »

i was reading around the board and i found some posts that said its possible to just use printf("%x", vari); in c? but i was wondering is there a way to write a hex to the screen in assembly???
eL JeDi

Re:gettime

Post by eL JeDi »

hi gtsphere,
is there a way to write a hex to the screen in assembly???
Yes. you should transform the hex into decimal number, and then add '0' char to every digit.

I don't know if there is something more easy in GAS, I've allways programed in TASM when use ASM.
Post Reply