Printing vendor string in real mode
Posted: Mon Feb 20, 2012 1:25 am
I want to be able to show the CPU's vendor string, obtained using the following
According to a regdump, I'm fine with that, but my print from the 32 bit registers dosen't work.... And often it dosen't even recognise the command...
I use this code to print the vendor string
the 32-bit register print is using this code, my first foray into direct hardware control (I'm in real mode, so have been using the BIOS)
Code: Select all
xor eax, eax ;EAX=0
cpuid ;GET VENDOR STRING
I use this code to print the vendor string
Code: Select all
mov esi, ebx
call print_string_e
mov esi, edx
call print_string_e
mov esi, ecx
call print_string_e
Code: Select all
; ------------------------------------------------------------------
; print_c32 -- Displays A charater using 32-bit registers!
; IN: ESI = message location (zero-terminated string), ES = VIDMEM location (0xB800
; OUT: Nothing (registers preserved)
print_c32:
mov ah, 0x0F ; attrib = white on black
mov cx, ax ; save char/attribute
movzx ax, byte [ypos]
mov dx, 160 ; 2 bytes (char/attrib)
mul dx ; for 80 columns
movzx bx, byte [xpos]
shl bx, 1 ; times 2 to skip attrib
mov di, 0 ; start of video memory
add di, ax ; add y offset
add di, bx ; add x offset
mov ax, cx ; restore char/attribute
stosw ; write char/attribute
add byte [xpos], 1 ; advance to right
ret
; ------------------------------------------------------------------
; print_string_e -- Displays A string using 32-bit registers!
; IN: ESI = message location (zero-terminated string),
; OUT: Nothing (registers preserved)
dochar:
call print_c32
print_str32:
lodsb ; string char to AL
cmp al, 0
jne dochar ; else, we're done
add byte [ypos], 1 ;down one row
mov byte [xpos], 0 ;back to left
ret
xpos db 0
ypos db 0
; ==============================================