Code: Select all
LDA#&81:LDX#1:LDY#0:JSR&FFF4
Code: Select all
LDA#&81:LDX#1:LDY#0:JSR&FFF4
-68 is &FFBC so you should be loading Y with &FF and X with &BC.AJW wrote: ↑Sat Jul 04, 2020 9:07 pmWhat is the machine code equivalent of IF INKEY-68 etc? I'm using:Code: Select all
LDA#&81:LDX#1:LDY#0:JSR&FFF4
Yes, and if the delay time is negative.....
Code: Select all
$ bbcbasic
PDP11 BBC BASIC IV Version 0.32
(C) Copyright J.G.Harston 1989,2005-2020
>_
Yes. It's the parameter for INKEY which if positive is the maximum wait time and if negative is the key to be tested. Exactly the same is true in assembly language: the parameter goes into YX (as a 16-bit signed number) in that case, so again if it's positive it will set the wait time and if negative the key number. You are perhaps overthinking this: try doing what I suggested (set Y to &FF and X to &BC) and see what happens!
So now i have to convert all my keys into 2s complement 16bit hex .Richard Russell wrote: ↑Sun Jul 05, 2020 10:47 amYes. It's the parameter for INKEY which if positive is the maximum wait time and if negative is the key to be tested. Exactly the same is true in assembly language: the parameter goes into YX (as a 16-bit signed number) in that case, so again if it's positive it will set the wait time and if negative the key number. You are perhaps overthinking this: try doing what I suggested (set Y to &FF and X to &BC) and see what happens!
Code: Select all
2810 LDA#&81:LDX#1:LDY#0:JSR&FFF4 \inkey(1)
2820 CPX#77:BNEek2:LDA#3:STA&8A:JSR updinput:LDA#1:STA&8B:RTS \m
2830 .ek2 CPX#75:BNEek:LDA#4:STA&8A:JSR updinput:LDA#1:STA&8B:RTS \k
No, you don't: the assembler will do that for you:
Code: Select all
LDA#&81
LDX#(-68 AND &FF)
LDY#((-68 AND &FF00) / 256)
JSR&FFF4
OSBYTE doesn't return the result in A, it returns it in X. See the documentation.What is returned in A?
As 1024MAK commented, the assembly language code does exactly the same thing as the BASIC INKEY() function. That returns zero (FALSE) if the key is not currently pressed and -1 (TRUE) if it is, so that's what X contains on return when you do it in assembler.
Code: Select all
A% = 129
X% = -68 AND &FF
Y% = (-68 AND &FF00) / 256
REPEAT
PRINT ~USR(&FFF4)
UNTIL FALSE
Code: Select all
LDX#(-102 AND&FF)
Code: Select all
CPX#(-1)
In both case the value has to be between 0 and 255 (inclusive) so the equivalent would beAJW wrote: ↑Sun Jul 05, 2020 6:28 pmStrange how I can do:
but not:Code: Select all
LDX#(-102 AND&FF)
It has to be 255Code: Select all
CPX#(-1)
Code: Select all
CPX#(-1 AND &FF)
I assume this is because (-1) will be interpreted as a 32 bit number (&FFFFFFFF), which you cannot compare against. Convert it to an 8 bit number.AJW wrote: ↑Sun Jul 05, 2020 6:28 pmStrange how I can do:
but not:Code: Select all
LDX#(-102 AND&FF)
It has to be 255Code: Select all
CPX#(-1)