title: How to print numbers from 1 to n using assembly language?
body: <p>I'm new to assembly language and I'm trying to print 1 to n numbers using assembly language, without using C libraries. I'm using qemu as my emulator for raspberry pi.</p>
  
  <p>Here is a sample code that I tried</p>
  
  <pre><code>    .global _start
  _start:
  MOV R7, #3 @ Syscall read from keyboard
  MOV R0, #0 @ Input stream keyboard
  MOV R2, #1  @ Read 1 characters
  LDR R1, =character @ Put number in R1
  MOV R6,R1 @Holding value of R1 i.e. the input number 'n'
  MOV R1,#0 @initialiing value 
  MOV R2, #1 @counter
  SWI 0
  
  _loop:
  AND R1, R1, R2 @Add one to each value of R1
  B _write @print the value
  SWI 0
  
  
  _write:
  MOV R7,#4 @ Syscall for output
  MOV R0,#1 @ Output stream for R1
  MOV R2,#1
  CMP R1,R6 @Compare if the value is equal to 'n'
  BNE _loop @if less than, then add again and print
  SWI 0
  
  end:
  MOV R7,#1
  SWI 0
  
  .data
  character:
  .word 0
  </code></pre>
  
  <p>Please let me know, how is it supposed to be done.</p>
  
  <p>Thanks</p>