Crap 0.1 first assembly project

Show us what you're working on, (preferably with screenshots).
User avatar
Nomad
Manic Miner
Posts: 600
Joined: Thu Dec 28, 2017 12:38 pm

Re: Crap 0.1 first assembly project

Post by Nomad » Thu Jan 11, 2018 10:45 am

hmm the website must be slow it says its still uploading... let me see if I can find another host..

http://s000.tinyupload.com/?file_id=248 ... 7835222099
0 x

User avatar
R-Tape
Site Admin
Posts: 1611
Joined: Thu Nov 09, 2017 11:46 am

Re: Crap 0.1 first assembly project

Post by R-Tape » Thu Jan 11, 2018 11:11 am

I like the twiddlediddlydiddley-plips. Not so keen on the DeeeDuuhhh.
1 x

User avatar
Nomad
Manic Miner
Posts: 600
Joined: Thu Dec 28, 2017 12:38 pm

Re: Crap 0.1 first assembly project

Post by Nomad » Thu Jan 11, 2018 11:18 am

R-Tape wrote:
Thu Jan 11, 2018 11:11 am
I like the twiddlediddlydiddley-plips. Not so keen on the DeeeDuuhhh.
Yea thet twiddlediddlydiddley plips were manually written. the DeeDuuuhh's are the random generated sounds. I thought perhaps it would be a cheesy way to give some variety to the game but as you say they sound pants.

I think a more tightly constrained random number generation (at the moment it returns 0-255) that is why the DeeDuuuhhs are so short in many cases. Will pad them with a 50 and see if that improves things...

this is the soundfx file from the program.

Code: Select all

;r-tapes sounds
zap:
	ld d,16		;speaker = bit 4
	ld e,0		;distance between speaker move counter
	ld b,255	;overall length counter
blp0:	ld a,d
	and 248		;keep border colour the same
	out (254),a	;move the speaker in or out depending on bit 4
	cpl		;toggle, so we alternative between speaker in and out to make sound
	ld d,a		;store it
	ld c,e		;now a pause
blp1:	dec c
	jr nz,blp1
	dec e		;change to inc e to reverse the sound, or remove to make it a note
	djnz blp0	;repeat B=255 times
	ret

wiggy:
	ld d,100
	ld e,50
	ld b,60
	call soundFXGen

	ld d,90
	ld e,50
	ld b,60
	call soundFXGen

	ld d,80
	ld e,50
	ld b,60
	call soundFXGen

	ld d,70
	ld e,50
	ld b,60
	call soundFXGen

	ld d,60
	ld e,50
	ld b,60
	call soundFXGen

	ld d,50
	ld e,50
	ld b,60
	call soundFXGen

	ld d,40
	ld e,50
	ld b,60
	call soundFXGen

	ld d,30
	ld e,50
	ld b,60
	call soundFXGen

	ld d,20
	ld e,50
	ld b,60
	call soundFXGen

	ld d,10
	ld e,50
	ld b,60
	call soundFXGen

	ld d,1
	ld e,50
	ld b,60
	call soundFXGen

	ld d,255
	ld e,50
	ld b,60
	call soundFXGen

	ret
;soundFX subroutine, corupted with the simple prandom from Chuntey blog.
;not as groovy as P Rak's random function but this is very simple subroutine

rndSoundFXGen:
	call randomChuntey
	add a,50
	and 255
	ld d,a
	call randomChuntey
	add a,50
	and 255
	ld e,a	
	call randomChuntey
	add a,50
	and 255
	ld b,a
;butchered from soundFX.
soundFXGen:
_S1:     push bc
	ld a,($5C48)		; 11T
	srl a
	srl a
	srl a
	set 4,a			; 8T
	out(254),a		; 11T
	ld b,d
_S2:	nop			; 4T
	nop			; 4T
	nop			; 4T
	djnz _S2		; 50021
	res 4,a
	out(254),a		; 11T
	ld b,e
_S3:	nop			; 4T
	nop			; 4T
	nop			; 4T
	djnz _S3		; 50031
	nop
	dec e			; 4T
	inc d			; 4T
	inc e			; 4T
	pop bc			; 10T
	djnz _S1		; 50006
	ret
0 x

Joefish
Manic Miner
Posts: 301
Joined: Tue Nov 14, 2017 10:26 am

Re: Crap 0.1 first assembly project

Post by Joefish » Thu Jan 11, 2018 2:11 pm

