How simple an 8 bit output?

Recurrent H/W and software problems
Post Reply
Jan Volk
Posts: 71
Joined: Wed Mar 03, 2021 1:35 pm
Been thanked: 23 times

How simple an 8 bit output?

Post by Jan Volk »

wlog
e = &b00000101 ' decimal 5
f = &b10000001 ' decimal 129
wlog bin$(e), bin$(f) ' output: 101 10000001
wlog e, f ' output: 5 129
wlog
wlog str$(e, "%3.0f") ' output: 5
wlog str$(f, "%3.0f") ' output: 129
wlog str$(e, "%08x") ' output: 00000000
end

' How do I get the output for e: 00000101 ?
' Can the binary value also be integrated in the str$( ) function e.g. str$(e, "%08b") ?
User avatar
cicciocb
Site Admin
Posts: 1889
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 405 times
Been thanked: 1261 times
Contact:

Re: How simple an 8 bit output?

Post by cicciocb »

You can simply do

Code: [Local Link Removed for Guests]

e = &b00000101 ' decimal 5
wlog right$("00000000" + bin$(e), 8)
Jan Volk
Posts: 71
Joined: Wed Mar 03, 2021 1:35 pm
Been thanked: 23 times

Re: How simple an 8 bit output?

Post by Jan Volk »

Thank you Cicciocb for your quick response

I didn't know Annex32 Basic was so flexible.
This example was immediately included in my own translated manual in Dutch at bin$ and right$.
Tested and it works perfectly.

I started a long time ago with a ZX81 and a Commodore64 and then with Bascom AVR and also Arduino c which is too complicated for me. Then Annex32 Basic is the solution. :D
User avatar
cicciocb
Site Admin
Posts: 1889
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 405 times
Been thanked: 1261 times
Contact:

Re: How simple an 8 bit output?

Post by cicciocb »

Interesting, maybe if other people are interested, you could share the doc translated with other Dutch users.
Post Reply