Problems with resetting sound card at port 220h

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
Maxxon22
Posts: 2
Joined: Sun Mar 08, 2015 7:35 am

Problems with resetting sound card at port 220h

Post by Maxxon22 »

Hi everyone!

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
Here are the print functions:

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
Nable
Member
Member
Posts: 453
Joined: Tue Nov 08, 2011 11:35 am

Re: Problems with resetting sound card at port 220h

Post by Nable »

I/O port 0x220 is for old ISA Sound Blaster that has nothing in common with the current PCI-E one.
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Re: Problems with resetting sound card at port 220h

Post by Brynet-Inc »

"Kids these days, thinking their fancy new PCI sound cards are legacy compatible with ISA SB cards." :-)

Most modern sound cards implement Intel's HDA specification, using a variety of audio codecs and configurations. A few professional audio devices however, do not.
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
Maxxon22
Posts: 2
Joined: Sun Mar 08, 2015 7:35 am

Re: Problems with resetting sound card at port 220h

Post by Maxxon22 »

Haha! :D

Thank you sooo much guys! I'm looking into the Intel HDA specification.
Post Reply