You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please can the following be added to both hex.bas which prints a binary representation of a byte, eg 8 would return "00001000"
function FASTCALL BinToString(num as ubyte) as String
asm
PROC
push namespace core
LOCAL END_CHAR
LOCAL DIGIT
LOCAL charloop
LOCAL bitisset
LOCAL nobitset
push af ; save ubyte
ld bc,10
call __MEM_ALLOC
ld a, h
or l
pop bc
ld c,b
ret z ; NO MEMORY
push hl ; Saves String ptr
ld (hl), 8
inc hl
ld (hl), 0
inc hl ; 8 chars string length
; c holds out entry 8 bit value, b number of bits
ld b,8
charloop:
call DIGIT
djnz charloop
pop hl ; Recovers string ptr
ret
DIGIT:
ld a,c
bit 7,a
jr nz,bitisset
ld a,'0'
jr nobitset
bitisset:
ld a,'1'
nobitset:
END_CHAR:
ld (hl), a
inc hl
ld a,c
sla c
ret
ENDP
pop namespace
end asm
end function
The text was updated successfully, but these errors were encountered:
Please can the following be added to both hex.bas which prints a binary representation of a byte, eg 8 would return "00001000"
The text was updated successfully, but these errors were encountered: