Finished flat assembly version...

This commit is contained in:
Ognjen Milan Robovic 2023-12-12 14:06:27 -05:00
parent 1827ae037f
commit 9f21818aaa

View File

@ -29,6 +29,21 @@ macro output_number number, base, offset, character, colour, effect {
call output_cancel call output_cancel
} }
macro output_string index, array, offset, colour, effect {
call output_bar
mov rbx, colour
mov rbp, effect
call output_colour
mov rax, index
mov rbx, offset
mul rbx
mov rbx, array
add rbx, rax
mov rbp, offset
call output_text
call output_cancel
}
format ELF64 executable 3 format ELF64 executable 3
segment readable executable segment readable executable
@ -40,32 +55,16 @@ entry $
output_number [character_index], 10, 4, align_space, COLOUR_CYAN, EFFECT_ITALIC output_number [character_index], 10, 4, align_space, COLOUR_CYAN, EFFECT_ITALIC
output_number [character_index], 16, 3, align_space, COLOUR_CYAN, EFFECT_BOLD output_number [character_index], 16, 3, align_space, COLOUR_CYAN, EFFECT_BOLD
call output_bar output_string [character_index], code_list, 3, COLOUR_BLUE, EFFECT_BOLD
mov rbx, COLOUR_BLUE output_string [character_index], name_list, 24, COLOUR_PINK, EFFECT_NORMAL
mov rbp, EFFECT_BOLD
call output_colour
mov rbx, [character_index]
call output_code
call output_cancel
call output_bar
mov rbx, COLOUR_PINK
mov rbp, EFFECT_NORMAL
call output_colour
mov rbx, [character_index]
call output_name
call output_cancel
mov rax, [character_index] mov rax, [character_index]
and rax, 1 and rax, 1
;~mov rbx, 2
;~div rbx
;~cmp rdx, 0
cmp rax, 0 cmp rax, 0
je skip_line je skip_line
mov rbx, align_line mov rbx, align_line
mov rbp, 1 mov rbp, 1
call output_string call output_text
skip_line: skip_line:
inc [character_index] inc [character_index]
@ -76,35 +75,35 @@ entry $
mov rax, 60 mov rax, 60
syscall syscall
output_string: output_text:
mov rax, 1 mov rax, 1
mov rdi, 1 mov rdi, 1
mov rsi, rbx; string mov rsi, rbx
mov rdx, rbp; length mov rdx, rbp
syscall syscall
ret ret
output_colour: output_colour:
mov [output_colour_format + 5], bl; effect mov [output_colour_format + 5], bl
mov [output_colour_format + 2], bpl; colour mov [output_colour_format + 2], bpl
mov rbx, output_colour_format mov rbx, output_colour_format
mov rbp, 7 mov rbp, 7
call output_string call output_text
ret ret
output_cancel: output_cancel:
mov rbx, output_colour_cancel mov rbx, output_colour_cancel
mov rbp, 4 mov rbp, 4
call output_string call output_text
ret ret
output_align: output_align:
mov r15, rbx; count mov r15, rbx
mov r14, rbp; align mov r14, rbp
loop_statement: loop_statement:
mov rbx, r14 mov rbx, r14
mov rbp, 1 mov rbp, 1
call output_string call output_text
dec r15 dec r15
cmp r15, 0 cmp r15, 0
jne loop_statement jne loop_statement
@ -116,17 +115,16 @@ output_bar:
call output_colour call output_colour
mov rbx, align_bar mov rbx, align_bar
mov rbp, 3 mov rbp, 3
call output_string call output_text
call output_cancel call output_cancel
ret ret
offset_base: offset_base:
mov ax, bx mov ax, bx
;~mov [output_length], 0
number_loop_statement: number_loop_statement:
div bpl div bpl
mov [output_quotient], al; code / base mov [output_quotient], al
mov [output_remainder], ah; code % base mov [output_remainder], ah
mov r14, output_format mov r14, output_format
add r14, [output_length] add r14, [output_length]
mov r15, output_cypher mov r15, output_cypher
@ -136,7 +134,7 @@ offset_base:
xor rax, rax xor rax, rax
mov al, [output_quotient] mov al, [output_quotient]
inc [output_length] inc [output_length]
cmp [output_quotient], 0 cmp rax, 0
jne number_loop_statement jne number_loop_statement
ret ret
@ -146,32 +144,12 @@ output_base:
add rbx, [output_length] add rbx, [output_length]
dec rbx dec rbx
mov rbp, 1 mov rbp, 1
call output_string call output_text
dec [output_length] dec [output_length]
cmp [output_length], 0 cmp [output_length], 0
jne output_loop_statement jne output_loop_statement
ret ret
output_code:
mov rax, rbx
mov rbx, 3
mul rbx
mov rbx, code_list
add rbx, rax
mov rbp, 3
call output_string
ret
output_name:
mov rax, rbx
mov rbx, 24
mul rbx
mov rbx, name_list
add rbx, rax
mov rbp, 24
call output_string
ret
segment readable writable segment readable writable
character_index dq 0 character_index dq 0