Nomad wrote:
Thu Jan 11, 2018 7:36 am
ImagePotato tip:
To enable local labels in Pasmo, you use the command line option --alocal, in the code you start your local labels with the _ character. mmmm nice. This will help with readability.
I've never been able to get local definitions to work.
This is where the documentation is lacking. What's the syntax for using the LOCAL command?

If I've got a bit of code I want to repeat between REPT / ENDM markers, and I put a label in it, it throws up an error as the label counts as a redefinition the second time it's repeated. But every way I can think of for trying to define the label as local to the REPT macro fails.
1 x

User avatar
Nomad
Manic Miner
Posts: 600
Joined: Thu Dec 28, 2017 12:38 pm

Re: Crap 0.1 first assembly project

Post by Nomad » Thu Jan 11, 2018 2:18 pm

Joefish wrote:
Thu Jan 11, 2018 2:11 pm
I've never been able to get local definitions to work.
This is where the documentation is lacking. What's the syntax for using the LOCAL command?

If I've got a bit of code I want to repeat between REPT / ENDM markers, and I put a label in it, it throws up an error as the label counts as a redefinition the second time it's repeated. But every way I can think of for trying to define the label as local to the REPT macro fails.
example. when I assemble crapchess, its just..

Code: Select all

pasmo --tapbas --alocal main.asm main.tap
on the command line.

in the files themselves its looks like...

Code: Select all

soundFXGen:
_S1:     push bc
	ld a,($5C48)		; 11T
	srl a
	srl a
	srl a
	set 4,a			; 8T
	out(254),a		; 11T
	ld b,d
_S2:	nop			; 4T
	nop			; 4T
	nop			; 4T
	djnz _S2		; 50021
	res 4,a
	out(254),a		; 11T
	ld b,e
_S3:	nop			; 4T
	nop			; 4T
	nop			; 4T
	djnz _S3		; 50031
	nop
	dec e			; 4T
	inc d			; 4T
	inc e			; 4T
	pop bc			; 10T
	djnz _S1		; 50006
	ret
as a sanity check I use two subroutines that use identical local labels.

Code: Select all

soundFXGen:
_S1:     push bc
	ld a,($5C48)		; 11T
	srl a
	srl a
	srl a
	set 4,a			; 8T
	out(254),a		; 11T
	ld b,d
_S2:	nop			; 4T
	nop			; 4T
	nop			; 4T
	djnz _S2		; 50021
	res 4,a
	out(254),a		; 11T
	ld b,e
_S3:	nop			; 4T
	nop			; 4T
	nop			; 4T
	djnz _S3		; 50031
	nop
	dec e			; 4T
	inc d			; 4T
	inc e			; 4T
	pop bc			; 10T
	djnz _S1		; 50006
	ret

soundFXGen2:
_S1:     push bc
	ld a,($5C48)		; 11T
	srl a
	srl a
	srl a
	set 4,a			; 8T
	out(254),a		; 11T
	ld b,d
_S2:	nop			; 4T
	nop			; 4T
	nop			; 4T
	djnz _S2		; 50021
	res 4,a
	out(254),a		; 11T
	ld b,e
_S3:	nop			; 4T
	nop			; 4T
	nop			; 4T
	djnz _S3		; 50031
	nop
	dec e			; 4T
	inc d			; 4T
	inc e			; 4T
	pop bc			; 10T
	djnz _S1		; 50006
	ret
works ok.

From the link bellow - I always thought it was impossible to use local labels in pasmo but I thought I would double check and boom in the docs..
n the autolocal mode, introduced by using the --alocal command line option, all labels that begins with a '_' are locals. His ambit ends at the next non local label or in the next PROC, LOCAL, MACRO, ENDP or ENDM directive.

Both automatic and explicit local labels are represented in the symbol table listing as 8 digit hexadecimal numbers, corresponding to the first use of the label in the source.
http://pasmo.speccy.org/pasmodoc.html#sourcelabel

I still don't understand how the macro expansion stuff works with pasmo its a bit of a mind bender. You are right about the documentation for pasmo it could be better/more extensive.

I could never get the LOCAL syntax to work either, but when I tried the --alocal way, you don't need to use LOCAL it just assumes that all labels that start with _ are local.
0 x

User avatar
Seven.FFF
Manic Miner
Posts: 283
Joined: Sat Nov 25, 2017 10:50 pm
Location: USA

