tane Posted August 10, 2021 Share Posted August 10, 2021 This compiles and works, but... org $609 general.launcher address1 = $1234 lda #<:address1 sta $4000 lda #>:address1 sta $4001 jump jmp jump run general.launcher ... not the following. The only difference is ".local" and ".endl". How can be created a local procedure with non-global labels inside? org $609 general.launcher .local address1 = $1234 lda #<:address1 sta $4000 lda #>:address1 sta $4001 .endl jump jmp jump run general.launcher Quote Link to comment Share on other sites More sharing options...
tebe Posted August 10, 2021 Share Posted August 10, 2021 remove ':' char ':' is for primary scope 1 Quote Link to comment Share on other sites More sharing options...
shanti77 Posted August 10, 2021 Share Posted August 10, 2021 (edited) org $600 A=1 run lda #A ;global A=1 ldx #EXAMPLE.A ;local A=2 rts .local EXAMPLE A=2 lda #A ;local A=2 ldx #:A ;global A=1 .endl run run Edited August 10, 2021 by shanti77 Quote Link to comment Share on other sites More sharing options...
tane Posted August 10, 2021 Author Share Posted August 10, 2021 Thanks all. The idea was to convert the macro CopyMemory (NRV, 2009) to a function in order to save space if multiple times is applied. As Macro: ;-------------------------------------------------------------------------------- ; CopyMemory [source address] [dest address] [bytes] ;-------------------------------------------------------------------------------- ; warning, using some page zero memory .macro CopyMemory copyMemPtr1 = 254 copyMemPtr2 = 252 copyMemCounter = 250 .if :0 <> 3 .error "CopyMemory error" .else ldy #0 lda #<:1 sta copyMemPtr1 lda #>:1 sta copyMemPtr1+1 lda #<:2 sta copyMemPtr2 lda #>:2 sta copyMemPtr2+1 .if :3 < 256 copyMemLoop1 lda (copyMemPtr1),y sta (copyMemPtr2),y iny cpy #:3 bne copyMemLoop1 .else lda #<:3 sta copyMemCounter lda #>:3 sta copyMemCounter+1 copyMemLoop2 lda (copyMemPtr1),y sta (copyMemPtr2),y iny bne copyMemB1 inc copyMemPtr1+1 inc copyMemPtr2+1 copyMemB1 lda copyMemCounter bne copyMemB2 dec copyMemCounter+1 copyMemB2 dec copyMemCounter lda copyMemCounter ora copyMemCounter+1 bne copyMemLoop2 .endif .endif .endm As 2 functions: function.main .local ///////////////////////////// Copy memory procedure - begin /////////////// TO EDIT VARIABLES TO THE RIGHT OF EQUAL: address.current.begin = $1234 address.current.fin = $5678 address.destiny.begin = $4321 ;[$address.current.begin - $address.current.fin] copy to [$address.destiny.begin - $address.destiny.fin] /////////////// ;Copy addresses to memory - begin: value.data.1 = address.current.begin value.data.2 = address.destiny.begin value.data.3 = address.current.fin-address.current.begin+1 lda #<value.data.1 ; ":" removed inside a local procedure (lda #<:value.data.1) sta copyMemPtr1 lda #>value.data.1 sta copyMemPtr1+1 lda #<value.data.2 sta copyMemPtr2 lda #>value.data.2 sta copyMemPtr2+1 lda #<value.data.3 sta copyMemCounter lda #>value.data.3 sta copyMemCounter+1 ;Copy addresses to memory - end jsr function.copy.memory ///////////////////////////// Copy memory procedure - end .endl rts function.copy.memory ;Variables: copyMemPtr1 = 254 copyMemPtr2 = 252 copyMemCounter = 250 ;Original macro: ldy #0 copyMemLoop2 lda (copyMemPtr1),y sta (copyMemPtr2),y iny bne copyMemB1 inc copyMemPtr1+1 inc copyMemPtr2+1 copyMemB1 lda copyMemCounter bne copyMemB2 dec copyMemCounter+1 copyMemB2 dec copyMemCounter lda copyMemCounter ora copyMemCounter+1 bne copyMemLoop2 ;Clean temp bytes of macro CopyMemory lda #$00 sta $fa sta $fb sta $fc sta $fd sta $fe sta $ff rts 1 Quote Link to comment Share on other sites More sharing options...
ivop Posted August 10, 2021 Share Posted August 10, 2021 11 minutes ago, tane said: Thanks all. The idea was to convert the macro CopyMemory (NRV, 2009) to a function in order to save space if multiple times is applied. I see what you want to do, but you lost the speed optimization for 256 bytes or less copies. You could also put the setting of the source, destination and length, and the jsr in a macro. That macro could decide whether to call your current copy routine, or the <=256 copy routine. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.