Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
23 user(s) are online (11 user(s) are browsing Forums)

Members: 2
Guests: 21

kas1e, sailor, more...

Headlines

 
  Register To Post

680x0 asembler problems.
Home away from home
Home away from home


See User information
I have this code, it should wait for 10 sec, but it does not.

SECTION main,CODE

     incdir    
include:
    include    
exec/exec_lib.i
    
include    exec/ports.i
    
include    exec/types.i
    
include    exec/execbase.i
    
include    exec/memory.i
    
include    exec/lists.i

    
include    devices/timer.i

    
include    graphics/gfxbase.i
    
include    graphics/graphics_lib.i
    
include    graphics/rastport.i
    
include     graphics/scale.i

;    include    graphics/rpattr.i

    
include    intuition/intuition_lib.i
    
include    intuition/intuition.i

    
include    dos/dos_lib.i
    
include    dos/dosextens.i


OldOpenLibrary EQU 
-$0198
CloseLibrary EQU    -$019E

    lea dos_library_name
(pc),a1
    move
.l    4.w,a6
    jsr        OldOpenLibrary
(a6)
    
move.l    d0,DOSBase
    beq    
.Out

    move
.l    sp,D0

    move
.l    #text_debug,_out_text
    
jsr        .print_text


    bsr    
.open_timer_device

;-------------------------------------------------------------------

    
bsr    .set_timer_to_10sec
    move
.w    #1,timer_device_set

; ----------------------------------------------------------------

    
move.l    timer_request,a1        DoIO(A1)
    
move.l    #text_SendIO,_out_text
    
jsr        .print_text

    move
.l    4.w,a6
    jsr    _LVOSendIO
(a6)

; -----------------------------------------------------------------

    ; 
WaitPort
    move
.l    timer_msgport,A0

    move
.l    #text_WaitPort,_out_text
    
jsr        .print_text

    move
.l    4.w,a6
    jsr    _LVOWaitPort
(a6)

;-------------------------------------------------------------------

    
bsr    .set_timer_to_10sec
    move
.w    #1,timer_device_set

; ----------------------------------------------------------------

    
move.l    timer_request,a1        DoIO(A1)
    
move.l    #text_SendIO,_out_text
    
jsr        .print_text

    move
.l    4.w,a6
    jsr    _LVOSendIO
(a6)

; -----------------------------------------------------------------

    ; 
WaitPort
    move
.l    timer_msgport,A0

    move
.l    #text_WaitPort,_out_text
    
jsr        .print_text

    move
.l    4.w,a6
    jsr    _LVOWaitPort
(a6)

;-----------------------------------------------------------------

    
bsr    .close_timer_device

    move
.l    #IO_SIZE,D0
    
move.l    #IOTV_TIME,D1
    
move.l    #TV_SIZE,D2
    
move.l    #IOTV_SIZE,D3

    
move.l    #text_debug,_out_text
    
jsr        .print_text

    
Close Dos.library
    move
.l    DOSBase,a1
    move
.l    4.w,a6
    jsr    CloseLibrary
(A6)

.
Out
    rts

.set_timer_to_10sec
    move
.l    timer_request,A0
    move
.l    #TR_ADDREQUEST,IO_COMMAND(A0)
    
move.l    #0,IO_FLAGS(A0)    
    
move.l    #0,IO_ERROR(A0)    ; reset error
    
move.l    #10,IOTV_TIME+TV_SECS(A0)
    
move.l    #0,IOTV_TIME+TV_MICRO(A0)
    
rts

.open_timer_device
;    movem    D0-D7/A0-A6,-(SP)

    
move.l    #text_create_port,_out_text
    
move.l    #0,D0
    
jsr        .print_text

    move
.l    4.w,a6
    jsr        _LVOCreateMsgPort
(a6)
    
move.l    d0,timer_msgport

    move
.l    #text_return_value,_out_text
    
jsr        .print_text

    
Is ok?
    
cmpi.w    #0,D0
    
BEQ        .open_timer_device_failed

    
; ***** Create Timer Request *****
    
move.l    timer_msgport,A0    ;     MsgPort
    move
.l    #IOTV_SIZE,D0    ;    Timer Request Size

    
move.l    #text_create_timer_request,_out_text
    
jsr        .print_text

    move
.l    4.w,a6    ;    ExecBase
    jsr        _LVOCreateIORequest
