I'm trying to find a way to use timer under CP/M+. I've made the code which calls firmware (KL_TIME_PLEASE) but it doesn't work. :(
org &100
kl_time_please equ &bd0d
;; get address of routine to call to execute a firmware function
ld hl,(1)
ld de,&57
add hl,de
ld (firm_jump+1),hl
loop
call firm_jump
dw kl_time_please
call PR00000 ;prints HL as decimal
;; make the end of line
ld de,eol
ld c,9
call 5
ld hl,cnt
dec (hl)
jr nz,loop
;; quit back to command-line
ret
eol db 13,10,"$"
cnt db 20
;; execute a firmware function
firm_jump
jp 0
PR00000 proc
local PRD,PR0
ld de,-10000
CALL PR0
ld de,-1000
CALL PR0
ld de,-100
CALL PR0
ld de,-10
CALL PR0
ld A,L
PRD add a,$30
ld e,a
ld c,2
jp 5 ;bdos
PR0 ld A,$FF
ld B,H
ld C,L
inc A
add HL,DE
jr C,$-4
ld H,B
ld L,C
JR PRD
endp
What is wrong? Or is there any other way to get timer data with Amstrad CPC6128 CP/M+ ? A lot of thanks for any help.
Quote from: litwr on 14:29, 01 January 16
I'm trying to find a way to use timer under CP/M+. I've made the code which calls firmware (KL_TIME_PLEASE) but it doesn't work. :(
org &100
kl_time_please equ &bd0d
;; get address of routine to call to execute a firmware function
ld hl,(1)
ld de,&57
add hl,de
ld (firm_jump+1),hl
loop
call firm_jump
dw kl_time_please
call PR00000 ;prints HL as decimal
;; make the end of line
ld de,eol
ld c,9
call 5
ld hl,cnt
dec (hl)
jr nz,loop
;; quit back to command-line
ret
eol db 13,10,"$"
cnt db 20
;; execute a firmware function
firm_jump
jp 0
PR00000 proc
local PRD,PR0
ld de,-10000
CALL PR0
ld de,-1000
CALL PR0
ld de,-100
CALL PR0
ld de,-10
CALL PR0
ld A,L
PRD add a,$30
ld e,a
ld c,2
jp 5 ;bdos
PR0 ld A,$FF
ld B,H
ld C,L
inc A
add HL,DE
jr C,$-4
ld H,B
ld L,C
JR PRD
endp
What is wrong? Or is there any other way to get timer data with Amstrad CPC6128 CP/M+ ? A lot of thanks for any help.
I had a good look at this, and even use a different routine for printing the number (which was published in AA54), but had no luck with it. The Winape Assembler had a problem with this statement:
jr c,$-4
in the PR0 routine, so I replaced it with jr c,pr0 which I'm presuming was my mistake, though the Assembler was telling me that &-4 was outside it's range ("&" is used instead of "$"), perhaps this line is doing something in your assembler that it's not meant to, though I'm only guessing now, everything else looks fine to me, though it's obviously not giving you the result you want.
The WinAPE assembler shouldn't have a problem with jr c,$-4. I've just tested and it all seems fine and outputs FA as the relative address. $ is the current code location, so $-4 is the current code location minus 4. &-4 is the location #FFFC which would be outside the relative jump range of course.
I have translated the source code to ZSM and assembled with it.
When I execute the COM file, WinAPE hangs.
I don't know what's the problem (yet).
Edit: The following code compiled with MESCC runs perfectly under WinAPE:
#include <mescc.h>
#include <printf.h>
main()
{
patch();
printf("HL = %04x\n", get_time());
}
#asm
patch
ld hl,(1)
ld de,057h
add hl,de
ld (firm_jump + 1),hl
ret
get_time
call firm_jump
defw 0bd0dh
ret
firm_jump
jp 0
#endasm
I think the problem is in the output subroutine.
Quote from: Executioner on 00:22, 02 January 16
The WinAPE assembler shouldn't have a problem with jr c,$-4. I've just tested and it all seems fine and outputs FA as the relative address. $ is the current code location, so $-4 is the current code location minus 4. &-4 is the location #FFFC which would be outside the relative jump range of course.
Well the problem was occurring when I converted the "$" sign to "&". Perhaps the fault lies in what that means?
I haven't seen an assembler use "$" to represent a Hexadecimal number, but I guess it's possible.
Quote from: AMSDOS on 00:56, 02 January 16
I haven't seen an assembler use "$" to represent a Hexadecimal number, but I guess it's possible.
$ is used to represent the current code location. For example,
org #1234
dw $
will generate the address #1234
org #1234
dw $ - 4will generate the address #1230
I am terribly sorry for my stupid question. :( The problem is very easy to solve. I forgot to save HL before BDOS call. So
JP 5
in PR00000 should be replaced by
push HL
call 5
pop HL
I was sure that BDOS (like AMSDOS, IBM PC DOS/BIOS, ...) preserves CPU registers. Thanks for the help anyway. The $-sign means the current code location and it also starts the hexadecimal number in pasmo-cross-assembler.
Ooops! :doh:
Funny bugs (that we all do sometimes) :laugh: