pasmo weirdness

The place for codemasters or beginners to talk about programming any language for the Spectrum.
Post Reply
Nomad
Manic Miner
Posts: 600
Joined: Thu Dec 28, 2017 12:38 pm

pasmo weirdness

Post by Nomad »

Weird Pasmo behavior

Have not really done much with pasmo for a few weeks as have been working on doing the analysis for project.

Now I try and use one of the subroutines from the Lance L book and I get the program to assemble in pasmo but nothing shows up in fuse (but then the debugging facilities are pitiful in fuse so I am not really sure whats going on..)

I thought you had to put an end statement for pasmo to like it but that seems not to be the case now????

Anyway here is the code that seems not to work. It's a simple subroutine to multiply two 16 bit numbers.

It should exit with the HL register having the result.

I generate the tap file, but when I run it nothing shows up in fuse.

I look at the "debugger" and nothing is showing up at location C350 (50000). Not a sausage. So I am thinking nothing is getting loaded from the tap file? Why was there no error when I did the assembly :lol: Its like it silently failed.

Code: Select all

ORG 50000
INCLUDE "MUL16.ASM"

SC6A:
		LD		HL,-2			; HL = MULTIPLICAND
		LD		DE,1023			; DE = MULTIPLIER
		CALL	MUL16			; 16-BIT MULTIPLY
								; RESULT OF 1023 * -2 = 0F802H
								;  REGISTER L = 02H
								;  			H = F8H
		JR		SC6A
RET

Code: Select all

; MUL16.ASM 
; Multiply two 16 bit numbers
;
; Entry Conditions:
; Multiplicand in HL
; Multiplier in DE
;
; Exit Conditions:
; Less significant word of product in HL
;
; Registers Used: AF, BC, DE, HL
; Execution Time: Approx. 865 to 965 cycles.
; Program size: 22 bytes
; Data Memory Required: None
;

; INITALIZE PARTIAL PRODUCT, BIT COUNT

MUL16:
		LD	C,L			; BC = MULTIPLIER
		LD	B,H
		LD	HL,0		; PRODUCT = 0
		LD	A,15		; COUNT = BIT LENGTH -1
		
		; SHIFT-AND-ADD ALGORITHM
		; IF MSB OF MULTIPLIER IS 1, ADD MULTIPLICAND TO PARTIAL PRODUCT
		; SHIFT PARTIAL PRODUCT, MULTIPLIER LEFT 1 BIT
		
MLP:
		SLA	E			; SHIFT MULTIPLIER LEFT 1 BIT
		RL	D
		JR	NC,MLP1		; JUMP IF MSB OF MULTIPLIER = 0
		ADD	HL,BC		; ADD MULTIPLICAND TO PARTIAL PRODUCT
MLP1:
		ADD	HL,HL		; SHIFT PARTIAL PRODUCT LEFT
		DEC	A
		JR	NZ,MLP		; CONTINUE UNTIL COUNT = 0
		
		; ADD MULTIPLICAND ONE LAST TIME IF MSB OF MULTIPLIER IS 1
		
		OR	D			; SIGN FLAG = MSB OF MULTIPLIER
		RET	P			; EXIT IF MSB OF MULTIPLIER IS 0
		ADD	HL,BC		; ADD MULTIPLICAND TO PRODUCT
		RET
I know I am missing something obvious :lol: I am going to blame it on my toothache.
User avatar
Sokurah
Manic Miner
Posts: 283
Joined: Tue Nov 14, 2017 10:38 am
Contact:

Re: pasmo weirdness

Post by Sokurah »

Nomad wrote: Sat Mar 10, 2018 1:43 pm I thought you had to put an end statement for pasmo to like it but that seems not to be the case now????
To "run it", right? ... you mean "RUN" - not "like"?
The END statement has never failed to RUN it for me. Are you sure your END is pointing to the right address?
Website: Tardis Remakes / Mostly remakes of Arcade and ZX Spectrum games.
My games for the Spectrum: Dingo, The Speccies, The Speccies 2, Vallation & Sqij.
Twitter: Sokurah
User avatar
RMartins
Manic Miner
Posts: 776
Joined: Thu Nov 16, 2017 3:26 pm

Re: pasmo weirdness

Post by RMartins »

It would be easier to help you, if you showed pasmo output when compiling the section you are conerned with.
By the way, why do you say it's related with that particular routine ?

Did you generate or created a BASIC loader for your ASM code ?

If you are loading ASM code directly, you need to do
LOAD "" CODE
Nomad
Manic Miner
Posts: 600
Joined: Thu Dec 28, 2017 12:38 pm

Re: pasmo weirdness

Post by Nomad »

when I run pasmo it shows no errors and generates the tap.

I type randomize usr 50000 in basic +3

nothing is in the memory of the emulator at that location, the HL register is not showing the value it should.

Therefore I figured the subroutine might not be loading correctly, or there is a error in the code, or there is some issue with the way pasmo is creating the tap file..

I remember there is a specific format pasmo wants the file to be in during assembly (you need to END it with the same value as the main label or the ORG number right?)
User avatar
RMartins
Manic Miner
Posts: 776
Joined: Thu Nov 16, 2017 3:26 pm

Re: pasmo weirdness

Post by RMartins »

Did you try the LOAD "" CODE, like I mentioned in my edit above ?

Pasmo generates the file, but also outputs all the lines while processing, so you can compare the file bytes, with the expected result.
Just compare the two, the output and the file.
User avatar
Einar Saukas
Bugaboo
Posts: 3070
Joined: Wed Nov 15, 2017 2:48 pm

Re: pasmo weirdness

Post by Einar Saukas »

Did you execute CLEAR 49999 before LOAD ""CODE ?

Also notice that RANDOMIZE USR 50000 will execute MUL16 directly, not your code you placed after it.
Nomad
Manic Miner
Posts: 600
Joined: Thu Dec 28, 2017 12:38 pm

Re: pasmo weirdness

Post by Nomad »

I am confused before I just would generate the tap file and it would load my program in the emulator, now I need to create the basic loader?

I use the command

Code: Select all

pasmo --tapbas  SC6A.ASM SC6A.TAP
The same as when I was doing crapchess.. and that created the basic loader.
Rorschak
Drutt
Posts: 6
Joined: Mon Nov 13, 2017 5:04 pm

Re: pasmo weirdness

Post by Rorschak »

Einar is correct. The code will run Mul16 directly.

This code works for me, returning 0xF802 in HL

Code: Select all

ORG 50000

SC6A:
		LD		HL,-2			; HL = MULTIPLICAND
		LD		DE,1023			; DE = MULTIPLIER
		CALL		MUL16			; 16-BIT MULTIPLY
							; RESULT OF 1023 * -2 = 0F802H
							;  REGISTER L = 02H
							;  H = F8H
		JR		SC6A

INCLUDE "MUL16.ASM"
I have removed the final RET, as it is never reached, and moved the include to the end of the file, so the code at 50000 will be your code.

Assembled with pasmo --tapbas SC6A.asm SC6A.tap

Tested with SpecEmu, but Fuse shouldn't be any different.
Nomad
Manic Miner
Posts: 600
Joined: Thu Dec 28, 2017 12:38 pm

Re: pasmo weirdness

Post by Nomad »

I tried the alterations, it assembles. But when I try and load it in fuse nothing works.

The code is not loaded into memory, I just get error when I try and LOAD ""CODE.

I will try it in another emulator.

I tried it in SpecEmu but it does not produce the right result in HL. The program seems to be loaded in the right place.

:lol: I don't understand I just want the damn thing to work like its supposed to.

These are the times I get very irritated with myself not being able to complete a simple task. I am not sure if its the software, the machine or something I did lol. :lol:

The amount of time I spend on these mistakes I sometimes question if its really worth all the time and effort when there are no results.

Ok above comments still stand - but i got it to work finally. :lol:

