Welcome to Gaia! ::

I've grown to be relatively dumb and am having a difficult time working with 68k assembly language

I have to write a small program where I ask a user input 2 ASCII characters, convert them to binary, add them, then convert it back to ASCII.

Without a modulus though, and the ability to use IF statements, I don't know how to do this.

I think I have the steps, but how to get to that is confusing me. Also, I have no idea if what I'm doing is even correct at this point. I'm a bit confused on data registers and always worried my information is going to be written over, so everything is saved in separate data registers only to be moved back later.

ALSO: Should I use MOVE.B #4? OR #5? I want to go back to #4 but a bit worried that's not it for some reason.

ALSO X2: I am aware I don't even have a back conversion done, and am a bit confused on that still, but I also just need to get one side working somehow.

EDIT: I posted it to Pastebin so I could shorten this thread and tack on one more question! Thanks for listening!

ASCII to Binary question --& http://pastebin.com/ptWhFQgT


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SECOND QUESTION

I have to have a user input a string of 80 characters or less, and convert all lowercase to uppercase. I know this is done by subtracting $20 from the lowercase letters. So I tried to make a branch if the value is greater than or equal to $61, then subtract $20. But no matter how I warp this (I've tried less than, less than or equal to, etc), it keeps saying that line 22 is invalid.

Which is why the comments state the less than argument, the code just does greater than, and I'm at a loss.

I've tried both signed and unsigned op codes, but I thought ASCII was unsigned. Not sure what's going on here.

http://pastebin.com/G1NyHdwv

Thank you again!
Captain Say
Without a modulus though, and the ability to use IF statements, I don't know how to do this.
I don't know why you think you need modulus. But you can do that by performing a DIV, then MUL the quotient by the divisor, then SUB the result from MUL from the result from DIV.

It's sufficient to subtract 0x30 from the input characters, test that they're within the range of 0x0 and 0x9, and perform operations on them. (The numbers 0-9 map to 0x30-0x39 in ASCII.)

And you have IF "statements." They're in the form of SUB (subtract), TST (test if zero), JMP (jump), CMP (compare), and Bcc (branch if...) This is how you do the equivalent of "IF." (CMP is equivalent to SUB then TST, and then you can issue instructions like BEQ, BGE, etc. to jump to another location.)

Assembly has no concept of higher-level ideas like blocks and functions and so forth.
Captain Say
I have to have a user input a string of 80 characters or less, and convert all lowercase to uppercase. I know this is done by subtracting $20 from the lowercase letters. So I tried to make a branch if the value is greater than or equal to $61, then subtract $20. But no matter how I warp this (I've tried less than, less than or equal to, etc), it keeps saying that line 22 is invalid.
Because BGT takes a label as an argument. You need to do:
CMP #$61, D1
BLT NOPE
SUBB #$20, D1
NOPE


I think you need to review your course materials. Get your instructor to review this with you if you can.
psychic stalker
Captain Say
Without a modulus though, and the ability to use IF statements, I don't know how to do this.
I don't know why you think you need modulus. But you can do that by performing a DIV, then MUL the quotient by the divisor, then SUB the result from MUL from the result from DIV.

It's sufficient to subtract 0x30 from the input characters, test that they're within the range of 0x0 and 0x9, and perform operations on them. (The numbers 0-9 map to 0x30-0x39 in ASCII.)

And you have IF "statements." They're in the form of SUB (subtract), TST (test if zero), JMP (jump), CMP (compare), and Bcc (branch if...) This is how you do the equivalent of "IF." (CMP is equivalent to SUB then TST, and then you can issue instructions like BEQ, BGE, etc. to jump to another location.)

Assembly has no concept of higher-level ideas like blocks and functions and so forth.
Captain Say
I have to have a user input a string of 80 characters or less, and convert all lowercase to uppercase. I know this is done by subtracting $20 from the lowercase letters. So I tried to make a branch if the value is greater than or equal to $61, then subtract $20. But no matter how I warp this (I've tried less than, less than or equal to, etc), it keeps saying that line 22 is invalid.
Because BGT takes a label as an argument. You need to do:
CMP #$61, D1
BLT NOPE
SUBB #$20, D1
NOPE


I think you need to review your course materials. Get your instructor to review this with you if you can.
I need to learn how to word things better! But thank you!!

I know there are other arguments to reform an IF Statement, such as branching, I guess I'm just not akin to figuring them out quite yet. I've only gotten to work with the language a few days after going through a couple of weeks of discussions on memory and such. Suddenly he threw the language at us and this entire weekend I've been learning about OP codes and things. I'll definitely ask him to explain a bit more tomorrow during class.

But your explanations are fantastic and I very much appreciate the help!
psychic stalker
I hate to bring this back up, but my professor doesn't feel much like helping and google is relatively difficult to use for specific questions. You're rather knowledgeable so I was wondering if you could help me again? If not, I completely understand.

http://pastebin.com/rRbsJW04

I have to convert from lowercase to uppercase. I kind of have it, but I'm not sure HOW to attach a null to the new string so that I can properly display it? It displays the properly converted string, just crashes as it does it.

Also, he's asking me to make it position independent. I've looked it up a bit, and I guess memory is something I'm still having a bit of a difficult time understanding completely.

I understand that position independent code would run regardless of where you move it in memory. I've moved it around in memory and it does, indeed crash.

I'm trying to decipher this language on my own and it's just really different from everything else I've messed with. Nothing like a high-level language.
Your prof is a d**k if he doesn't make time to help you.
Captain Say
I have to convert from lowercase to uppercase. I kind of have it, but I'm not sure HOW to attach a null to the new string so that I can properly display it? It displays the properly converted string, just crashes as it does it.
You're probably writing past the end of it or walking off into memory you're not supposed to use.

What's the post-condition of the input routine? Does it leave A1 set to the end of where it wrote to the buffer? If so, then write a 0x0 at that location before you reload the address of BUFF to A1.
Captain Say
Also, he's asking me to make it position independent. I've looked it up a bit, and I guess memory is something I'm still having a bit of a difficult time understanding completely.
You know where BUFF is, relative to START. (Hint: BUFF - START) So refer to it by its distance from START instead of using its address as-is.
Captain Say
I'm trying to decipher this language on my own and it's just really different from everything else I've messed with. Nothing like a high-level language.
That's why it's called a "low-level language." You're talking to the machine through a very direct translation. You have to think like the machine to talk to it effectively.

Read through your code. What does each line do? What will happen after that line executes? What's the pre- and post-condition of the registers after each instruction?

Think about those things, and it'll start to become more obvious what you're doing.

Quick Reply

Submit
Manage Your Items
Other Stuff
Get Items
Get Gaia Cash
Where Everyone Hangs Out
Other Community Areas
Virtual Spaces
Fun Stuff