Page 1 of 1
gettime
Posted: Thu Jan 30, 2003 8:46 pm
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
Re:gettime
Posted: Thu Jan 30, 2003 11:19 pm
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!
Re:gettime
Posted: Fri Jan 31, 2003 1:36 am
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
Re:gettime
Posted: Fri Jan 31, 2003 1:46 am
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???
Re:gettime
Posted: Fri Jan 31, 2003 2:17 am
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.