Re: Crap 0.1 first assembly project

Post by Seven.FFF » Thu Jan 11, 2018 3:55 pm

Here's a Zeus tape generation example:

Code: Select all

; wiggymain.asm

zeusemulate             "48K"                           ; Tell the Zeus emulator to be a 48K Spectrum.
org                     50000                           ; Tell the Zeus assembler where to place the code.
Stack                   equ $FF40                       ; $FF40 is the value of SP on entry from RANDOMIZE USR on a 48K model.
Zeus_SP                 equ Stack                       ; Tell the Zeus emulator where to set the stack pointer
                                                        ;   (not needed in new versions of Zeus; older versions of
                                                        ;   Zeus reset SP to $0000 after outputting a tap or tzx).

Main:
                        nop
                        nop
                        ld a,50
                        call Wiggy
                        ld (51000),a
                        ret

                        include "test.asm"


TapStart                equ Main                        ; Start address of bytes to save in the LOAD "" CODE block after the tape's BASIC loader.
TapEnd                  equ $                           ; End address of bytes to save in the LOAD "" CODE block after the tape's BASIC loader.
TapSize                 equ TapEnd-TapStart             ; Length of bytes to save in the LOAD "" CODE block after the tape's BASIC loader.
EntryPoint              equ Main                        ; Entry point (what the BASIC loader calls with RANDOMISE USR nnnnn).
TapMode                 equ 2                           ; Mode 2 is standard TAP (not speedloader etc).

                        output_tap "wiggy.tap", "Wiggy", "Comment", TapStart, TapSize, TapMode, EntryPoint
                        output_tzx "wiggy.tzx", "Wiggy", "Comment", TapStart, TapSize, TapMode, EntryPoint
                        output_z80 "wiggy.z80", Stack, TapStart
                        //output_szx "wiggy.szx", Stack, TapStart ; Zeus generates SZX files in interrupt mode 2, which
                                                                  ;   need tweaking to get them returning to BASIC.

end                     EntryPoint                      ; Tell the Zeus emulator where to start running code at.

Code: Select all

; test.asm

Wiggy:
        ld a, 100
        ret
Make sure you right-click in the editor and choose Toggle Code. The wide left margin shows assembled bytes and the addresses they get assembled to.

Image
1 x
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
seven-fff.com/blog

User avatar
Nomad
Manic Miner
Posts: 600
Joined: Thu Dec 28, 2017 12:38 pm

Re: Crap 0.1 first assembly project

Post by Nomad » Thu Jan 11, 2018 4:15 pm

That is all kinds of awesome, thanks Seven_FFF now I can start tackling your tutorial soon 8-)

Being able to examine the byte code like that is very nice.

Is there a manual for zeus? I know there are many examples on the website but I couldn't find a pdf of the manual. I guess there are options for generating things like microdrive/floppy disk?
1 x

User avatar
Seven.FFF
Manic Miner
Posts: 283
Joined: Sat Nov 25, 2017 10:50 pm
Location: USA

Re: Crap 0.1 first assembly project

Post by Seven.FFF » Thu Jan 11, 2018 4:35 pm

joefish wrote: If I've got a bit of code I want to repeat between REPT / ENDM markers, and I put a label in it, it throws up an error as the label counts as a redefinition the second time it's repeated. But every way I can think of for trying to define the label as local to the REPT macro fails.
Zeus has rich handling and scoping of local labels. This is a deliberately baroque example to show what's possible if you were insane enough:

Code: Select all

; label-scoping.asm                                             ; This example doesn't do anything if you run it,
                                                                ; but it is instructive to see how it gets assembled!

zeusemulate             "48K"                                   ; Tell the Zeus emulator to be a 48K Spectrum.
org                     50000                                   ; Tell the Zeus assembler where to place the code.
Stack                   equ $FF40                               ; $FF40 is the value of SP on entry from RANDOMIZE USR on a 48K model.
Zeus_SP                 equ Stack                               ; Tell the Zeus emulator where to set the stack pointer
                                                                ;   (not needed in new versions of Zeus; older versions of
                                                                ;   Zeus reset SP to $0000 after outputting a tap or tzx).
Zeus_PC                 equ labelGlobalA                        ; Tell the Zeus emulator where to start running code.



labelGlobalA:           ret                                     ; Global labels can be back-referenced from later code.