(a6)
    
move.l    D0,timer_request        D0 is stored in timer_request

    move
.l    #text_return_value,_out_text
    
jsr        .print_text

    
Is ok?
    
cmpi.l    #0,D0
    
BEQ        .open_timer_device_failed

    
; ***** Open Device *****
    
move.l    #timer_device_name,A0
;    move.l    #UNIT_MICROHZ,D0
    
move.l    #UNIT_VBLANK,D0            ; unit
    
move.l    timer_request,A1
    move
.l    #0,D1                    ; flags

    
move.l    #text_open_device,_out_text
    
jsr        .print_text

    move
.l    4.w,a6
    jsr        _LVOOpenDevice
(a6)

    
move.l    #text_return_value,_out_text
    
jsr        .print_text

.open_timer_device_failed
;    movem    (SP)+,D0-D7/A0-A6     ;        exit early
    rts

.close_timer_device

;    movem    D0-D7/A0-A6,-(SP)

    
move.w    timer_device_set,D0
    cmpi
.w    #0,d0
    
BEQ        .safe_to_close_device

    move
.l    timer_request,A0
    move
.l    (A0),D0

    cmpi
.w    #0,d0
    
BEQ        .no_timer_request

    move
.l    #text_abort_io,_out_text
    
jsr        .print_text

    
AbortIO
    move
.l    d0,a1
    move
.l    4.w,a6
    jsr    _LVOWaitIO
(a6)

    
move.l    #text_WaitIO,_out_text
    
jsr        .print_text

    
WaitIO
    move
.l    timer_request,A1
    move
.l    4.w,a6
    jsr    _LVOWaitIO
(a6)

.
safe_to_close_device

    
CloseDevice
    move
.l    timer_request,A0
    move
.l    A0,D0

    cmpi
.w    #0,d0
    
BEQ        .no_timer_request
    
    move
.l      D0,A0

    move
.l    #text_close_device,_out_text
    
jsr        .print_text

    move
.l    4.w,a6                ExceBase
    jsr    _LVOCloseDevice
(a6)

    
move.l    #text_delete_io_request,_out_text
    
jsr        .print_text

    
DeleteIORequest
    move
.l    timer_request,A0
    move
.l    4.w,a6                ExceBase
    jsr    _LVODeleteIORequest
(a6)

.
no_timer_request

    
DeleteIMsgPort
    move
.l    timer_request,A0
    move
.l    A0,d0

    move
.l    timer_msgport,D0
    cmpi
.w    #0,d0
    
BEQ        .no_timer_msgport

    move
.l    D0,A0

    move
.l    #text_delete_msgport,_out_text
    
jsr        .print_text

    jsr    _LVODeleteMsgPort
(a6)

.
no_timer_msgport

    move
.l    #text_end_of_function,_out_text
    
jsr        .print_text

;    movem    (SP)+,D0-D7/A0-A6
    rts


.print_text

    move
.l    D0,_lost_D0
    move
.l    D1,_lost_D1
    move
.l    D2,_lost_D2
    move
.l    A0,_lost_A0
    move
.l    A1,_lost_A1
    move
.l    A6,_lost_A6

    move
.l    #printf_args,A1

    
move.l    _out_text,(A1)+
    
move.l    D0,(A1)+
    
move.l    D1,(A1)+
    
move.l    D2,(A1)+
    
move.l    D3,(A1)+
    
move.l    D4,(A1)+
    
move.l    D5,(A1)+
    
move.l    D6,(A1)+
    
move.l    D7,(A1)+

    
move.l    A0,(A1)+
    
move.l    _lost_A1,(A1)+
    
move.l    A2,(A1)+
    
move.l    A3,(A1)+
    
move.l    A4,(A1)+
    
move.l    A5,(A1)+
    
move.l    A6,(A1)+
    
move.l    A7,(A1)+

    
move.l    #PRINT_FMT,D1    ; FMT
    
move.l    #printf_args,D2    ; ARGS
    
move.l    DOSBase,a6        DosBase
    jsr        _LVOVPrintf
(a6)    ; Printf

    move
.l    _lost_D0,D0
    move
.l    _lost_D1,D1
    move
.l    _lost_D2,D2
    move
.l    _lost_A0,A0
    move
.l    _lost_A1,A1
    move
.l    _lost_A6,A6

    rts

even
timer_msgport        dc
.l 0
timer_request        dc
.l 0
timer_device_set    dc
.w    0
DOSBase            dc
.l 0

_out_text            dc
.l 0

printf_args        ds
.l    17

_lost_D0            dc
.l 0
_lost_D1            dc
.l 0
_lost_D2            dc
.l 0
_lost_D3            dc
.l 0
_lost_D4            dc
.l 0
_lost_D5            dc
.l 0
_lost_D6            dc
.l 0
_lost_D7            dc
.l 0

_lost_A0            dc
.l 0
_lost_A1            dc
.l 0
_lost_A2            dc
.l 0
_lost_A3            dc
.l 0
_lost_A4            dc
.l 0
_lost_A5            dc
.l 0
_lost_A6            dc
.l 0
_lost_A7            dc
.l 0

text_debug                dc
.b    "debug",0

text_end_of_function        dc
."end of function",0
text_time_to_close_timer_device    dc
.b    "time to close timer.device",0
text_create_timer_request    dc
."create timer request (A0, D0)",0
text_create_msgport        dc
.b    "CreateMsgPort ()",0
text_delete_msgport        dc
.b    "DeleteMsgPort",0
text_close_library            dc
.b    "CloseLibrary",0
text_open_library            dc
.b    "OpenLibrary",0
text_close_device            dc
."CloseDevice(A1)",0
text_open_device            dc
.b    "open device(A0,D0,A1,D1)",0
text_create_port            dc
."CreatePort",0
text_return_value            dc
."return value",0
text_abort_io                dc
."AbortIO(A1)",0
text_WaitPort                dc
."WaitPort(A0)",0
text_WaitIO                dc
."WaitIO(A1)",0
text_DoIO                    dc
."DoIO(A1)",0
text_SendIO                dc
."SendIO(A1)",0

text_delete_io_request        dc
."delete io request",0


timer_device_name            dc
.b    "timer.device",0;
dos_library_name            dc.b    "dos.library",0

PRINT_FMT                dc
."%s:",10
                        dc
.b    "D0 %08lx D1 %08lx D2 %08lx D3 %08lx D4 %08lx D5 %08lx D6 %08lx D7 %08lx",10
                        dc
.b    "A0 %08lx A1 %08lx A2 %08lx A3 %08lx A4 %08lx A5 %08lx A6 %08lx A7 %08lx",10
                        dc
.b    10,0


program outputs this:

debug:
D0 5C6EE000 D1 1804CEE9 D2 000F5000 D3 5D42EC40 D4 00000001 D5 FFD50001 D6 FFD60001 D7 60133BA4
A0 5D42EC40 A1 60134015 A2 5C5F90DC A3 60133BA4 A4 5C6EE004 A5 
02817F0C A6 02A7B402 A7 5C6EDFFC

CreatePort
:
D0 00000000 D1 1804CEE9 D2 000F5000 D3 5D42EC40 D4 00000001 D5 FFD50001 D6 FFD60001 D7 60133BA4
A0 5D42EC40 A1 60134015 A2 5C5F90DC A3 60133BA4 A4 5C6EE004 A5 
02817F0C A6 02A7B402 A7 5C6EDFF8

return value:
D0 5F28C540 D1 1804CEE9 D2 000F5000 D3 5D42EC40 D4 00000001 D5 FFD50001 D6 FFD60001 D7 60133BA4
A0 5D42EC40 A1 60134015 A2 5C5F90DC A3 60133BA4 A4 5C6EE004 A5 
02817F0C A6 02A7B402 A7 5C6EDFF8

create timer request 
(A0D0):
D0 00000028 D1 1804CEE9 D2 000F5000 D3 5D42EC40 D4 00000001 D5 FFD50001 D6 FFD60001 D7 60133BA4
A0 5F28C540 A1 60134015 A2 5C5F90DC A3 60133BA4 A4 5C6EE004 A5 
02817F0C A6 02A7B402 A7 5C6EDFF8

return value:
D0 6071E390 D1 1804CEE9 D2 000F5000 D3 5D42EC40 D4 00000001 D5 FFD50001 D6 FFD60001 D7 60133BA4
A0 5F28C540 A1 60134015 A2 5C5F90DC A3 60133BA4 A4 5C6EE004 A5 
02817F0C A6 02A7B402 A7 5C6EDFF8

open device
(A0,D0,A1,D1):
D0 00000001 D1 00000000 D2 000F5000 D3 5D42EC40 D4 00000001 D5 FFD50001 D6 FFD60001 D7 60133BA4
A0 60134008 A1 6071E390 A2 5C5F90DC A3 60133BA4 A4 5C6EE004 A5 
02817F0C A6 02A7B402 A7 5C6EDFF8

return value:
D0 00000000 D1 00000000 D2 000F5000 D3 5D42EC40 D4 00000001 D5 FFD50001 D6 FFD60001 D7 60133BA4
A0 60134008 A1 6071E390 A2 5C5F90DC A3 60133BA4 A4 5C6EE004 A5 
02817F0C A6 02A7B402 A7 5C6EDFF8

SendIO
(A1):
D0 00000000 D1 00000000 D2 000F5000 D3 5D42EC40 D4 00000001 D5 FFD50001 D6 FFD60001 D7 60133BA4
A0 6071E390 A1 6071E390 A2 5C5F90DC A3 60133BA4 A4 5C6EE004 A5 
02817F0C A6 02A7B402 A7 5C6EDFFC

WaitPort
(A0):
D0 00000000 D1 00000000 D2 000F5000 D3 5D42EC40 D4 00000001 D5 FFD50001 D6 FFD60001 D7 60133BA4
A0 5F28C540 A1 6071E390 A2 5C5F90DC A3 60133BA4 A4 5C6EE004 A5 
02817F0C A6 02A7B402 A7 5C6EDFFC

SendIO
(A1):
D0 6071E390 D1 00000000 D2 000F5000 D3 5D42EC40 D4 00000001 D5 FFD50001 D6 FFD60001 D7 60133BA4
A0 6071E390 A1 6071E390 A2 5C5F90DC A3 60133BA4 A4 5C6EE004 A5 
02817F0C A6 02A7B402 A7 5C6EDFFC

WaitPort
(A0):
D0 6071E390 D1 00000000 D2 000F5000 D3 5D42EC40 D4 00000001 D5 FFD50001 D6 FFD60001 D7 60133BA4
A0 5F28C540 A1 6071E390 A2 5C5F90DC A3 60133BA4 A4 5C6EE004 A5 
02817F0C A6 02A7B402 A7 5C6EDFFC

AbortIO
(A1):
D0 6071E390 D1 00000000 D2 000F5000 D3 5D42EC40 D4 00000001 D5 FFD50001 D6 FFD60001 D7 60133BA4
A0 6071E390 A1 6071E390 A2 5C5F90DC A3 60133BA4 A4 5C6EE004 A5 
02817F0C A6 02A7B402 A7 5C6EDFF8

WaitIO
(A1):
D0 FFFFFFFD D1 00000000 D2 000F5000 D3 5D42EC40 D4 00000001 D5 FFD50001 D6 FFD60001 D7 60133BA4
A0 6071E390 A1 6071E390 A2 5C5F90DC A3 60133BA4 A4 5C6EE004 A5 
02817F0C A6 02A7B402 A7 5C6EDFF8

CloseDevice
(A1):
D0 6071E390 D1 00000000 D2 000F5000 D3 5D42EC40 D4 00000001 D5 FFD50001 D6 FFD60001 D7 60133BA4
A0 6071E390 A1 6071E390 A2 5C5F90DC A3 60133BA4 A4 5C6EE004 A5 
02817F0C A6 02A7B402 A7 5C6EDFF8

delete io request
:
D0 6071E390 D1 00000000 D2 000F5000 D3 5D42EC40 D4 00000001 D5 FFD50001 D6 FFD60001 D7 60133BA4
A0 6071E390 A1 6071E390 A2 5C5F90DC A3 60133BA4 A4 5C6EE004 A5 
02817F0C A6 02A7B402 A7 5C6EDFF8

DeleteMsgPort
:
D0 5F28C540 D1 00000000 D2 000F5000 D3 5D42EC40 D4 00000001 D5 FFD50001 D6 FFD60001 D7 60133BA4
A0 5F28C540 A1 6071E390 A2 5C5F90DC A3 60133BA4 A4 5C6EE004 A5 
02817F0C A6 02A7B402 A7 5C6EDFF8

