News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_McArti0

Why WAIT in basic freezed?

Started by McArti0, 01:08, 04 February 22

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

McArti0

Why:


WAIT &f500,1 work.


But WAIT &f500,1,0 ... don't work? (freezed)


WAIT &f500,1,255 don't work too.


Manual say:


W A I T <port number, , <mask,[, <inversion,]

" The value read is eXclusive 0Red with the <inversion, and then ANDed with the <mask,"
CPC 6128, Whole 6128 and Only 6128, with .....
NewPAL v3 for use all 128kB RAM by CRTC as VRAM
One chip driver for 512kB(to640) extRAM 6128
TYPICAL :) TV Funai 22FL532/10 with VGA-RGB-in.

gurneyh


pelrun

His point is that even using an inversion of 0 which should be completely identical to omitting the parameter, WAIT behaves differently. Sounds like a bug in BASIC to me.

pelrun

#3
Confirmed - in both BASIC 1.0 and 1.1 if you put anything in the inversion parameter then the mask gets incorrectly set to 0, making it never return  :picard2:


More details: Using the disassembly of BASIC 1.1 at https://github.com/Bread80/Amstrad-CPC-BASIC-Source/blob/ae70de4838bbfda0b53d45ff05ff61bd44f0861d/PeekPokeIOBarCall.asm#L40

The problem is that the call to eval_expr_as_byte_or_error in line 60, which is used to read in both the mask and inversion values, corrupts DE. Since the mask value is stored in D, it gets overwritten by the high byte of the inversion parameter (which is guaranteed to be 0 or it would have thrown an Improper Argument error and not returned.)

eto

Quote from: McArti0 on 01:08, 04 February 22WAIT &f500,1,255 don't work too.

does WAIT &f500,0,1 work?

McArti0

CPC 6128, Whole 6128 and Only 6128, with .....
NewPAL v3 for use all 128kB RAM by CRTC as VRAM
One chip driver for 512kB(to640) extRAM 6128
TYPICAL :) TV Funai 22FL532/10 with VGA-RGB-in.

pelrun

#6
Quotedoes WAIT &f500,0,1 work?

Given the way WAIT works, putting 0 in the mask field will ALWAYS lock the machine up, even when the inversion field is missing. You're asking the machine to wait until a bit is set, but clearing all the bits before you test. So technically, it "works" because locking up is exactly what you asked it to do.

McArti0

Quote from: gurneyh on 07:40, 04 February 22
hi,

you do not necessarily need to use inversion



but I want to find end time of H-Sync


Lord Alan... , give my money back ;) :D
CPC 6128, Whole 6128 and Only 6128, with .....
NewPAL v3 for use all 128kB RAM by CRTC as VRAM
One chip driver for 512kB(to640) extRAM 6128
TYPICAL :) TV Funai 22FL532/10 with VGA-RGB-in.

eto

Quote from: pelrun on 10:26, 04 February 22Given the way WAIT works, putting 0 in the mask field will ALWAYS lock the machine up

:doh:  argl... sure... AND 0

Powered by SMFPacks Menu Editor Mod