Menu                    proc                                    ; Named proc. All labels defined inside (except those scoped with ::) are local to that proc.
labelNamedProcA:          nop                                   ; Labels in named procs can be back- or forward referenced.
                          for loop1 = 1 to 5                    ; Assembly-time loop.
                            proc                                ; Anonymous proc inside the loop. All labels defined inside get a separate symbol instance and value for each loop iteration.
label1A:                      nop                               ; Labels in anonymous procs can be back- or forward referenced.
                              jp Menu.labelNamedProcA           ; You can refer to labels defined in any named proc
                              jp Menu.labelNamedProcB           ;   with [proc].[label] dot notation.
                              jp ^^^^labelGlobalA               ; Each pair of ^^ jumps up one level
                              jp ^^^^labelGlobalB               ;   to resolve labels in a parent scope.
                              jp labelGlobalA                   ; Local labels in current scope need no qualification.
                              jp ::labelGlobalB                 ; You can refer to global labels with :: prefix from anywhere.
                              for loop2 = 1 to 3                ; A second assembly-time loop nested inside the first one.
                                proc                            ; Another Anonymous proc inside the inner loop.
label2A:                          nop                           ; Labels in anonymous procs can be back- or forward referenced.
                                  jp ^^label1A                  ; ^^ Scopes up one level to refer
                                  jp ^^label1B                  ;    to label inside outer anon proc.
                                  jp ^^^^labelNamedProcA        ; ^^ Scopes up two levels to refer
                                  jp ^^^^labelNamedProcB        ;    to label inside named proc proc.
                                  jp Menu.labelNamedProcA       ; Or refer to same proc proc label
                                  jp Menu.labelNamedProcB       ;    directly with dot notation.
                                  jp labelGlobalA               ; Local labels in current scope
                                  jp labelGlobalB               ;    need no qualification.
                                  jp ::labelGlobalA             ; You can refer to global labels
                                  jp ::labelGlobalB             ;    with :: prefix from anywhere.
label2B:                          nop                           ; Enclosing labels can also be forward-referenced from earlier code.
                                pend                            ; Closing inner anon proc.
                              next ; loop2                      ; Closing inner loop.
label1B:                      nop                               ; Enclosing labels can also be forward-referenced from earlier code.
                            pend                                ; Closing outer anon proc.
                          next ; loop1                          ; Closing outer loop.
labelNamedProcB:          nop                                   ; Enclosing labels can also be forward-referenced from earlier code.
                          jp labelNamedProcA                    ; Local labels in current scope need no qualification, whether back-
                          jp labelNamedProcB                    ;   or forward-referenced.
                          jp Menu.labelNamedProcA               ; Labels in named procs can be referenced with dot notation, whether back-
                          jp Menu.labelNamedProcB               ;   or forward-referenced.
                          jp labelGlobalA                       ; Global labels can be referenced without :: notation, whether back-
                          jp labelGlobalB                       ;   or forward-referenced, provided they are unambiguous.
                          jp ^^labelGlobalA                     ; Global labels can also be referenced with ^^  notation, whether back-
                          jp ^^labelGlobalB                     ;   or forward-referenced, from a first-level named or anonymous proc.
                          jp ::labelGlobalA                     ; Global labels can always be referenced with :: notation, whether back-
                          jp ::labelGlobalB                     ;   or forward-referenced.
pend
labelGlobalB:             nop                                   ; Global labels can also be forward-referenced from earlier code.
                          jp Menu_4_2.label2A                   ; Any instance-named symbol can be DIRECTLY referenced from anywhere. Use with caution!
                          		        		; Procs (both named and anonymous) and macros open up a new child scope. Other assembly-time
                          		        		; directlves (loops etc) don't. Hence why each loop here has an anon proc immediately inside.
                          		        		; Here there are three nested scopes (Main, outer anon and inner anon).
                          		        		; Nested scopes inside loops get a new scope instance for each iteration of the loop.
                          		        		; Nesting loops *and* scopes gets a new scope instance for each combination of iterations.
                          					; You can see this in the symbol naming below. FOr example in Menu_3_2.label2A, 
                          					; Global is an implicit outer scope, "Menu" is the named proc scope, "3" is the scope inside the outer
                          					; anon proc, and "2" is the scope inside the inner named proc. All this gives a unique scope name for 
                          					; that scope instance, then ".label2A" refers to the "label2A" label inside that scope instance.                      

; All this still assembles in only four passes!

; Symbol list generated by Zeus:

