Skip to content

Commit

Permalink
Support Unicode characters in sys_read
Browse files Browse the repository at this point in the history
Also provide a configurable register identifier for the destination,
just like with `sys_puts`. Thanks Leonard for the suggestions:
  #8 (comment)
  • Loading branch information
akkartik authored and KCreate committed Jul 22, 2017
1 parent 3c15b65 commit b5e7fa2
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/machine/vm.cr
Original file line number Diff line number Diff line change
Expand Up @@ -1083,9 +1083,10 @@ module VM
value = reg_read Int32, reg
STDOUT.puts "#{value}"
when Syscall::READ
reg = Register.new stack_pop UInt8
char = STDIN.raw &.read_char
if char.is_a?(Char)
reg_write Register::R0.byte, char.ord
reg_write reg, char.ord
end
else
invalid_syscall id
Expand Down

0 comments on commit b5e7fa2

Please sign in to comment.