Re: Programming PowerPC on Mac

From: Annie (me_at_privacy.net)
Date: 11/25/04

  • Next message: The \\./annabee: "Re: A response to Phil Carmody."
    Date: Thu, 25 Nov 2004 08:07:34 +0000 (UTC)
    
    

    On 2004-11-25 BethStone21@hotmail.NOSPICEDHAM.com said:

    > You see, Annie, you think you're so <SLAP>

    Well, at least you didn't write one of your usual thousand-
    line missives. That's good. The smaller posts are faster
    to delete. Hehe!

    > Anyway, pardon me for not continuing...
                                                 _____
           No problem; I -prefer- that you ((( `\
           don't continue. _ _`\ )
                                                (^ ) )
           And remember the hallmarks of ~-( )
           an experienced Usenet poster: _'((,,,)))
           Brief, concise, to-the-point, ,-' \_/ `\
           and on-topic. ( , |
                                              `-.-'`-.-'/|_|
           Did I mention 'brief?' Hehehe! \ / | |
                                                  =()=: / ,' aa
           Here...amuse yourself with this:

    ;
    ; PIANO.ASM - Version 0.0 [For DOS]
    ; Keyboard number keys (NOT keypad keys) play the musical notes.
    ; ~~~
    code segment
            org 100h
            mov ah,9
            mov dx,offset msg
            int 21h
    ;
    ; Get user keypress.
    ;
    get_key:
            mov ah,0 ;function 0 - wait for keypress
            int 16h ;call ROM BIOS keyboard services
            cmp al,27 ;was ESC pressed?
            jz exit ;yes, so go exit
    ;
    ; Filter out all keys except '1' through '8' by checking the scan code.
    ;
            cmp ah,02h ;less than '1'?
            jl get_key ;yes, so ignore it
            cmp ah,09h ;greater than '8'?
            jg get_key ;yes, so ignore it
    ;
    ; Set up the tone parameters.
    ;
            sub al,21h ;change scan code to to digit (0-9)
            and al,00000111xb ;mask off upper 5 bits
            shl al,1 ;* by 2 (2 bytes/word)
            cbw ;byte --> word in AX
            mov bx,ax ;put in BX (for table)
            mov ax,0 ;numerator (low word)
            mov dx,12h ;(high word)
            div word ptr [table] + bx ;divisor from table
            mov bx,ax ;save quotient in BX
    ;
    ; Set 1/pitch into timer, then turn on tone.
    ;
            mov al,10110110xb ;the magic number...
            mov dx,43h
            out dx,al
            mov ax,bx ;1/pitch into AX
            mov dx,42h
            out dx,al
            mov al,ah ;MSB to AL, then...
            out dx,al
            mov dx,61h
            in al,dx
            or al,3 ;turn on bits 0 and 1...
            out dx,al
    ;
    ; Delay for 2/18ths of a second.
    ;
    delay:
            mov ah,00h ;function 0 - get system timer tick
            int 01Ah ;call ROM BIOS time-of-day services
            add dx,2 ;add our delay value to DX
            mov bx,dx ;store result in BX
    pozz:
            int 01Ah ;call ROM BIOS time-of-day services
            cmp dx,bx ;has the delay duration passed?
            jl pozz ;no, so go check again
    ;
    ; Clear the keyboard buffer.
    ;
            push es ;preserve ES
            push di ;preserve DI
            mov ax,40h ;BIOS segment in AX
            mov es,ax ;transfer to ES
            mov ax,1Ah ;keyboard head pointer in AX
            mov di,ax ;transfer to DI
            mov ax,1Eh ;keyboard buffer start in AX
            mov es: word ptr [di],ax ;transfer to head pointer
            inc di ;bump pointer to...
            inc di ;...keyboard tail pointer
            mov es: word ptr [di],ax ;transfer to tail pointer
            pop di ;restore DI
            pop es ;restore ES
            call stopnote ;go turn off the note
            jmp get_key ;go get another keypress
    ;
    ; Turn off speaker.
    ;
    stopnote:
            push dx
            mov dx,61h
            in al,dx
            and al,11111100xb ;mask lower 2 bits
            out dx,al
            pop dx
            ret ;return to caller
    ;
    ; ESC pressed, so exit.
    ;
    exit:
            call stopnote ;go turn off the note
            int 20h ;exit to DOS
    ;
    msg db 13,10,'PIANO Version 0.0',13,10
            db 'Press keyboard number keys 1 - 8 to play notes.'
            db ' ESC exits.',13,10,'$'
    ;
    ;frequencies of notes
    ;
    table dw 262 ;middle C
            dw 294 ;D
            dw 330 ;E
            dw 347 ;F
            dw 392 ;G
            dw 440 ;A
            dw 494 ;B
            dw 524 ;C
    end


  • Next message: The \\./annabee: "Re: A response to Phil Carmody."