From 9f21818aaadf6f02660ae35af56ab936462bbb64 Mon Sep 17 00:00:00 2001 From: xolatile Date: Tue, 12 Dec 2023 14:06:27 -0500 Subject: [PATCH] Finished flat assembly version... --- xscii.asm | 92 ++++++++++++++++++++++++--------------------------------------- 1 file changed, 35 insertions(+), 57 deletions(-) diff --git a/xscii.asm b/xscii.asm index f6ee997..078d3b5 100644 --- a/xscii.asm +++ b/xscii.asm @@ -29,6 +29,21 @@ macro output_number number, base, offset, character, colour, effect { 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 segment readable executable @@ -40,32 +55,16 @@ entry $ output_number [character_index], 10, 4, align_space, COLOUR_CYAN, EFFECT_ITALIC output_number [character_index], 16, 3, align_space, COLOUR_CYAN, EFFECT_BOLD - call output_bar - mov rbx, COLOUR_BLUE - 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 + output_string [character_index], code_list, 3, COLOUR_BLUE, EFFECT_BOLD + output_string [character_index], name_list, 24, COLOUR_PINK, EFFECT_NORMAL mov rax, [character_index] and rax, 1 - ;~mov rbx, 2 - ;~div rbx - ;~cmp rdx, 0 cmp rax, 0 je skip_line - mov rbx, align_line - mov rbp, 1 - call output_string + mov rbx, align_line + mov rbp, 1 + call output_text skip_line: inc [character_index] @@ -76,35 +75,35 @@ entry $ mov rax, 60 syscall -output_string: +output_text: mov rax, 1 mov rdi, 1 - mov rsi, rbx; string - mov rdx, rbp; length + mov rsi, rbx + mov rdx, rbp syscall ret output_colour: - mov [output_colour_format + 5], bl; effect - mov [output_colour_format + 2], bpl; colour + mov [output_colour_format + 5], bl + mov [output_colour_format + 2], bpl mov rbx, output_colour_format mov rbp, 7 - call output_string + call output_text ret output_cancel: mov rbx, output_colour_cancel mov rbp, 4 - call output_string + call output_text ret output_align: - mov r15, rbx; count - mov r14, rbp; align + mov r15, rbx + mov r14, rbp loop_statement: mov rbx, r14 mov rbp, 1 - call output_string + call output_text dec r15 cmp r15, 0 jne loop_statement @@ -116,17 +115,16 @@ output_bar: call output_colour mov rbx, align_bar mov rbp, 3 - call output_string + call output_text call output_cancel ret offset_base: mov ax, bx - ;~mov [output_length], 0 number_loop_statement: div bpl - mov [output_quotient], al; code / base - mov [output_remainder], ah; code % base + mov [output_quotient], al + mov [output_remainder], ah mov r14, output_format add r14, [output_length] mov r15, output_cypher @@ -136,7 +134,7 @@ offset_base: xor rax, rax mov al, [output_quotient] inc [output_length] - cmp [output_quotient], 0 + cmp rax, 0 jne number_loop_statement ret @@ -146,32 +144,12 @@ output_base: add rbx, [output_length] dec rbx mov rbp, 1 - call output_string + call output_text dec [output_length] cmp [output_length], 0 jne output_loop_statement 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 character_index dq 0