I've set up a simple real-mode environment with some basic functions (printChar, printString, printHex). My goal now is to record sound data from the microphone connected to my pc/sound card.
I've read the SoundBlaster Hardware Programming Guide (http://pdos.csail.mit.edu/6.828/2007/re ... laster.pdf) and implemented the Reset DSP function into my code. It works fine with VirtualBox and I get the 0x00AA response. (The sound card should respond with this code if everything went ok).
My problem is when I boot it in a real environment (on my PC) I get the code 0x00FF. Which means that somethings not right. My motherboard is an Asus Maximus VII Ranger.
I don't know what the problem might be. I thought that maybe the onboard sound card is not mapped to port 0x220. So I bought a new SoundBlaster Z audio card, but it's still not working Can somebody help me?
Little bit of nerd porn here:
http://i.imgur.com/dEQ52u1.jpg?1
Thank you anyone who'll spend time with my problem. I really appreciate it.
Here's my code:
Code: Select all
USE16
org 0x7C00
begin:
; Setup registers
xor eax, eax
xor esi, esi
xor edi, edi
mov ds, ax
mov es, ax
; Setup stack
mov bp, 0x8000
mov sp, bp
; Set screen to 80x25 color text mode
mov ax, 0x03
int 0x10
xor ax, ax
mov dx, soundBaseAddress + 0x06
mov al, 1
out dx, al
sub al, al
Delay:
dec al
jnz Delay
out dx, al
sub cx, cx
Empty:
mov dx, soundBaseAddress + 0x0E
in al, dx
or al, al
jns NextAttempt
mov dx, soundBaseAddress + 0x0A
in al, dx
call printHex
cmp al, 0xAA
je ResetOK
jmp ResetFailed
NextAttempt:
loop Empty
ResetOK:
mov si, success_msg
call printString
jmp hang
ResetFailed:
mov si, error_msg
call printString
jmp hang
hang:
jmp hang
; Includes
; ========================
; Basic
%include "print_string.asm"
%include "print_char.asm"
%include "print_hex.asm"
soundBaseAddress equ 0x0220
; Variables
hello_msg db "Hello Matrix!", 0
error_msg db " Error, ****!", 0
success_msg db " Success!", 0
times 510 - ($-$$) db 0
dw 0xaa55
Code: Select all
; PRINT STRING
printString:
pusha
mov ah, 0x0E
.repeat:
lodsb
cmp al, 0
je .done
int 0x10
jmp short .repeat
.done:
popa
ret
; PRINT HEX
printHex:
pusha
; Print HEX from AX
; Print "0x" first
mov bl, "0"
call printChar
mov bl, "x"
call printChar
mov bx, 0
mov bl, ah
call formatHex
mov bx, 0
mov bl, al
call formatHex
popa
ret
formatHex:
shl bx, 4
shr bl, 4
jmp hexDoLowByte
hexDoLowByte:
add bx, 0x3030
cmp bl, 0x39
jbe hexDoHighByte
add bl, 7
hexDoHighByte:
cmp bh, 0x39
jbe hexDone
add bh, 7
hexDone:
mov cx, bx
mov bl, ch
call printChar
mov bl, cl
call printChar
ret
; PRINT CHAR
printChar:
pusha
mov al, bl
mov ah, 0x0E
int 0x10
popa
ret