; labelGlobalA                    EQU $C350
; labelGlobalB                    EQU $C5B5
; loop1                           EQU $0006
; loop2                           EQU $0004
; Menu                            EQU $C351
; Menu.labelNamedProcA            EQU $C351
; Menu.labelNamedProcB            EQU $C596
; Menu_0.label1A                  EQU $C352
; Menu_0.label1B                  EQU $C3C5
; Menu_0_0.label2A                EQU $C365
; Menu_0_0.label2B                EQU $C384
; Menu_0_1.label2A                EQU $C385
; Menu_0_1.label2B                EQU $C3A4
; Menu_0_2.label2A                EQU $C3A5
; Menu_0_2.label2B                EQU $C3C4
; Menu_1.label1A                  EQU $C3C6
; Menu_1.label1B                  EQU $C439
; Menu_1_0.label2A                EQU $C3D9
; Menu_1_0.label2B                EQU $C3F8
; Menu_1_1.label2A                EQU $C3F9
; Menu_1_1.label2B                EQU $C418
; Menu_1_2.label2A                EQU $C419
; Menu_1_2.label2B                EQU $C438
; Menu_2.label1A                  EQU $C43A
; Menu_2.label1B                  EQU $C4AD
; Menu_2_0.label2A                EQU $C44D
; Menu_2_0.label2B                EQU $C46C
; Menu_2_1.label2A                EQU $C46D
; Menu_2_1.label2B                EQU $C48C
; Menu_2_2.label2A                EQU $C48D
; Menu_2_2.label2B                EQU $C4AC
; Menu_3.label1A                  EQU $C4AE
; Menu_3.label1B                  EQU $C521
; Menu_3_0.label2A                EQU $C4C1
; Menu_3_0.label2B                EQU $C4E0
; Menu_3_1.label2A                EQU $C4E1
; Menu_3_1.label2B                EQU $C500
; Menu_3_2.label2A                EQU $C501
; Menu_3_2.label2B                EQU $C520
; Menu_4.label1A                  EQU $C522
; Menu_4.label1B                  EQU $C595
; Menu_4_0.label2A                EQU $C535
; Menu_4_0.label2B                EQU $C554
; Menu_4_1.label2A                EQU $C555
; Menu_4_1.label2B                EQU $C574
; Menu_4_2.label2A                EQU $C575
; Menu_4_2.label2B                EQU $C594
; Stack                           EQU $FF40
; Zeus_PC                         EQU $C350
; Zeus_SP                         EQU $FF40
A lot of this came out of discussions with Simon about a real doubly-nested loop I was trying to write, and getting frustrated with. I was trying to conditionally jump to specific places inside the assembly-time loops, depending on run-time conditions, and it wasn't behaving as expected. The jiggling letters on the Jet Power Jack menu, I think it was.
Last edited by Seven.FFF on Thu Jan 11, 2018 5:34 pm, edited 5 times in total.
1 x
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
seven-fff.com/blog

User avatar
Seven.FFF
Manic Miner
Posts: 283
Joined: Sat Nov 25, 2017 10:50 pm
Location: USA

Re: Crap 0.1 first assembly project

Post by Seven.FFF » Thu Jan 11, 2018 4:42 pm

Nomad wrote:
Thu Jan 11, 2018 4:15 pm
That is all kinds of awesome, thanks Seven_FFF now I can start tackling your tutorial soon 8-)

Being able to examine the byte code like that is very nice.

Is there a manual for zeus? I know there are many examples on the website but I couldn't find a pdf of the manual. I guess there are options for generating things like microdrive/floppy disk?
Nope, no PDF. Half the documentation is in the website example files, and the other half is in the History section of the About screen. The only thing really missing is an overall structure. I did mull over making a wiki, but I'm not sure I could maintain it in the longer term.

I usually download this, unzip into a directory, download the history text into the same directory, then use grep/whatever to search through the whole thing.

Simon is very amenable to questions (and making improvements arising from questions and discussions). As am I (well the questions if not the improvements!). If you're on facebook messenger, hit him or me up on there.
1 x
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
seven-fff.com/blog

Joefish
Manic Miner
Posts: 301
Joined: Tue Nov 14, 2017 10:26 am

Re: Crap 0.1 first assembly project

Post by Joefish » Thu Jan 11, 2018 10:40 pm

So when it comes to PASMO, nobody knows?
I'll be adding the auto locals directive to my builds in future anyway.
0 x

Post Reply