end of 
function:
D0 5F28C540 D1 00000000 D2 000F5000 D3 5D42EC40 D4 00000001 D5 FFD50001 D6 FFD60001 D7 60133BA4
A0 5F28C540 A1 6071E390 A2 5C5F90DC A3 60133BA4 A4 5C6EE004 A5 
02817F0C A6 02A7B402 A7 5C6EDFF8

debug
:
D0 00000020 D1 00000020 D2 00000008 D3 00000028 D4 00000001 D5 FFD50001 D6 FFD60001 D7 60133BA4
A0 5F28C540 A1 6071E390 A2 5C5F90DC A3 60133BA4 A4 5C6EE004 A5 
02817F0C A6 02A7B402 A7 5C6EDFFC

(NutsAboutAmiga)

Basilisk II for AmigaOS4
AmigaInputAnywhere
Excalibur
and other tools and apps.
Go to top
Re: 680x0 asembler problems.
Not too shy to talk
Not too shy to talk


See User information
@LiveForIt

Each SendIO has to be complemented by a WaitIO.

The sequence is either

DoIo()

or

SendIO()
WaitIO()

or

SendIO()
Wait() or WaitPort()
WaitIO()


WaitIO will not wait if the request is already finished, but it has to be called anyway to clean up the request before it can be reused.




Go to top
Re: 680x0 asembler problems.
Home away from home
Home away from home


See User information
@thomas

Adding WaitIO(), made AbortIO() crash, I guess there are nothing to abort now, maybe a good sign.

.set_timer_to_10sec 
    move
.l    timer_request,A0 
    move
.l    #TR_ADDREQUEST,IO_COMMAND(A0) 
    
move.l    #0,IO_FLAGS(A0)     
    
move.l    #0,IO_ERROR(A0)    ; reset error 
    
move.l    #10,IOTV_TIME+TV_SECS(A0) 
    
move.l    #0,IOTV_TIME+TV_MICRO(A0) 
    
rts


This is a hex dump of timer Request
I think I most have done something wrong here.

60AEED80:  00000000 00000000 07000000 00006096
60AEED90:  AF900028 6FF43050 6FF4309C 00000000
60AEEDA0
:  0000000A 00000000


60AEEDA0: 0000000A is 10 sec, so that looks fine.
60AEEDA4: 00000000 is 0 micro sec, so that's ok

Most be some thing with the other hex values, I think

(NutsAboutAmiga)

Basilisk II for AmigaOS4
AmigaInputAnywhere
Excalibur
and other tools and apps.
Go to top
Re: 680x0 asembler problems.
Home away from home
Home away from home


See User information
@LiveForIt

ok so io_Command should be 16.
io_flags should be 8 bit
and io_Error should be 8 bit.

Lets se if that fixes, it.

(NutsAboutAmiga)

Basilisk II for AmigaOS4
AmigaInputAnywhere
Excalibur
and other tools and apps.
Go to top
Re: 680x0 asembler problems.
Just popping in
Just popping in


See User information
@LiveForIt

I notice you're using the OldOpenLibrary LVO. If you're testing on OS 4.x that LVO may no longer be valid. It's been deprecated since the new OpenLibrary superseded it in Kickstart 2 or earlier. Passing a zero as the version number parameter to the OpenLibrary LVO does the same thing and is definitely supported.

Go to top
Re: 680x0 asembler problems.
Just popping in
Just popping in


See User information
@Samurai_Crow

FYI, OldOpenLibrary() still works on 68K for OS4, but it obviously doesn't exist in the interfaces.

I tried it out for sh*ts and giggles about a year ago.

Go to top
Re: 680x0 asembler problems.
Home away from home
Home away from home


See User information
@Samurai_Crow

Well as soon as you remove something, things start to crash, anyway can’t remove any JMP ADR inside jmp table anyway, it will just mess up the LVO offsets.

(NutsAboutAmiga)

Basilisk II for AmigaOS4
AmigaInputAnywhere
Excalibur
and other tools and apps.
Go to top
Re: 680x0 asembler problems.
Just can't stay away
Just can't stay away


See User information
@Samurai_Crow

OldOpenLibrary() is just a stub that calls OpenLibrary(libname, 0) so removing it wouldn't result in much savings and it is needed in the jump table for backwards compatibility.

Go to top

  Register To Post

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2016 The XOOPS Project