boo-os/strings.asm

150 lines
3.8 KiB
NASM
Raw Normal View History

2021-11-09 02:19:34 +00:00
label draw_char_pixels:
shift 5 2 1; Shift 5 by count in R(2)
loadi 6 1;
and 1 6 1; Mask with 0x01
loadi 6 $FFFFFF
mul 1 6 1;
tx $C $2
loadi $2 0
2021-11-09 02:19:34 +00:00
jeq +2
rstore 1 $B; Transfer RAX to the Address Stored in R11
tx $2 $C
2021-11-09 02:19:34 +00:00
inc $B; Increment VBuf Pointer
inc 2; INC Scratch Pixel
loadi 1 8; For Every Pixel in this Row of 8
jneq draw_char_pixels
ret
label draw_char:
ldstore 4 3; Load Arg 1 in 3
loadi 6 $18;
shift 3 6 5; Shift To First Byte
loadi 2 0; Set Pixel to 8
call draw_char_pixels
loadi 6 $278
add $6 $B $B ; Move VBUF
loadi 6 $10;
shift 3 6 5; Shift To Second Byte
loadi 6 $0000FF;
and 6 5 5; Mask Off
loadi 2 0; Set Pixel to 8
call draw_char_pixels
loadi 6 $278
add $6 $B $B ; Move VBUF
loadi 6 $8;
shift 3 6 5; Shift To Third Byte
loadi 6 $0000FF;
and 6 5 5;
loadi 2 0; Set Pixel to 8
call draw_char_pixels
loadi 6 $278
add $6 $B $B ; Move VBUF
loadi 6 $0;
shift 3 6 5; Shift To 4th Byte
loadi 6 $0000FF;
and 6 5 5; MASK off last Byte
loadi 2 0; Set Pixel to 8
call draw_char_pixels
loadi 6 $278
add $6 $B $B ; Move VBUF
inc 4; Move to Second Part
ldstore 4 3; Load Arg 1 in 3
loadi 6 $18;
shift 3 6 5; Shift To First Byte
loadi 2 0; Set Pixel to 8
call draw_char_pixels
loadi 6 $278
add $6 $B $B ; Move VBUF
loadi 6 $10;
shift 3 6 5; Shift To Second Byte
loadi 6 $0000FF;
and 6 5 5; Mask Off
loadi 2 0; Set Pixel to 8
call draw_char_pixels
loadi 6 $278
add $6 $B $B ; Move VBUF
loadi 6 $8;
shift 3 6 5; Shift To Third Byte
loadi 6 $0000FF;
and 6 5 5;
loadi 2 0; Set Pixel to 8
call draw_char_pixels
loadi 6 $278
add $6 $B $B ; Move VBUF
loadi 6 $0;
shift 3 6 5; Shift To 4th Byte
loadi 6 $0000FF;
and 6 5 5; MASK off last Byte
loadi 2 0; Set Pixel to 8
call draw_char_pixels
ret
2021-11-09 02:19:34 +00:00
label _scratch_draw_string:
nop
label draw_string:
label draw_next_char:
ldstore 4 3; Load Arg 1 in 3
store 4 _scratch_draw_string
loadi $2 $20 ; Load Addr of [SPACE] in $2
sub $3 $2 $1 ; Sub the Character From Space
loadi $2 2
mul $1 $2 $1 ; Mull By 2
loadi $2 char_space
add $2 $1 $1 ; Add to Char Space
tx $4 $1
call draw_char; Call draw_char
loadi $2 8
add $2 $9 $9; // X = X + 9
call set_pos
load $4 _scratch_draw_string
inc $4;
ldstore 4 3; Load Arg 1 in 3
tx $2 $3
loadi $1 0
jneq draw_next_char
ret
label num_to_char:
loadi $2 HEX_TABLE
add $2 $4 $4
ldstore 4 3; Load Arg 1 in 3
loadi $2 $20 ; Load Addr of [SPACE] in $2
sub $3 $2 $1 ; Sub the Character From Space
loadi $2 2
mul $1 $2 $1 ; Mull By 2
loadi $2 char_space
add $2 $1 $1 ; Add to Char Space
tx $4 $1
ret