i need to know why when I
that is, move something to the top of the stack
(on my 1040 ST the stack top is $F8000)
and then examine memory at that very address ($F8000)
NOTHING is ever there!
I have some idea but would like to hear an expert opinion.
however if I: "MOVE #$21,-(SP)"
then the stack pointer decreases and I examine memory
at $F8FFE, the "$21" will be there!
also, I wrote the object code for this (improved) Hebrew random print
program. It becomes a .PRG file but when I run it it only prints one line
of Hebrew at the very top of the screen!
The original source code when run from my assembler works as it should,
filling the screen with random Hebrew letters.
AtariAge for some reason won't allow me to attach my .PRG file so
here is the source code for my little work of art that needs your help:
;RANDOM Hebrew PRINTER
;BY 'ACE' with help from ggn of Greece
;April 14, 2019
move.w #$11,-(sp) ;get random
trap #$e ;call GEM
addq.l #$2,sp ;fix stack
and.l #$ffff,d0 ;clear upper 16 bits division not overflow
divu #$1b,d0 ;divide by 27
swap d0 ;modulo to D0
add.b #$c2,d0 ;add 194 to random
move d0,-(sp) ;random on stack
move.w #2,-(sp) ;print it
trap #1 ;call GEM
addq.w #$4,sp ;stack correction
a couple of things, lets start with -(Sp) and (SP)+ or -(Ax) (Ax)+.
ok it actual telling you what its doing.
In case of -(SP),-(Ax) what it means is, it first start with subtracting the length of the data to the Ax/SP pointer and after that is finish, its moves the data ,
so in case if you use a long word. and let say A0 points Address 1000 and you write Move.l #$12345678,-(A0)
it will start with subtracting 4 from A0 so it now pointing to 996, and if you look in address 996 it would say $12345678
same with move.w but its only 2 bytes and of cause move.b its only a byte,
but i am not sure that it work when using a byte on the stack Pointer (SP)
same with (SP)+,(Ax)+ it just mean that the SP or AX will be add to instead of being subtracted from, one more thing to beware of here, is that the add fist will be add after the memory operations.
same example as before
let say A0 points address 996 and the contains in 996 is #$12345678
and if you write Move.l #$0,(A0)+
it will start by moving #0, to address 996 and after that have been done, it now add 4 to the address register.
before the move #0 the address contain the value of #$12345678 after the move.l. A0 now pointing to address 1000 and if you look in memory address 996 it should say zero
but you can remember it like this is the mathematical symbols before the Parenthesis
it will do the sub first (and in this case) the move after.
and if the mathematical symbols are after Parenthesis.
it will do the (in this case) move first and the add after
but the party don't stop here. you can do the same with
why use the -()/()+, I think you get the add and the sub for free. (but I am not 100% sure maybe an other can tell you).
one more thing don't use jmp or jsr there can be cases where you only can use the like jmp (A0)
use bra and brs
i hope you get my nonsense, i have been very sick the last week, and still not 100%.