Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Assembly question
#15
slenkar Wrote:im trying to learn assembly, but keep getting strange results

this program for example
Quote:function FASTCALL downone() as ubyte
asm
INC HL
end asm
end function

function FASTCALL setup() as ubyte
asm
LD HL,16384
end asm
end function
'LD B,0

function FASTCALL drawthis() as ubyte
asm
LD A,128
LD (HL),A
end asm
end function

Dim res as String
setup()
for x=0 to 100
downone()
drawthis()
next

this is supposed to draw something to the screen 100 times
is the for next loop interfering with the assembly?
Probably. From one basic instruction to another, *everything* can be destroyed in assembler (registers, etc).

ZX Basic uses memory (stack) to store temporary results from one instruction to another, but sometimes it realizes that two basic instructions together can be "operated" as a single instruction. And again, this new instruction can be packed with the next one as a single instruction, and so on. But once you insert an ASM block, this optimization is stopped.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 4 Guest(s)