From caae2876d7cb5b555ab52fa6a05c9b95fea80534 Mon Sep 17 00:00:00 2001 From: Gergo ERDI Date: Sun, 3 Sep 2023 17:06:54 +0200 Subject: [PATCH] `db @[Word8]` should be lazy in the content of the bytes --- src/Z80/Assembler.hs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Z80/Assembler.hs b/src/Z80/Assembler.hs index 8d2e2e9..2264de1 100644 --- a/src/Z80/Assembler.hs +++ b/src/Z80/Assembler.hs @@ -62,7 +62,12 @@ class Bytes a where instance Bytes ByteString where defb = defByteString instance (b ~ Word8) => Bytes [b] where - defb = defByteString . BS.pack + defb bs = Z80 $ do + tell $ BS.pack bs + modify (incrementLoc . fromIntegral $ length bs) + -- The new location has to be computed lazily in the actual + -- content of the bytes, so that we can emit byte values + -- referring to later labels. db :: Bytes a => a -> Z80ASM db = defb