Skip to content

Commit

Permalink
whitespace align operants for start, main, match and match_cmpbyte
Browse files Browse the repository at this point in the history
feedback requested on what this sample does for readability
  • Loading branch information
markjenkins committed Feb 26, 2020
1 parent 3ca50bb commit 0a3389b
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions stage1/M0-macro-compact.hex2
Expand Up @@ -30,13 +30,13 @@

;; Setup offset table
0D00001 0 # READSCID R0 ; Get process capabilities
E100B0 1 0 000f # ANDI R1 R0 0xF ; We only care about size nybble
E100B0 1 0 000f # ANDI R1 R0 0xF ; We only care about size nybble
E0002D2 0 0001 # LOADUI R0 1 ; Assume we are 8bit
05032 0 0 1 # SL0 R0 R0 R1 ; Let size nybble correct answer
05032 0 0 1 # SL0 R0 R0 R1 ; Let size nybble correct answer
E0002F2 0 @offset_Text # STORER16 R0 @offset_Text ; Set ->TEXT offset
05001 1 0 0 # ADDU R1 R0 R0 ; twice the size is the offset of the expression
05001 1 0 0 # ADDU R1 R0 R0 ; twice the size is the offset of the expression
E0002F2 1 @offset_Expression # STORER16 R1 @offset_Expression ; Set ->EXPRESSION offset
05001 0 1 0 # ADDU R0 R1 R0 ; 3 times the size of the register is the size of the struct
05001 0 1 0 # ADDU R0 R1 R0 ; 3 times the size of the register is the size of the struct
E0002F2 0 @offset_struct # STORER16 R0 @offset_struct ; Set offset_struct


Expand All @@ -45,7 +45,7 @@
;; Writes results to Tape_02
;; Accepts no arguments and HALTS when done
:main
090004 C E # COPY R12 R14 ; calloc scratch
090004 C E # COPY R12 R14 ; calloc scratch
E0002D0 F @collect_defines # CALLI R15 @collect_defines ; Get all the defines

;; We need to rewind tape_01 to perform our second pass
Expand All @@ -65,29 +65,29 @@
;; Receives a CHAR* in R0, CHAR* in R1
;; Returns Bool in R0 indicating if strings match
:match
090200 1 F # PUSHR R1 R15 ; Protect R1
090200 2 F # PUSHR R2 R15 ; Protect R2
090200 3 F # PUSHR R3 R15 ; Protect R3
090200 4 F # PUSHR R4 R15 ; Protect R4
090005 2 0 # MOVE R2 R0 ; Put First string in place
090005 3 1 # MOVE R3 R1 ; Put Second string in place
090200 1 F # PUSHR R1 R15 ; Protect R1
090200 2 F # PUSHR R2 R15 ; Protect R2
090200 3 F # PUSHR R3 R15 ; Protect R3
090200 4 F # PUSHR R4 R15 ; Protect R4
090005 2 0 # MOVE R2 R0 ; Put First string in place
090005 3 1 # MOVE R3 R1 ; Put Second string in place
E0002D2 4 0000 # LOADUI R4 0 ; Set initial index of 0

:match_cmpbyte
0503A 0 2 4 # LOADXU8 R0 R2 R4 ; Get a byte of our first string
0503A 1 3 4 # LOADXU8 R1 R3 R4 ; Get a byte of our second string
E1000F 4 4 0001 # ADDUI R4 R4 1 ; Prep for next loop
090303 1 0 # CMPSKIP.NE R1 R0 ; Compare the bytes
0503A 0 2 4 # LOADXU8 R0 R2 R4 ; Get a byte of our first string
0503A 1 3 4 # LOADXU8 R1 R3 R4 ; Get a byte of our second string
E1000F 4 4 0001 # ADDUI R4 R4 1 ; Prep for next loop
090303 1 0 # CMPSKIP.NE R1 R0 ; Compare the bytes
E0002CA 1 @match_cmpbyte # JUMP.NZ R1 @match_cmpbyte ; Loop if bytes are equal
;; Done
0D00002 2 # FALSE R2 ; Default answer
090303 0 1 # CMPSKIP.NE R0 R1 ; If ended loop with everything matching
090303 0 1 # CMPSKIP.NE R0 R1 ; If ended loop with everything matching
0D00003 2 # TRUE R2 ; Set as TRUE
090005 0 2 # MOVE R0 R2 ; Prepare for return
090280 4 F # POPR R4 R15 ; Restore R4
090280 3 F # POPR R3 R15 ; Restore R3
090280 2 F # POPR R2 R15 ; Restore R2
090280 1 F # POPR R1 R15 ; Restore R1
090005 0 2 # MOVE R0 R2 ; Prepare for return
090280 4 F # POPR R4 R15 ; Restore R4
090280 3 F # POPR R3 R15 ; Restore R3
090280 2 F # POPR R2 R15 ; Restore R2
090280 1 F # POPR R1 R15 ; Restore R1
0D01001 F # RET R15


Expand Down

0 comments on commit 0a3389b

Please sign in to comment.