0

Iam beginner in assembly language, can any one explain what is wrong with my simple code and fix it?

Iam trying to read integer number and display it, my program is as follow:

.data
.global main
.extern printf
main:
    mov r1, #20 //read value 20 into register r1
    bl printf   //print the value

but why it seems not working ?!

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
hayith
  • 1
  • 2
  • 3
    `printf` expects as its first argument the address of a format string which tells it how to interpret the rest of the arguments. Also, you seem to be missing a call to `exit` or some other code that will terminate your program in a proper way. – Michael Oct 26 '20 at 17:09
  • @Michael can you fix it please cuz I really dont know how thanks – hayith Oct 26 '20 at 17:13
  • @Michael does this code correct based on what you said ? .data string: .asciz "%d\n" .text .global main .extern printf main: push {ip, lr} ldr r0, =string mov r1, #32 bl printf pop {ip, pc} – hayith Oct 26 '20 at 17:14

0 Answers0