I am experiencing werid behavior from lowlevel.library's GetKey function:
ABSEXECBASE EQU 4
_LVOOpenLibrary EQU -552
_LVOCloseLibrary EQU -414
_LVODelay EQU -198
_LVOGetKey EQU -48
start:
move.l ABSEXECBASE.W,a6
LEA dos_name,A1 ;00452: 43f900000f27
MOVEQ #39,D0 ;00458: 7027
JSR _LVOOpenLibrary(A6) ;0045a: 4eaefdd8
MOVE.L D0,DosBase ;0045e: 23c000000f34
BEQ exit
move.l ABSEXECBASE.W,a6
LEA lowlevel_name,A1 ;00452: 43f900000f27
MOVEQ #39,D0 ;00458: 7027
JSR _LVOOpenLibrary(A6) ;0045a: 4eaefdd8
MOVE.L D0,LowlevelBase ;0045e: 23c000000f34
BEQ exit
loop:
MOVEA.L DosBase,A6
MOVEQ #10,D1
JSR _LVODelay(A6)
MOVEA.L LowlevelBase,A6
JSR _LVOGetKey(A6)
JSR debug_write_ulong
CMPI.L #$45,D0
BNE loop
exit:
MOVEA.L ABSEXECBASE.W,A6
MOVEA.L LowlevelBase,A1
JSR _LVOCloseLibrary(A6)
MOVEA.L ABSEXECBASE.W,A6
MOVEA.L DosBase,A1
JSR _LVOCloseLibrary(A6)
MOVEQ #0,D0
RTS
dos_name:
DC.B "dos.library",0
lowlevel_name:
DC.B "lowlevel.library",0,0
DosBase:
DC.L 0
LowlevelBase:
DC.L 0
_LVOPutStr EQU -948
debug_buffer:
DS.B 10
debug_write_ulong:
MOVEM.L D0-D7/A0-A6, -(A7)
LEA debug_buffer,A0
MOVE.B #48,(A0) ;'0'
MOVE.B #120,1(A0) ;'x'
MOVE.L D0,D1
SWAP D1
LSR.L #8,D1
LSR.L #4,D1
ANDI.L #$000f,D1
CMPI.B #10,D1
BCS.S lab_eq20
SUBI.B #10,D1
ADDI.B #97,D1
BRA.S label20
lab_eq20:
ADDI.B #48,D1
label20:
MOVE.B D1,2(A0)
MOVE.L D0,D1
SWAP D1
LSR.L #8,D1
ANDI.L #$000f,D1
CMPI.B #10,D1
BCS.S lab_eq21
SUBI.B #10,D1
ADDI.B #97,D1
BRA.S label21
lab_eq21:
ADDI.B #48,D1
label21:
MOVE.B D1,3(A0)
MOVE.L D0,D1
SWAP D1
LSR.L #4,D1
ANDI.L #$000f,D1
CMPI.B #10,D1
BCS.S lab_eq22
SUBI.B #10,D1
ADDI.B #97,D1
BRA.S label22
lab_eq22:
ADDI.B #48,D1
label22:
MOVE.B D1,4(A0)
MOVE.L D0,D1
SWAP D1
ANDI.W #$000f,D1
CMPI.B #10,D1
BCS.S lab_eq23
SUBI.B #10,D1
ADDI.B #97,D1
BRA.S label23
lab_eq23:
ADDI.B #48,D1
label23:
MOVE.B D1,5(A0)
MOVE.L D0,D1
LSR.L #8,D1
LSR.L #4,D1
ANDI.W #$000f,D1
CMPI.B #10,D1
BCS.S lab_eq24
SUBI.B #10,D1
ADDI.B #97,D1
BRA.S label24
lab_eq24:
ADDI.B #48,D1
label24:
MOVE.B D1,6(A0)
MOVE.L D0,D1
LSR.L #8,D1
ANDI.W #$000f,D1
CMPI.B #10,D1
BCS.S lab_eq25
SUBI.B #10,D1
ADDI.B #97,D1
BRA.S label25
lab_eq25:
ADDI.B #48,D1
label25:
MOVE.B D1,7(A0)
MOVE.L D0,D1
LSR.L #4,D1
ANDI.W #$000f,D1
CMPI.B #10,D1
BCS.S lab_eq26
SUBI.B #10,D1
ADDI.B #97,D1
BRA.S label26
lab_eq26:
ADDI.B #48,D1
label26:
MOVE.B D1,8(A0)
MOVE.L D0,D1
ANDI.W #$000f,D1
CMPI.B #10,D1
BCS.S lab_eq27
SUBI.B #10,D1
ADDI.B #97,D1
BRA.S label27
lab_eq27:
ADDI.B #48,D1
label27:
MOVE.B D1,9(A0)
MOVE.B #10,10(A0)
MOVE.B #0,11(A0)
MOVEA.L DosBase, A6
MOVE.L #debug_buffer,D1
JSR _LVOPutStr(A6)
MOVEM.L (A7)+, D0-D7/A0-A6
RTS
Try assembling and running the above code (works with PhxAss). First time you run, it will write a line of 0's until you press a key. If you press ESC it will exit. But now the strange thing: The key you last pressed will get "stuck", even across runnings, so the next time you run it, it will exit immidiately with 0x45. I don't think this behavior is intended.
Also I have tested the QueryKeys function, and it doesn't seem to work at all...
Any enlightened comments are welcome!