Hex1

From Esolang
Jump to navigation Jump to search
This article is not detailed enough and needs to be expanded. Please help us by adding some more information.

Hex1 is the most obvious and logical extension of the hex0 language. As the hardest part of writing programs in hex is having to manually count bytes to know the size of the offset needed for jumps and loops. So we add single letter labels (such as :a and :b) and a single sized offset pointer which will automatically populate with the offset (@a and @b)

below is the list of common prefix symbols for the offset pointers:

  • ! - 8 bit relative address
  • @ - 16 bit relative address
  • % - 32 bit relative address
  • ~ - architecture specific relative (usually 24bit)
  • $ - 16 bit absolute address
  • & - 32 bit absolute address
; First pass loop to determine addresses of labels
:f ;First_pass
    13 01 81 FF     # RD_SP RS1_SP !-8 ADDI             ; Allocate stack
    23 30 11 00     # RS1_SP RS2_RA SD                  ; protect ra

:1 ;First_pass_loop
    $R EF 00 00 00  # RD_RA $Read_byte JAL              ; Get another byte

    ; Deal with EOF
    13 03 C0 FF     # RD_T1 !-4 ADDI
    @3 63 00 65 00  # RS1_A0 RS2_T1 @First_pass_done BEQ

Example of .hex1 code from hex2

See also