euloth@dalcsug.UUCP (George Seto) (06/26/88)
Can anyone using TDI's Modula 2 help a friend of mine out with a question? He is trying to access the System Timer at location $4AB to read the count there. However he can't find a way of doing a peek or actually Long Peek. He has been trying to use the TakeALong command in Modula, but so far, two weeks, no luck. Anyone have tried to do this before? Or in general read a memory location for either a byte or a long? Thanks in advance for any help. George Seto -- ******************************************************************************* * euloth@dalcsug.uucp || Disclaimer: All opinions are my own unless other- * * /\/\/\/\/\/\/\/\/\/\ || wise noted. * ****AKA: Atari Nut*************************************************************
wes@obie.UUCP (Barnacle Wes) (07/01/88)
In article <490@dalcsug.UUCP>, euloth@dalcsug.UUCP (George Seto) writes: > > Can anyone using TDI's Modula 2 help a friend of mine out with a > question? He is trying to access the System Timer at location $4AB > to read the count there. However he can't find a way of doing a > peek or actually Long Peek. He has been trying to use the > TakeALong command in Modula, but so far, two weeks, no luck. In general, to peek at a location in Modula-2, you would use something like: FROM System IMPORT BYTE, WORD, LONG; SysTimer : LONG @ 4ABH; ... WhatEver := SysTimer; The "@" notation tells the compiler the absolute address of this variable is fixed in memory. You can't do this for the system timer on the ST, however, because the system timer is in "protected" memory. To access this protected memory, the CPU has to be in supervisor mode. You can do this with the SuperExec procedure in module XBIOS. This is an example: FROM XBIOS IMPORT SuperExec; FROM System IMPORT LONG; PROCEDURE GetSysTimer : LONG; VAR TheTimer : LONG; PROCEDURE GetIt; VAR SysTimer : LONG @ 4ABH; BEGIN TheTimer := SysTimer; END. BEGIN SuperExec(GetIt); RETURN TheTimer; END. This is probably not entirely correct; it has been a while since I worked in Modula-2. It should be enough to give you an idea of what you have to do, however. Good Luck! -- {uwmcsd1, hpda}!sp7040!obie!wes | "If I could just be sick, I'd be fine." +1 801 825 3468 | -- Joe Housely --
browndf@cs.glasgow.ac.uk (Deryck F Brown) (07/01/88)
The standard way to do memory addressing in Modula2 would be something like this... VAR p : POINTER TO INTEGER; (* 2-byte signed quantity *) contents : INTEGER; BEGIN p := ADDRESS(address); (* address you wish to peek *) contents := p^; (* do a peek *) p^ := contents; (* do a poke *) END. Obviously to access something which is in the ST's protected areas of memory (like the system timer variable) you would have to use the enter supervisor mode call first. To peek/poke quantities other than integers you would need pointers to other quantities e.g. POINTER TO BYTE, POINTER TO WORD, POINTER TO LONGWORD. ps BYTE, WORD, LONGWORD and ADDRESS all have to be imported from SYSTEM. Deryck