Skip to content

Commit

Permalink
fix(comments): minor grammar tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
lukepeterson committed Jun 30, 2024
1 parent a422681 commit e2e88da
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
9 changes: 4 additions & 5 deletions assembler/assembler.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,8 @@ func (a *Assembler) parseLine(line string) error {
return err
}

// Split the 16-bit int into high and low order bytes
// The 8080 CPU is little endian, so we need to split the bytes
// and return the low order byte first.
// Split the 16-bit int into high and low order bytes. The 8080 CPU is little endian,
// so we split the bytes and return the low order byte first.
a.ByteCode = append(a.ByteCode, instruction.Opcode, byte(lowByte), byte(highByte))
default:
return fmt.Errorf("invalid instruction length for: %v", tokens[0])
Expand All @@ -79,7 +78,7 @@ func (a *Assembler) parseLine(line string) error {
return nil
}

// parseHex takes a string with an H suffix or 0x prefix and parses it into a 16 bit integer, returning the result as two int8s. This has a nice side effect of being able to take a one byte string and also returning the result as two 8bit integers, which is required for our two byte instructions. For example: "4AH" -> 0x00, 0x4A.
// parseHex takes a string with an H suffix or 0x prefix and parses it into a 16 bit integer, returning the result as two int8s. This has a nice side effect of being able to take a one byte string and also returning the result as two 8-bit integers, which is required for our two-byte instructions. For example: "4AH" -> 0x00, 0x4A.
func parseHex(token string) (uint8, uint8, error) {
token = strings.TrimSuffix(token, "H")
token = strings.TrimPrefix(token, "0X")
Expand All @@ -95,7 +94,7 @@ func parseHex(token string) (uint8, uint8, error) {
return highByte, lowByte, nil
}

// Assemble takes a newline separated string of code, parses the input into tokens, and then converts each instruction to a valid opcode from the instructionSet.
// Assemble takes a newline separated string of code, parses the input into tokens, and then converts each instruction to a valid opcode from the instructionSet map.
func (a *Assembler) Assemble(code string) error {
lines := strings.Split(code, "\n")
for _, line := range lines {
Expand Down
2 changes: 1 addition & 1 deletion assembler/tokeniser.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func tokenise(line string) ([]string, error) {
return tokens, nil
}

// normalise takes an input string, converts it to upper case, strips out extra spaces, and makes all comma formatting consistent, helping us match against out opcode map.
// normalise takes an input string, converts it to upper case, strips out extra spaces, and makes all comma formatting consistent, helping us match against our opcode map.
func normalise(line string) string {
line = strings.ToUpper(line)

Expand Down

0 comments on commit e2e88da

Please sign in to comment.