Help to print a character in screen 0 with assembly

By fpracek

Resident (51)

Аватар пользователя fpracek

12-03-2023, 18:46

Hi,
I'm trying to write to print a character in screen 0 mode 80 columns).
I have hl registry equals to 0 and I'd expect to have my charater printed in position 0 (In basic is LOCATE 0,0) with this code:

Quote:

ld a,l
di
out (c),a
ld a,h
ei
out (c),a

Instead the character printed in position 1 (BASIC LOCATE 1,0).
I don't understand why.
If I set ht to 79 (HEX 4f) the character is printed into the first column of the second row (BASIC LOCATE 0,1)
It seems an offset of 1 character...

Для того, чтобы оставить комментарий, необходимо регистрация или !login

By NYYRIKKI

Enlighted (6067)

Аватар пользователя NYYRIKKI

13-03-2023, 01:31

Try "LD HL,4000h" instead.

Details here: https://problemkaputt.de/portar.htm#vramdatareadwrite

By gdx

Enlighted (6219)

Аватар пользователя gdx

13-03-2023, 01:34

Do you need direct access?

By fpracek

Resident (51)

Аватар пользователя fpracek

13-03-2023, 05:02

Quote:

Do you need direct access?

I need to print a text into specific position like BASIC “LOCATE” command. With CHPUT I don’t know if it is possible.

By fpracek

Resident (51)

Аватар пользователя fpracek

13-03-2023, 05:07

Quote:

Try "LD HL,4000h" instead.

It was a success!!!
Thanks

By ro

Scribe (4964)

Аватар пользователя ro

13-03-2023, 07:12

NYYRIKKI wrote:

Try "LD HL,4000h" instead.

Details here: https://problemkaputt.de/portar.htm#vramdatareadwrite

Oh, nice document!

By gdx

Enlighted (6219)

Аватар пользователя gdx

13-03-2023, 10:47

	ld	hl,Hello_TXT	; Load the address from the label Hello_TXT into HL.
	call	Print		; Call the routine Print below.

	ret
 
Print:
	ld	a,(hl)		; Load the byte from memory at address indicated by HL to A.
	or	a		; Same as CP 0 but faster.
	ret	z		; Back behind the call print if A = 0
	call	CHPUT		; Call the routine to display a character.
	inc	hl		; Increment the HL value.
	jr	Print		; Relative jump to the address in the label Print.
 
 
; Message data
Hello_TXT:			; Set the current address into label Hello_TXT. (text pointer)
	db "Hello world!",0	; Zero indicates the end of text.

By fpracek

Resident (51)

Аватар пользователя fpracek

13-03-2023, 12:53

Thanks!!!