Dan Snacks
Dan Snacks

Reputation: 31

Basic Assembly Labels and Jumping

So I'm working on some assembly and I'm testing some things out before I jump right into anything intermediate.
What I'm trying to do: The user inputs a number 0 or 1. The output is the number and whatever character the number starts with (O for one or Z for zero)
So the output for 0 should be 0Z and the output for 1 should be 1O.
I'm having issues because it only works for the 1, it doesn't output anything for 0. I'm sure its a very basic mistake, but if anyone could explain what the problem is that'd be lovely.
Also, if anyone beginner assembly resources they'd like to suggest I appreciate it. I couldn't find any that I particularly liked

         rdint %eax
         irmovl $1, %ecx
         irmovl $0, %edx
         subl %ecx, %eax
         je output1
         addl %edx, %eax
         je output0
         halt

output1: 
         irmovl $1, %ecx
         wrint %ecx
         irmovl $79, %ecx
         wrch %ecx
         halt
output0:
         irmovl $0, %ebx
         wrint %ebx
         irmovl $90, %ebx
         wrch %ebx
         halt

thanks

Upvotes: 1

Views: 624

Answers (1)

Dan Snacks
Dan Snacks

Reputation: 31

So I figured out what I was doing wrong. My syntax on the subl was wrong, because the order of the registers were wrong. Which was really confusing tome, as why they would have them in that order. Anyways in case anyone else is struggling with assembly i've been going over this tutorial the past hour and its helping http://www.tutorialspoint.com/assembly_programming/ (still looking for others, because it's not as readable as I'd like)
error:

    subl %ecx, %eax

Upvotes: 1

Related Questions