Skip to content

Add division operator support#27

Open
deepanshu1422 wants to merge 1 commit intoxorvoid:mainfrom
deepanshu1422:feature/division-modulo
Open

Add division operator support#27
deepanshu1422 wants to merge 1 commit intoxorvoid:mainfrom
deepanshu1422:feature/division-modulo

Conversation

@deepanshu1422
Copy link

This adds the division operator (/) to the language.

  • Implements unsigned division using x86 div instruction
  • Adds special handling in emit_div_op for division operations
  • Updates linter to recognize / as a valid operator
  • Updates grammar documentation
  • Adds test example demonstrating division

The implementation emits "xor dx,dx; div cx" to perform unsigned division with the quotient returned in ax.

Total size impact: 0 bytes (still fits in 512-byte boot sector) This was achieved by using xchg instead of mov in emit_op, saving the exact bytes needed for the division operator.

This adds the division operator (/) to the language.
- Implements unsigned division using x86 div instruction
- Adds special handling in emit_div_op for division operations
- Updates linter to recognize / as a valid operator
- Updates grammar documentation
- Adds test example demonstrating division

The implementation emits "xor dx,dx; div cx" to perform unsigned
division with the quotient returned in ax.

Total size impact: 0 bytes (still fits in 512-byte boot sector)
This was achieved by using xchg instead of mov in emit_op, saving
the exact bytes needed for the division operator.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant