public inbox for ~johnnyrichard/olang-devel@lists.sr.ht
 help / color / mirror / code / Atom feed
From: Carlos Maniero <carlos@maniero.me>
To: ~johnnyrichard/olang-devel@lists.sr.ht
Cc: Carlos Maniero <carlos@maniero.me>
Subject: [PATCH olang v1] codegen: x64: use the low bit register for 8 bits ops
Date: Thu, 17 Oct 2024 00:16:57 +0000 (UTC)	[thread overview]
Message-ID: <20241017001654.271323-1-carlos@maniero.me> (raw)

There was some registers that was using the high bit instead.

Signed-off-by: Carlos Maniero <carlos@maniero.me>
---
 src/codegen_x86_64.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/codegen_x86_64.c b/src/codegen_x86_64.c
index 1951365..c4cef3c 100644
--- a/src/codegen_x86_64.c
+++ b/src/codegen_x86_64.c
@@ -967,7 +967,7 @@ get_reg_for(x86_64_register_type_t type, size_t bytes)
     switch (type) {
         case REG_ACCUMULATOR: {
             if (bytes <= 1) {
-                return "%ah";
+                return "%al";
             } else if (bytes <= 2) {
                 return "%ax";
             } else if (bytes <= 4) {
@@ -977,7 +977,7 @@ get_reg_for(x86_64_register_type_t type, size_t bytes)
         }
         case REG_BASE: {
             if (bytes <= 1) {
-                return "%bh";
+                return "%bl";
             } else if (bytes <= 2) {
                 return "%bx";
             } else if (bytes <= 4) {
@@ -987,7 +987,7 @@ get_reg_for(x86_64_register_type_t type, size_t bytes)
         }
         case REG_COUNTER: {
             if (bytes <= 1) {
-                return "%ch";
+                return "%cl";
             } else if (bytes <= 2) {
                 return "%cx";
             } else if (bytes <= 4) {
@@ -997,7 +997,7 @@ get_reg_for(x86_64_register_type_t type, size_t bytes)
         }
         case REG_DATA: {
             if (bytes <= 1) {
-                return "%dh";
+                return "%dl";
             } else if (bytes <= 2) {
                 return "%dx";
             } else if (bytes <= 4) {

base-commit: c01fa7cf444bdd2cc9d6befff462285783263413
-- 
2.46.1


             reply	other threads:[~2024-10-17  0:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-17  0:16 Carlos Maniero [this message]
2024-10-17  0:17 ` [olang/patches/.build.yml] build success builds.sr.ht
2024-10-17  2:19 ` [PATCH olang v1] codegen: x64: use the low bit register for 8 bits ops Johnny Richard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241017001654.271323-1-carlos@maniero.me \
    --to=carlos@maniero.me \
    --cc=~johnnyrichard/olang-devel@lists.sr.ht \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.johnnyrichard.com/olang.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox