*Very* new to ASM. Where to start?

Pagina 4/5
1 | 2 | 3 | | 5

Van norakomi

Paragon (1102)

afbeelding van norakomi

19-09-2005, 12:34

http://map.tni.nl/articles/keymatrix.php

this is also a nice article when using bios.
This is a bit faster:

keys: EQU #FBE5

space:
ld a,(keys+8) ;space
bit 0,a
jp nz,space

for esc:

esc:
ld a,(keys+7) ;escape
bit 2,a
jp nz,esc

or instead of bit 2,a you could type
AND %00000100 ;check bit 2

I'm using only bios for this, but if you want to know how to do the same without Bios just give a shout.

Van Mirg

Expert (88)

afbeelding van Mirg

25-09-2005, 14:49

Thanks! I've been toying around with it a bit. I crashed my MSX a couple of times, but that was all my fault, heheh. Tongue

I'd like to know how to read the keyboard matrix without BIOS too. But I also want to know which method is "better" to use and why. I always want to know how something works and what its advantages when I use something are instead of just using it. Smile

Van BiFi

Enlighted (4348)

afbeelding van BiFi

25-09-2005, 15:27

           LD  B,120
WAIT_2SEC: HALT
           DJNZ WAJT_2SEC

Will wait for 2 seconds Winkif it gets compiled, the VDP is the only device generating interrupts, the VDP runs in 60Hz and the interrupts are enabled... otherwise the Z80 is picking his nose 'til eternity... Wink

Van [D-Tail]

Ascended (8255)

afbeelding van [D-Tail]

25-09-2005, 16:17

pfff.. whether it'll be 2 seconds and 2 seconds and 20% of 2 seconds, so what... normally VDP generates interrupts, normally the Z80 has interrupts enabled, and it will compile... Convincing enough? Smile

Van BiFi

Enlighted (4348)

afbeelding van BiFi

25-09-2005, 17:17

no, it will break on an undefined label or the relative jump being out of range Tongue

Van Sonic_aka_T

Enlighted (4130)

afbeelding van Sonic_aka_T

25-09-2005, 17:17

I quit my non-textmode programs with this:

CALL $9F ; Bios: CHGET
LD A,0
CALL $5F ; Bios: CHGMOD
RET

Two small tricks... Instead of LD A,$00 you can use XOR A. This will also make A zero, although it will affect flags as well. The advantage is that XOR A is a one-byte instruction while LD A,n is two bytes. Trick number two; whenever you do a CALL followed IMMEDIATELY by a return, you can also make the first call into a JP, and omit the RET.

Van norakomi

Paragon (1102)

afbeelding van norakomi

26-09-2005, 12:48

Thanks! I've been toying around with it a bit. I crashed my MSX a couple of times, but that was all my fault, heheh. Tongue
BLUEMSX:
You probably know this, but what I always do in WBASS2 is type in the beginning of my programm
begin equ $c000
org begin
and when I asm my programm and run it I press:
F8 (save state)
F5 (go begin)
then when the computer crashes, you simply press F7 (load state)....
no time loss resetting the computer.

Van Mirg

Expert (88)

afbeelding van Mirg

26-09-2005, 13:57

norakomi: I only have openMSX, as I'm on a Mac. I don't use it for coding, though. I like to do that on my MSX. Not because I don't trust openMSX or anything, I just like using that old machine too much. Big smile

Sonic_aka_T: Thanks for the tip! I knew the XOR [register] trick to load 0 into a register, but I forget it quite often.. Ah well, I'll keep coding and coding and after a while, I'll learn to use it every time. Smile

Van Mirg

Expert (88)

afbeelding van Mirg

26-09-2005, 22:38

Hmm, I'm having a tiny keymatrix related problem..

I'm trying to write a program that keeps looking for a pressed spacekey. If the spacekey is pressed, the program should end.

This works:

        ORG $C000

KEYS:   EQU $FBE5

        CALL $9F

KEYHDL: LD A,(KEYS+8)
        BIT 0,A
        JP Z,SPACE
        JP KEYHDL

EINDE:  RET

SPACE:  LD A,65
        CALL $A2
        JP EINDE

The CALL $9F doesn't really belong there, of course, as I'm wanting to only check the keyboard matrix. The weird thing is that when I delete that instruction, the program just keeps looping forever, and nog "A" is printed by the SPACE routine, so I guess it never gets called at all.

Does $9F initialise the keyboard in some way, or do I have something plain wrong in my code? The code is almost exactly copied from map.tni.nl's Keyboard matrices page.

Van Sonic_aka_T

Enlighted (4130)

afbeelding van Sonic_aka_T

27-09-2005, 00:27

Sonic_aka_T: Thanks for the tip! I knew the XOR [register] trick to load 0 into a register, but I forget it quite often.. Ah well, I'll keep coding and coding and after a while, I'll learn to use it every time. SmileIt only works with A tho, but it can save quite some space indeed... Smile

Pagina 4/5
1 | 2 | 3 | | 5