Thank you for all the help. you are all very patient.
User avatar
RMartins
Manic Miner
Posts: 776
Joined: Thu Nov 16, 2017 3:26 pm

Re: pasmo weirdness

Post by RMartins »

I would suggest you document your mistake in this thread (if it's not too embarrassing :lol: ), since it might be useful for someone else that might be doing the same mistake in the future.
Nomad
Manic Miner
Posts: 600
Joined: Thu Dec 28, 2017 12:38 pm

Re: pasmo weirdness

Post by Nomad »

RMartins wrote: Sat Mar 10, 2018 11:04 pm I would suggest you document your mistake in this thread (if it's not too embarrassing :lol: ), since it might be useful for someone else that might be doing the same mistake in the future.
Yes that is a good idea :lol:

So what the problem was - before when creating the taps in pasmo it generated a basic loader.
Now that does not seem to be happening. So I was expecting pasmo to have handled the basic commands that in the end i had to enter in manually, as a program. When i tried to do it 'interactive' at the basic prompt it would not work.

Much like roshack and Einar said - but the issue was I was trying to do the sequence without line numbers.

Code: Select all

10 CLEAR 49999 
20 RANDOMIZE USR 50000
30 LOAD "" CODE
RUN
line 10 needs to be n-1 where n is your ORG number.
line 20 needs to be the ORG number

After I RUN, the value of HL in the debugger is what it should be.

I did this in Fuse.
Last edited by Nomad on Sun Mar 11, 2018 2:55 am, edited 1 time in total.
User avatar
Seven.FFF
Manic Miner
Posts: 735
Joined: Sat Nov 25, 2017 10:50 pm
Location: USA

Re: pasmo weirdness

Post by Seven.FFF »

Did you have the END directive at the end of the source?
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
NXtel NXTP ESP Update ESP Reset CSpect Plugins
Nomad
Manic Miner
Posts: 600
Joined: Thu Dec 28, 2017 12:38 pm

Re: pasmo weirdness

Post by Nomad »

Seven.FFF wrote: Sun Mar 11, 2018 2:49 am Did you have the END directive at the end of the source?
No perhaps that was it, I tried it with END before but it was the same result. I'll give it another go.. I am sure it had the functionality before and there was some cyrptic requirement for pasmo to have an END statement linked to the ORG or the main label right :lol: I will check that later as it sounds like this is the problem.

Weird thing is pasmo just happy creates the tap without letting on the END is missing. :lol:
User avatar
Seven.FFF
Manic Miner
Posts: 735
Joined: Sat Nov 25, 2017 10:50 pm
Location: USA

Re: pasmo weirdness

Post by Seven.FFF »

END is nothing to do with ORG. There’s a single END, at the end, to tell it how to create the loader. It’s something specific to pasmo and it’s loader generation.

ORGs are scattered all round your source, and tell the assembler what address to lay down the next assembled bytes at that point in the source code. There’s no requirement to have any ORGs at all, in which case assembly starts at $0000, which is often RAM in older Z80 systems. ORG as a concept is pretty general to most assemblers, although it occasionally uses a different directive.
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
NXtel NXTP ESP Update ESP Reset CSpect Plugins
Nomad
Manic Miner
Posts: 600
Joined: Thu Dec 28, 2017 12:38 pm

Re: pasmo weirdness

Post by Nomad »

I Tried END SC6A didn't seem to work
same with the ORG number END..

same with END at the end of SC6A listing.

First attempt with the END 50000 - this used to work with my other programs in pasmo.

Code: Select all

ORG 50000

SC6A:
		LD		HL,-2			; HL = MULTIPLICAND
		LD		DE,1023			; DE = MULTIPLIER
		CALL	MUL16			; 16-BIT MULTIPLY
								; RESULT OF 1023 * -2 = 0F802H
								;  REGISTER L = 02H
								;  			H = F8H
		JR		SC6A
		
INCLUDE "MUL16.ASM"

END 50000
Then I tried ending with the END SC6A as that was the main program label..

Code: Select all

ORG 50000

SC6A:
		LD		HL,-2			; HL = MULTIPLICAND
		LD		DE,1023			; DE = MULTIPLIER
		CALL	MUL16			; 16-BIT MULTIPLY
								; RESULT OF 1023 * -2 = 0F802H
								;  REGISTER L = 02H
								;  			H = F8H
		JR		SC6A
		
INCLUDE "MUL16.ASM"

END SC6A
Finally I tried just a simple END

Code: Select all

ORG 50000

SC6A:
		LD		HL,-2			; HL = MULTIPLICAND
		LD		DE,1023			; DE = MULTIPLIER
		CALL	MUL16			; 16-BIT MULTIPLY
								; RESULT OF 1023 * -2 = 0F802H
								;  REGISTER L = 02H
								;  			H = F8H
		JR		SC6A
		
INCLUDE "MUL16.ASM"

END 
Like I might be taking crazy pills but what is the point of using the tap generator over the binary blob if pasmo can't generate a working basic loader stub :lol:
User avatar
Seven.FFF
Manic Miner
Posts: 735
Joined: Sat Nov 25, 2017 10:50 pm
Location: USA

Re: pasmo weirdness

Post by Seven.FFF »

It’s not such a great assembler. it’s old, largely abandoned, easily confused and doesn’t always do what the documentation says it does. I lose patience with it pretty easily!
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
NXtel NXTP ESP Update ESP Reset CSpect Plugins
Nomad
Manic Miner
Posts: 600
Joined: Thu Dec 28, 2017 12:38 pm

Re: pasmo weirdness

Post by Nomad »

Seven.FFF wrote: Sun Mar 11, 2018 3:02 am END is nothing to do with ORG. There’s a single END, at the end, to tell it how to create the loader. It’s something specific to pasmo and it’s loader generation.

ORGs are scattered all round your source, and tell the assembler what address to lay down the next assembled bytes at that point in the source code. There’s no requirement to have any ORGs at all, in which case assembly starts at $0000, which is often RAM in older Z80 systems. ORG as a concept is pretty general to most assemblers, although it occasionally uses a different directive.
Yes I remember the Lance A main book uses ORG 00000 as the load location for the programs. I think that is what it is on the S100 Bus systems.
Seven.FFF wrote: Sun Mar 11, 2018 3:19 am It’s not such a great assembler. it’s old, largely abandoned, easily confused and doesn’t always do what the documentation says it does. I lose patience with it pretty easily!
Words can't adequately state how salty pasmo made me last night :lol: Im a hot potato right now.

There is a little voice that is constantly whispering 'you should have use zeus you potato..." :lol:

I checked out the website and there is an entire demonstration on how 128k memory paging works and how to use it. Kudos Simon..

http://www.desdes.com/products/oldfiles ... x_v352.asm

I forgotten why I don't use the zeus IDE lol - it looks terible with wine, all the windows are out of wack.

I guess its alright for just testing the monitor but its totally unusable as an every day ide.

how difficult would it be to get a linux version of zeus? not using some crippled wine hack?

Image

Would you use a application that did this? :lol:

So I end up with a choice between a assembler that can't assemble a simple tap (pasmo). or an IDE that looks like aids on my screen (zeus).

Lol... so much fail with the spectrum stuff...

It does not have to be this way... if you want to develop on atari 800 you can use an emulator that has only been under constant development since 2009 (instead of the decades long development cycles of the spectrum stuff...) but unlike the spectrum junk this actually works exactly like the hardware, is usable and you don't need special hacks/manuals just to use the emulators. Just the original documents for the original hardware, software.

Perhaps the spectrum is a much harder platform to emulate properly? I can't explain why they fail so hard compared to the Atari 800 stuff.

Image

Image

Image

Image

Image

Image

This runs out of the box under wine, everything functions fine. :lol:

Image

Don't mind me I am just extra salty today. :lol:
AndyC
Dynamite Dan
Posts: 1388
Joined: Mon Nov 13, 2017 5:12 am

Re: pasmo weirdness

Post by AndyC »

Nomad wrote: Sun Mar 11, 2018 3:20 amIt does not have to be this way... if you want to develop on atari 800 you can use an emulator that has only been under constant development since 2009 (instead of the decades long development cycles of the spectrum stuff...) but unlike the spectrum junk this actually works exactly like the hardware, is usable and you don't need special hacks/manuals just to use the emulators. Just the original documents for the original hardware, software.

Perhaps the spectrum is a much harder platform to emulate properly? I can't explain why they fail so hard compared to the Atari 800 stuff.
I think it's more of a "real world" constraint in this case. Almost no Spectrum users had disc drives and microdrives were a bit niche too, so pretty much everything has to work with tape. An "on machine" assembler, therefore, was pretty much going to have to store the assembly source code and final object code in memory, which with only 48K is a bit limiting. Plus you have to save out all your code to tape (takes ages), run it, have the machine crash, reload the assembler (ages), reload the source (more ages) and so on. It always made learning to program on the spectrum a much more painful task without the benefits of a cross assembler.

In contrast, on the CPC I wrote my own assembler in BASIC that read a source file on disc and assembled the binary to a file on disc. Even being written in BASIC (and still having to load a separate disc based text editor) this was light years faster and more productive. Moving beyond that to ROM based tools (Protext + Maxam being the gold star toolset) was like having a modern IDE in terms of how quickly you could turn things around. I've not tried coding on the Atari, but I'd imagine it's not a dissimilar experience.
User avatar
Einar Saukas
Bugaboo
Posts: 3070
Joined: Wed Nov 15, 2017 2:48 pm

Re: pasmo weirdness

Post by Einar Saukas »

Nomad wrote: Sun Mar 11, 2018 2:47 am

Code: Select all

10 CLEAR 49999 
20 RANDOMIZE USR 50000
30 LOAD "" CODE
RUN
Lines 20 and 30 must be swapped. You were trying to execute the code before loading it.
User avatar
Seven.FFF
Manic Miner
Posts: 735
Joined: Sat Nov 25, 2017 10:50 pm
Location: USA

Re: pasmo weirdness

Post by Seven.FFF »

Zeus looks fine, except you have the fonts set too large. What is it you don't like, the Toggle Code pane?
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
NXtel NXTP ESP Update ESP Reset CSpect Plugins
Nomad
Manic Miner
Posts: 600
Joined: Thu Dec 28, 2017 12:38 pm

Re: pasmo weirdness

Post by Nomad »

Seven.FFF wrote: Sun Mar 11, 2018 1:19 pm Zeus looks fine, except you have the fonts set too large. What is it you don't like, the Toggle Code pane?
what I want to do is move the code window so it uses the unused space to the left. I think the font issue is down to the wineconfig I will have a play with it. on default you get size 4-5 fonts that can't really be altered in the application menu for some stuff (that requires ms default fonts)

Right clicking i can kill some of the menu dead space but it still looks terrible - like a windows 3.1 application :lol: Even this would be ok but the menus themselves seem broken in many places.

I guess only other irritation with zeus is all of the boiler plate stuff - one thing I like a lot is the monitor - debugger is good also. There are probably a bunch of obscure boilerplate stuff I need to do to the code to get it to even run on zeus. That is probably why the HL value is not showing the correct value.

I just reset wine's configs for zeus back to default. a lot of the menus are still broken. It also does not seem to run the program - when i assemble and run the program it just keeps cycling through a bunch of values in HL none of which are the ones the example program says should be in HL..
User avatar
Seven.FFF
Manic Miner
Posts: 735
Joined: Sat Nov 25, 2017 10:50 pm
Location: USA

Re: pasmo weirdness

Post by Seven.FFF »

The unused space to the left shows the address and first eight assembled bytes for each line of source code. You have to click Assemble for it to show though.

It’s highly possible I suggested you to show the pane when you were having probs with visualising what was being assembled! You can hide it again with right click > toggle code.
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
NXtel NXTP ESP Update ESP Reset CSpect Plugins
Nomad
Manic Miner
Posts: 600
Joined: Thu Dec 28, 2017 12:38 pm

Re: pasmo weirdness

Post by Nomad »

AndyC wrote: Sun Mar 11, 2018 1:08 pm I think it's more of a "real world" constraint in this case. Almost no Spectrum users had disc drives and microdrives were a bit niche too, so pretty much everything has to work with tape. An "on machine" assembler, therefore, was pretty much going to have to store the assembly source code and final object code in memory, which with only 48K is a bit limiting. Plus you have to save out all your code to tape (takes ages), run it, have the machine crash, reload the assembler (ages), reload the source (more ages) and so on. It always made learning to program on the spectrum a much more painful task without the benefits of a cross assembler.

In contrast, on the CPC I wrote my own assembler in BASIC that read a source file on disc and assembled the binary to a file on disc. Even being written in BASIC (and still having to load a separate disc based text editor) this was light years faster and more productive. Moving beyond that to ROM based tools (Protext + Maxam being the gold star toolset) was like having a modern IDE in terms of how quickly you could turn things around. I've not tried coding on the Atari, but I'd imagine it's not a dissimilar experience.
Yes that is true, I think you are right. The Atari system I emulated was the same they used in the inhouse Atari development machines - with the corvus hard disk its very fast. It is like using a modern IDE in terms of speed of use. you can bounce back to and from the editor, to the assembler to the debugger, run the code on the machine. Productivity wise its much faster than using a cross-assembler. But then again. Very few Atari users would have had access to that kind of setup. It would have been a developers system. On a standard Atari it would have been pretty slow even using the floppy disks. Still its way faster than having to use a cassette tape.

I was surprised how well winApe runs in wine. I figured it would be a pain to use but its very well done. I kept thinking, where is the catch? :lol: Like i mentioned in that tutorial thread I think the biggest hindrance to CPC stuff now is the lack of source material. Hardly any of the books seem to be scanned/available. You got cpc wiki but its nowhere near the level of access to material that you have with Commodore/Atari/Spectrum books.
User avatar
Seven.FFF
Manic Miner
Posts: 735
Joined: Sat Nov 25, 2017 10:50 pm
Location: USA

Re: pasmo weirdness

Post by Seven.FFF »

I dunno what to do about the menus. Last time I discussed it with Simon he said had been open to making a native Linux version but there was no need because it behaved perfectly under wine when he tried. I’ve never personally tried because Linux annoys me :(

At the very least you need to tell the emulator what machine to emulate (with zeusemulate “48K” although you can set it in the combobox) and where to start executing (ZeusPC=nnnnn, or END nnnnn for pasmo source compatibility). If there’s neither, it will just run the code in the ROM like the hardware would.

If it is cycling through different values of hl, I would guess you haven’t put a breakpoint before it returns, and it is running the IM 1 interrupt handler in the speccy rom. That polls the keyboard and does other OS stuff every frame. When running freely without a breakpoint, Zeus snapshots the registers every second or so, so it’s normal to see them changing as the program (in this case the rom interrupt handler) executes.
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
NXtel NXTP ESP Update ESP Reset CSpect Plugins
Nomad
Manic Miner
Posts: 600
Joined: Thu Dec 28, 2017 12:38 pm

Re: pasmo weirdness

Post by Nomad »

Yea that is me being a potato and not telling zeus what target I want. :lol:

I had wondered why there is not a default target. But that is fair enough that is a design decision.

take your point about the linux, lol some days I hate it too. (Like when the update broke my system a few times. :lol: )

I am sure that in some linux distro zeus must work fine but its not just myself a number of people (well one other) mentioned the visual aids problem with the menus :lol:

With stuff like that (especially with arch) its hard to know if its the application, wine or the version of the distro that is the cause of the problem. Lol its just a roll of a dice so I hesitate to say that its a zeus issue. But its so random that stuff like the spectrumpaint fails in equally epic fashion, where as sevenup works great :lol: Same goes for winApe and Alltura (however you spell it). They ran fine out of the box.
Post Reply