I can really use some assistance to help me determine why my
simple assembly language subroutine does not function as I would
like. What I need to do is move a number of 16 bit A to D
converter values located at I/O port &H300 to an array in
memory. The A to D values are in a First in-First out memory
that will automatically address the next sample each time an “IN”
instruction to port &H300 is executed. The transfers need to
be done very quickly so have attempted to do the transfers via
in-line assembly in a sub routine. I have established an
ABSOLUTE array starting at &H30000 in which to put the A to D
data values. The following test program shows what I would like
to accomplish. When the program is run, it shows that memory
locations that should have been replaced by the A to D port
values remain as previously initialized.
' Test Program to put A/D Converter Values into memory array
' starting at addres &H30000
DEFINT I 'All "I" Variables are Intergers (%)
DIM ABSOLUTE AtoD??(1:32760) AT &H30000 'Create Large Array Starting
'at address &H30000.
DIM AtoDAddress AS DWORD PTR 'Address pointer to A to D Data
AtoDAddress = &H30000 'Set the AtoD address pointer to the start of AtoD Data
CLS
PRINT "AtoDAddress Pointer is "HEX$(AtoDAddress)
PRINT "Fill part of the AtoD array with known values"
' Want to fill the AtoD array with a seqence of known values
I = 8
W1?? = 0
DO ' Fill AtoD array with words from 0 to 8
@AtoDAddress = W1?? 'put Word value into AtoD array
AtoDAddress = AtoDAddress + 2 ' Increment to next Word address
W1?? = W1?? + 1 'Increment W1
I = I - 1
LOOP While I > 0
PRINT "AtoDAddress Pointer is " HEX$(AtoDAddress)
I = 0
AtoDAddress = &H30000
PRINT "AtoDAddress Pointer is "HEX$(AtoDAddress)
' Want to display the word values in the AtoD array
DO ' Display AtoD array words from locations 0 through 8
W1?? = @AtoDAddress 'put Array value into W1??
PRINT "A/D Array Address/Values " HEX$(AtoDAddress), HEX$(W1??) ' Display
' address then Hex value
AtoDAddress = AtoDAddress + 2 ' Increment to next Word address
I = I + 2
LOOP While I < 16
PRINT "AtoDAddress Pointer is "HEX$(AtoDAddress)
AtoDAddress = &H30000
AddOffset?? = &H0000 ' Set address offset to 0000h
NofS% = 6
PRINT "Called INSTRING SubRoutine " (NofS%) (AddOffset??)
CALL INSTRING(BYVAL NofS%, BYVAL AddOffset??) ' Call INSTRING
I = 0
PRINT "AtoDAddress Pointer is "HEX$(AtoDAddress)
' Want to display the word values in the AtoD array
DO ' Display AtoD array words from locations 0 through 8
W1?? = @AtoDAddress 'put Array value into W1??
PRINT "A/D Array Address/Values is " HEX$(I), HEX$(W1??) ' Display address
'then Hex value
AtoDAddress = AtoDAddress + 2 ' Increment to next Word address
I = I + 2
LOOP While I < 16
PRINT "AtoDAddress Pointer is "HEX$(AtoDAddress)
END
SUB INSTRING(BYVAL No%, BYVAL AddOff??) 'Move A/D Values to memory
! push DI ; Save DI
! pushf ; Save the flag register
! mov AX, &H3000 ; Move the segment 3000H to Register AX
! mov ES, AX ; Move the segment 3000H in AX to Register ES
! mov AX, AddOff?? ; Move Offset address into AX
! mov DI, AX ; Move the Address Offset in AX to Register DI
! mov CX, No% ; Move Number of A/D samples to CX
! mov DX, &H300 ; Move the A/D port address into DX
! cld ; Clear direction flag (to increment addrss pointer)
TRANSDATA:
! in AX, DX ; Input A/D Word from I/O port &H300 & put into AX
! stosw ; Store A/D Word in [AtoDAddress] (ES
I), Incr. DI,
! loop TRANSDATA ; Decrement CX. Jump to TRANSDATA if not zero
! popf ; Restore Flag Register
! pop DI ; Restore DI
END SUB
------------------
simple assembly language subroutine does not function as I would
like. What I need to do is move a number of 16 bit A to D
converter values located at I/O port &H300 to an array in
memory. The A to D values are in a First in-First out memory
that will automatically address the next sample each time an “IN”
instruction to port &H300 is executed. The transfers need to
be done very quickly so have attempted to do the transfers via
in-line assembly in a sub routine. I have established an
ABSOLUTE array starting at &H30000 in which to put the A to D
data values. The following test program shows what I would like
to accomplish. When the program is run, it shows that memory
locations that should have been replaced by the A to D port
values remain as previously initialized.
' Test Program to put A/D Converter Values into memory array
' starting at addres &H30000
DEFINT I 'All "I" Variables are Intergers (%)
DIM ABSOLUTE AtoD??(1:32760) AT &H30000 'Create Large Array Starting
'at address &H30000.
DIM AtoDAddress AS DWORD PTR 'Address pointer to A to D Data
AtoDAddress = &H30000 'Set the AtoD address pointer to the start of AtoD Data
CLS
PRINT "AtoDAddress Pointer is "HEX$(AtoDAddress)
PRINT "Fill part of the AtoD array with known values"
' Want to fill the AtoD array with a seqence of known values
I = 8
W1?? = 0
DO ' Fill AtoD array with words from 0 to 8
@AtoDAddress = W1?? 'put Word value into AtoD array
AtoDAddress = AtoDAddress + 2 ' Increment to next Word address
W1?? = W1?? + 1 'Increment W1
I = I - 1
LOOP While I > 0
PRINT "AtoDAddress Pointer is " HEX$(AtoDAddress)
I = 0
AtoDAddress = &H30000
PRINT "AtoDAddress Pointer is "HEX$(AtoDAddress)
' Want to display the word values in the AtoD array
DO ' Display AtoD array words from locations 0 through 8
W1?? = @AtoDAddress 'put Array value into W1??
PRINT "A/D Array Address/Values " HEX$(AtoDAddress), HEX$(W1??) ' Display
' address then Hex value
AtoDAddress = AtoDAddress + 2 ' Increment to next Word address
I = I + 2
LOOP While I < 16
PRINT "AtoDAddress Pointer is "HEX$(AtoDAddress)
AtoDAddress = &H30000
AddOffset?? = &H0000 ' Set address offset to 0000h
NofS% = 6
PRINT "Called INSTRING SubRoutine " (NofS%) (AddOffset??)
CALL INSTRING(BYVAL NofS%, BYVAL AddOffset??) ' Call INSTRING
I = 0
PRINT "AtoDAddress Pointer is "HEX$(AtoDAddress)
' Want to display the word values in the AtoD array
DO ' Display AtoD array words from locations 0 through 8
W1?? = @AtoDAddress 'put Array value into W1??
PRINT "A/D Array Address/Values is " HEX$(I), HEX$(W1??) ' Display address
'then Hex value
AtoDAddress = AtoDAddress + 2 ' Increment to next Word address
I = I + 2
LOOP While I < 16
PRINT "AtoDAddress Pointer is "HEX$(AtoDAddress)
END
SUB INSTRING(BYVAL No%, BYVAL AddOff??) 'Move A/D Values to memory
! push DI ; Save DI
! pushf ; Save the flag register
! mov AX, &H3000 ; Move the segment 3000H to Register AX
! mov ES, AX ; Move the segment 3000H in AX to Register ES
! mov AX, AddOff?? ; Move Offset address into AX
! mov DI, AX ; Move the Address Offset in AX to Register DI
! mov CX, No% ; Move Number of A/D samples to CX
! mov DX, &H300 ; Move the A/D port address into DX
! cld ; Clear direction flag (to increment addrss pointer)
TRANSDATA:
! in AX, DX ; Input A/D Word from I/O port &H300 & put into AX
! stosw ; Store A/D Word in [AtoDAddress] (ES

! loop TRANSDATA ; Decrement CX. Jump to TRANSDATA if not zero
! popf ; Restore Flag Register
! pop DI ; Restore DI
END SUB
------------------
Comment