Is there sample VIC20 assembly doing wedges for BASIC?

Basic and Machine Language

Moderator: Moderators

User avatar
chysn
Vic 20 Scientist
Posts: 1205
Joined: Tue Oct 22, 2019 12:36 pm
Website: http://www.beigemaze.com
Location: Michigan, USA
Occupation: Software Dev Manager

Re: Is there sample VIC20 assembly doing wedges for BASIC?

Post by chysn »

MrSterlingBS wrote: Sun Jul 23, 2023 11:58 pm Example:
10 @iMUL,5,3 ; integer multiplication 5x3=15

Do i need to PEEK it from the memory location?
Or is there another way?
You can use variables to communicate back to BASIC programs. Either pass the variable name to the @IMUL command, or come up with some other way to determine the variable name.

Code: Select all

lda #"R" + #$80 ; First letter of the variable name. High byte of both characters set means an integer (%)
sta $45         ; Store the first letter in VARNAM zero-page location
lda #$80        ; This is a one-letter variable name, but still need to set high bit
sta $46         ; Store the second character (or null here) in VARNAM+1
jsr $d0e7       ; The routine D0E7 finds or creates the variable and sets a pointer to start of its memory in $47/$48
ldy #1          ; ($47),1 will be the low byte of an integer variable value. Yes, the value is big-endian!
lda #<INTVAL    ; Low byte of the integer to store
sta ($47),y     ; ,,
dey             ; ($47),0 will be the high byte of an integer variable value.
lda #>INTVAL    ; High byte of the integer to store
sta ($47),y     ; ,,
Execute this code, using whatever INTVAL you want, and then in BASIC you can just use it as an integer variable:

Code: Select all

?R%
See Mapping the VIC, Appendix B for lots of additional info.
VIC-20 Projects: wAx Assembler, TRBo: Turtle RescueBot, Helix Colony, Sub Med, Trolley Problem, Dungeon of Dance, ZEPTOPOLIS, MIDI KERNAL, The Archivist, Ed for Prophet-5

WIP: MIDIcast BASIC extension

he/him/his
User avatar
MrSterlingBS
Vic 20 Enthusiast
Posts: 174
Joined: Tue Jan 31, 2023 2:56 am
Location: Germany,Braunschweig

Re: Is there sample VIC20 assembly doing wedges for BASIC?

Post by MrSterlingBS »

chysn wrote: Mon Jul 24, 2023 8:28 am
MrSterlingBS wrote: Sun Jul 23, 2023 11:58 pm Example:
10 @iMUL,5,3 ; integer multiplication 5x3=15

Do i need to PEEK it from the memory location?
Or is there another way?
You can use variables to communicate back to BASIC programs. Either pass the variable name to the @IMUL command, or come up with some other way to determine the variable name.

Code: Select all

lda #"R" + #$80 ; First letter of the variable name. High byte of both characters set means an integer (%)
sta $45         ; Store the first letter in VARNAM zero-page location
lda #$80        ; This is a one-letter variable name, but still need to set high bit
sta $46         ; Store the second character (or null here) in VARNAM+1
jsr $d0e7       ; The routine D0E7 finds or creates the variable and sets a pointer to start of its memory in $47/$48
ldy #1          ; ($47),1 will be the low byte of an integer variable value. Yes, the value is big-endian!
lda #<INTVAL    ; Low byte of the integer to store
sta ($47),y     ; ,,
dey             ; ($47),0 will be the high byte of an integer variable value.
lda #>INTVAL    ; High byte of the integer to store
sta ($47),y     ; ,,
Execute this code, using whatever INTVAL you want, and then in BASIC you can just use it as an integer variable:

Code: Select all

?R%
See Mapping the VIC, Appendix B for lots of additional info.
Hello,

I did not get the code to run.
Is something i need to do before i use the code?

In my other post BLAS Routines on C64 and VIC there is some code to get the values from the SYS command and write some value back. But this code also do not works!

What is the problem with that?

BR
Sven
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: Is there sample VIC20 assembly doing wedges for BASIC?

Post by Mike »

chysn wrote:[...]
MrSterlingBS wrote:I did not get the code to run.
Works for me:

Image

$1267 ^= 4711

Image
Is [there] something I need to do before I use the code? In my other post BLAS Routines on C64 and VIC there is some code to get the values from the SYS command and write some value back. But this code also [does] not [work]! What is the problem with that?
I have no idea. If you manage to attach *.prg or *.d64 files of your builds, that would at least give people a chance to see what went wrong.
User avatar
chysn
Vic 20 Scientist
Posts: 1205
Joined: Tue Oct 22, 2019 12:36 pm
Website: http://www.beigemaze.com
Location: Michigan, USA
Occupation: Software Dev Manager

Re: Is there sample VIC20 assembly doing wedges for BASIC?

Post by chysn »

Mike wrote: Sat Sep 23, 2023 11:02 am
Is [there] something I need to do before I use the code? In my other post BLAS Routines on C64 and VIC there is some code to get the values from the SYS command and write some value back. But this code also [does] not [work]! What is the problem with that?
I have no idea. If you manage to attach *.prg or *.d64 files of your builds, that would at least give people a chance to see what went wrong.
When you troubleshoot, double-check addressing modes. It's easy to accidentally type in zeropage mode (LDA $10) when it's supposed to be immediate (LDA #$10).

There are no special preparations the code needs to make that aren't presented.

A real-world example of setting an integer variable is at line 1953 here https://github.com/Chysn/VIC20-wAx2/blo ... .asm#L1953. An example of setting a floating point number is at line 1643 here https://github.com/Chysn/VIC20-wAx2/blo ... .asm#L1643 and shows cool FAC conversion stuff.
Post Reply