flat assembler
Message board for the users of flat assembler.
Index
> OS Construction > [solved] CPUID trouble Goto page 1, 2 Next |
Author |
|
dosin 29 Jan 2010, 04:35
this a prints cpuname and small vend name in pmode:
hope this helps! Code: pusha mov eax,0 ; eax=0 cpuid mov [cpuname+ 12],ebx mov [cpuname+ 16],edx mov [cpuname+ 20],ecx mov [smallvendor],ecx popa mov esi,cpuname call print_string mov esi,spacer call print_string mov esi,smallvendor call print_string jmp $ cpuname: db 'CPU VENDOR: ',0 spacer: db " ",0 smallvendor dd ? Last edited by dosin on 29 Jan 2010, 14:46; edited 1 time in total |
|||
29 Jan 2010, 04:35 |
|
roboman 29 Jan 2010, 05:53
Don't know much about cpuid, but does your PrintString choke if it's not 0 terminated?
|
|||
29 Jan 2010, 05:53 |
|
sinsi 29 Jan 2010, 06:05
Watch your pushes and pops too
Code: Push EAX ; Save regs we need to use later on. Push ECX Push EDX ;... Pop EDX Pop ECX Pop EDX |
|||
29 Jan 2010, 06:05 |
|
tom tobias 29 Jan 2010, 12:16
hmm. EDX, EAX, hmm. Now where have we had this discussion before????
Yup, that's right, a single letter change, leading to an error, which is difficult to identify....difficult to debug....hahaha... Proof is in the pudding..... |
|||
29 Jan 2010, 12:16 |
|
revolution 29 Jan 2010, 12:41
When I first saw that the first person I thought of was tom tobias.
tom, thanks for not letting me down. So what should be do about this "problem"? Clearly it is not acceptable that one single letter change is allowed to make a program crash (regardless of whether it is in and xor or a push). Should we rename all the registers and opcodes to ensure a minimum possible Hamming distance? |
|||
29 Jan 2010, 12:41 |
|
edfed 29 Jan 2010, 13:47
the single letter change is like the single DNA change.
it gives unpredictable results. a way to push:pop regs is preferable do them on a single line, with the 4 general registers.(not only 3). Code: push eax ebx excx edx pop edx ecx ebx eax then, you just have to compare the lines, the first in forward order, the second in reverse order. and if you are very lazy, you can do it with a macro Code: macro pushg32{ push eax ebx ecx edx } macro popg32{ pop edx ecx ebx eax } push eax ebx ecx edx is better because if you want to add a new functionality in your code, you can do it with ALL registers. after, you do the optimisation with a reduced pushing/poping. and all with lowercase chars is better because faster to write. |
|||
29 Jan 2010, 13:47 |
|
revolution 29 Jan 2010, 13:50
edfed: Have you ever seen the 'proc' macro?
|
|||
29 Jan 2010, 13:50 |
|
edfed 29 Jan 2010, 13:52
i know 'proc', but i don't use it.
never, i don't understand it... like 'struct'... |
|||
29 Jan 2010, 13:52 |
|
revolution 29 Jan 2010, 13:55
edfed wrote: i know 'proc', but i don't use it. |
|||
29 Jan 2010, 13:55 |
|
edfed 29 Jan 2010, 14:08
revolution wrote:
cool, i'll give it a try one day. but it is an abstraction layer, no? |
|||
29 Jan 2010, 14:08 |
|
revolution 29 Jan 2010, 14:53
edfed wrote: but it is an abstraction layer, no? |
|||
29 Jan 2010, 14:53 |
|
Coddy41 29 Jan 2010, 17:05
roboman wrote: Don't know much about cpuid, but does your PrintString choke if it's not 0 terminated? Nah, It would probably just print a bunch of ascii characters to the screen until a 0 comes along. Hmm, I fixed that push pop problem, but it still does not seem to work I have decided to do a re-write with it based from dosin's example. EDIT: Funny, even dosin's example would not work in my OS, I am wondering if it is the GDT I am using, I am going to wright my own and see. I'll post back if it works _________________ Want hosting for free for your asm project? You can PM me. (*.fasm4u.net) |
|||
29 Jan 2010, 17:05 |
|
bitshifter 29 Jan 2010, 17:21
Also i made one for MM testing... (still not complete)
http://board.flatassembler.net/topic.php?t=10708 |
|||
29 Jan 2010, 17:21 |
|
Coddy41 29 Jan 2010, 17:28
Wow I did a search on the fasm board on 'CPUID' before making this thread and I do not
think I saw that one =/ Thanks I'll study it as I wanted to test for MMX _________________ Want hosting for free for your asm project? You can PM me. (*.fasm4u.net) |
|||
29 Jan 2010, 17:28 |
|
dosin 29 Jan 2010, 19:30
What you could do - is make a dex os app that will display it..
since dex os is in pmode and have all the functions you need ...print string ect.. once you have it to print what you want - and working right.. transfer to your os.. then if its still not working.. look at the functions your using - your print text... gdt... pmode code... ect. |
|||
29 Jan 2010, 19:30 |
|
bitshifter 29 Jan 2010, 19:51
Dex already have that program written (CPUID.DEX)
Maybe he would be kind enough to share the sources |
|||
29 Jan 2010, 19:51 |
|
Coddy41 29 Jan 2010, 21:09
@dosin: It works in DexOS wich is weird, Im going to check the rest of my code
and see if that works. @bitshifter: Atually, the CPUID source is posted on the DexOS forums, do a search of "CPUID not working" The code has a bug, but if you know what you are doing there is a post that tells you the problem _________________ Want hosting for free for your asm project? You can PM me. (*.fasm4u.net) |
|||
29 Jan 2010, 21:09 |
|
dosin 29 Jan 2010, 23:40
if you have a print char function you can try that and see if it has the vender name stored - just print one char at a time..
if it works than there may be something in your printstring... if still nothing .. it could be something with your GDT segment set up... your data segs.. or something.. Code: call get_cpuid_info mov al,byte[cpuname+ 12] call print_char mov al,byte[cpuname+ 13] call print_char mov al,byte[cpuname+ 14] call print_char ect... |
|||
29 Jan 2010, 23:40 |
|
Coddy41 30 Jan 2010, 00:28
My printstring works fine after dex pointed out the problem (see here http://dex.7.forumer.com/viewtopic.php?p=5812#5812)
But it does not hurt to try... I got my same result _________________ Want hosting for free for your asm project? You can PM me. (*.fasm4u.net) |
|||
30 Jan 2010, 00:28 |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.