Hello everyone,
I have just joined up and am pretty much at the beginning of my Asm learning curve so I hope you will all forgive any silly questions. I've been playing around with PowerBasic at a hobby level for a little while and there seems to be a lot of PB'ers who slip Asm into their code. As someone who grew up in the days of the Vic20 and C64, when Asm was essential to get decent game performance, I've always been intrigued by this mysterious black art! Now I hope to find out more.
Look forward to chatting with you all.
Peace, Steven
Steve,
Welcome to the forum. enjoy! :icon14:
Dave.
welcome to the forum Steve :t
the admin guy, here, is Hutch - i am sure you have seen him in the PB forum
don't know how many more Steve's we can have, though - lol
Hi Steve,
Welcome to the forum.
Hi Steve,
Welcome on board. With the current versions of PB you can write very close to MASM style code once you are familiar with it. Here is a sample doing both simple PB function form and the lower level FASTPROC form which is near identical to MASM code..
' ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
FUNCTION szCopy2(ByVal psrc as DWORD,ByVal pdst as DWORD) as DWORD
#REGISTER NONE
! mov esi, psrc ; load source address
! mov edi, pdst ; load destination address
! xor ecx, ecx ; zero index
! jmp lbl0
#align 16
lbl0:
! movzx eax, BYTE PTR [esi+ecx] ; read byte
! mov [edi+ecx], al ; write byte
! test eax, eax ; test for terminator
! jz lbl1 ; exit loop on zero
! movzx eax, BYTE PTR [esi+ecx+1] ; read byte
! mov [edi+ecx+1], al ; write byte
! test eax, eax ; test for terminator
! jz lbl1 ; exit loop on zero
! movzx eax, BYTE PTR [esi+ecx+2] ; read byte
! mov [edi+ecx+2], al ; write byte
! test eax, eax ; test for terminator
! jz lbl1 ; exit loop on zero
! movzx eax, BYTE PTR [esi+ecx+3] ; read byte
! mov [edi+ecx+3], al ; write byte
! add ecx, 4
! test eax, eax ; test for terminator
! jnz lbl0 ; loop back if not zero
lbl1:
! mov FUNCTION, ecx ; return value is the copied length
End FUNCTION
' ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
FASTPROC copybytes2
' ------------------------------------------
' arguments are, 1. [esp+4] source address
' 2. [esp+8] destination address
' ------------------------------------------
PREFIX "!"
push esi ; preserve ESI, adds 4 to stack
mov esi, [esp+4][4] ; load source address
mov edx, [esp+8][4] ; load destination address
xor ecx, ecx ; zero index
jmp lbl0
align 16
lbl0:
movzx eax, BYTE PTR [esi+ecx] ; read byte
mov [edx+ecx], al ; write byte
test eax, eax ; test for terminator
jz lbl1 ; exit loop on zero
movzx eax, BYTE PTR [esi+ecx+1] ; read byte
mov [edx+ecx+1], al ; write byte
test eax, eax ; test for terminator
jz lbl1 ; exit loop on zero
movzx eax, BYTE PTR [esi+ecx+2] ; read byte
mov [edx+ecx+2], al ; write byte
test eax, eax ; test for terminator
jz lbl1 ; exit loop on zero
movzx eax, BYTE PTR [esi+ecx+3] ; read byte
mov [edx+ecx+3], al ; write byte
add ecx, 4
test eax, eax ; test for terminator
jnz lbl0 ; loop back if not zero
lbl1:
pop esi ; restores ESI, subs 4 from stack
ret 8 ; balance stack on exit
END PREFIX
END FASTPROC
' ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
Hi Steven,
welcome to the forum.
Gunther
Thanks for all the welcomes guys!
Hutch: Thanks for going to the trouble of posting that code. It's a little bit beyond me right now, but I'm keen to get up to speed so I'm going to have a play around with it.