Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7179535
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:09:36+00:00 2026-05-28T17:09:36+00:00

I prefer to code on my calculator in hex. I know my opcodes and

  • 0

I prefer to code on my calculator in hex. I know my opcodes and what not, but i’m not sure how to create a string “hello” in register HL. Cany you help? I have googled it, but it’s hard to find an answer because most people use compilers that handle that for them. I want to do this the hard and challenging way though. But I want the most efficient way of doing it in hex.

I tried….

[code here]
C9 – RETURN
[STRING HERE]

…but it doesn’t seem LD has a way to get relative data. So I can’t even get the address location after C9. Any tips?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T17:09:37+00:00Added an answer on May 28, 2026 at 5:09 pm

    You can’t store 5 ASCII characters (“hello”) in a 2-byte register, which HL is. The only thing you can do is store these 5 characters somewhere in the memory and load HL with the address of this string (effectively, the address of its first character “h”).

    EDIT:

    If you need to find the location of your subroutine while it’s executing, you can read the return address from the stack and then minimally disassemble the instruction just before the return address.

    If it’s CALL (cc,) nn or JP (cc,) nn, the subroutine’s address is encoded in the instruction’s two last bytes.

    If it’s JP (HL/IX/IY), the address is in the register (HL, IX or IY) used for the indirect jump. To be able to recover this address, you’ll have to save these registers’ values in your subroutine (using e.g. PUSH).

    If it’s RET (cc), the address was on the stack when your subroutine started, but it may since have been overwritten by your routine’s activities or that of the interrupt service routines. This is a tough case, but I hope it’s not RET.

    You can’t disassemble the instruction blindly and reliably at the same time because different instructions have different lengths and what you may recognize as JP (HL) can in fact be just a part of a longer CALL nn. But the code that invokes your subroutine is unlikely to change and chances are there’s only one place or one method of invocation, which means that once you know the instruction that’s used to invoke your subroutine, you don’t need to guess anything anymore, just write your code assuming it’s always that instruction.

    Using the above technique, you can use the layout you suggested in the question:

    [code here] C9 – RETURN [STRING HERE]

    You just need to recover the subroutine’s address and add to it the subroutine’s size. That’ll be the address of the string.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

It's not too difficult to implement, but I'd prefer code reuse if possible. my
I need to access a mysql database from c# code but I would prefer
I work in a Windows environment and would prefer to deploy code to IIS.
I have some template code that I would prefer to have stored in a
I'm looking for source code for a web based study group. I'd prefer something
I've never written functional specs, I prefer to jump into the code and design
I prefer to keep our SSIS packages in a solution on the server, not
I'm working on an LGPL game engine library and I prefer to code without
I'm trying to mass indent my code in the way I prefer it -
I prefer to code with white space visible and I use tabs. (no holy

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.