English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. AMOS

 
 
Thread Tools
Old 28 October 2018, 21:48   #1
volvo_0ne
Registered User
 
Join Date: Mar 2015
Location: Sheffield UK
Posts: 360
Why does this work?

Code:
Rem AMOS Pro 2,00

Rem WHY DOES THIS WORK? 
Rem AS DEEKS & DOKES are to odd addresses???  


Reserve As Data 5,1000

ST=Start(5)+1

N=1

For I=ST To ST+31 Step 2

	Doke I,N
   
	Print I;",";Deek(I)
 
	N=N*2

Next I
volvo_0ne is offline  
Old 28 October 2018, 21:50   #2
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,164
it works because amos can read byte per byte and rebuild the 16 bit word... My Oric already had DEEK & DOKE and was 8 bit.
jotd is online now  
Old 28 October 2018, 22:01   #3
volvo_0ne
Registered User
 
Join Date: Mar 2015
Location: Sheffield UK
Posts: 360
Quote:
Originally Posted by jotd View Post
it works because amos can read byte per byte and rebuild the 16 bit word... My Oric already had DEEK & DOKE and was 8 bit.
Yes, BUT in the manual, it says .....

DEEK function: read two bytes from an even address

word=Deek(address)

DEEK reads a two-byte "word" at a specified address.
This address must be even, or an address error will be generated.


DOKE instruction: change a two-byte word at an even address

Doke address,number

Use the DOKE command to copy a two-byte number between 0 and 65535 into the memory location at a specified even address.

Only DOKE into places where you are certain of safety, because indiscriminate use of this command will almost certainly crash your Amiga!

(My Underlines)
It does not throw up an "address error" and it seems to work ok in this case.
volvo_0ne is offline  
Old 28 October 2018, 22:39   #4
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,164
oh then it works because you're using a 68020+. 68020 and higher are able to read words on odd addresses.
jotd is online now  
Old 28 October 2018, 22:58   #5
volvo_0ne
Registered User
 
Join Date: Mar 2015
Location: Sheffield UK
Posts: 360
Quote:
Originally Posted by jotd View Post
oh then it works because you're using a 68020+. 68020 and higher are able to read words on odd addresses.
AH!

I didn't know that.

I am indeed using an A1200 environment and AMOS 2.00

But even so (leading on to my next question)...........

Sometimes this seems very flaky.

Is there a way of writing/reading a mixture of 8/16 bit integers to consecutive memory locations reliably (odd or even) on all 68X?


for instance I may have sequence $F0 $00 $E710 to be saved (& retrieved) from arbitory addresses as 8 or 16 bit numbers (obviously $E710 is 16 bit & the others are 8 bit)


How would I deal with this without wasting the odd addresses?

I'll never need a number above $FFFF but I could waste a LOT of space by aligning and losing the odd bytes
volvo_0ne is offline  
Old 28 October 2018, 23:02   #6
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,164
use custom DOKE (resp DEEK):

Code:
POKE(address,(value / 256) & 0xFF);
POKE(address+1,value & 0xFF);
(not sure how masking is done in AMOS)
jotd is online now  
Old 01 November 2018, 21:12   #7
volvo_0ne
Registered User
 
Join Date: Mar 2015
Location: Sheffield UK
Posts: 360
Thanks, that has solved my problem nicely

for reference......
I did

Poke address,value and $FF
Poke address+1,(value / 256) and $FF

to enter the values

and

value =Peek(address)+256*Peek(address+1)

to retrieve the value.
volvo_0ne is offline  
Old 01 November 2018, 21:16   #8
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,164
With that, you'll get the same value when writing & reading but you're actually writing your data with the wrong endianness.

address must have MSB, so (value / 256), and address+1 must have LSB, so value and $FF.

Your 2 errors make up, but the data is written in the wrong endian direction.

Try a double POKE on an even address, then a real DEEK you'll see what I mean
jotd is online now  
Old 01 November 2018, 23:14   #9
volvo_0ne
Registered User
 
Join Date: Mar 2015
Location: Sheffield UK
Posts: 360
Quote:
Originally Posted by jotd View Post
With that, you'll get the same value when writing & reading but you're actually writing your data with the wrong endianness.

address must have MSB, so (value / 256), and address+1 must have LSB, so value and $FF.

Your 2 errors make up, but the data is written in the wrong endian direction.

Try a double POKE on an even address, then a real DEEK you'll see what I mean
I realise that (now) but I was used to Z80 notation (from years back) which must have kicked in automatically

It works here just now and it's only for some location data which i'm trialing.

(Unless you can see any problems down the line).......
volvo_0ne is offline  
 


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting More to work methodman support.Apps 2 15 April 2018 13:09
does it work everywhere or not meynaf Coders. Asm / Hardware 1 28 June 2016 23:32
How do I get F4 to work? mrvp support.FS-UAE 3 30 August 2015 20:31
Why no more work on OS 3.9? mfletcher Amiga scene 7 10 May 2009 11:47
Does this work? BarrySWE support.Apps 1 05 October 2005 18:39

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 15:45.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.21006 seconds with 13 queries