How do you calculate N mod K in LC3? N comes from mem location x3100 and K comes from mem location x3101 and you want to store the result of N mod K in x3102
1
There are 1 answers
Related Questions in ASSEMBLY
- Is there some way to use printf to print a horizontal list of decrementing hex digits in NASM assembly on Linux
- How to call a C language function from x86 assembly code?
- Binary Bomb Phase 2 - Decoding Assembly
- AVR Assembly Clock Cycle
- Understanding the differences between mov and lea instructions in x86 assembly
- ARM Assembly code is not executing in Vitis IDE
- Which version of ARM does the M1 chip run on?
- Why would %rbp not be equal to the value of %rsp, which is 0x28?
- Move immediate 8-bit value into RSI, RDI, RSP or RBP
- Unable to run get .exe file from assembly NASM
- DOSbox automatically freezes and crashes without any prompt warnings
- Load function written in amd64 assembly into memory and call it
- link.exe unresolved external symbol _mainCRTStartup
- x86 Wrote a boot loader that prints a message to the screen but the characters are completely different to what I expected
- running an imf file using dosbox in parallel to a game
Related Questions in MODULO
- Mod operator returning wrong output
- Dispatch metadata from WordPress DB query into a table with 4 columns
- Why don't x86-64 (or other architectures) implement division by 10?
- Best way to set desired range with inverse trig functions?
- Why two modular operations cannot be optimized as well as one modular operation
- How to sort lists of matrices and find the index of a matrix on a list?
- Google Sheets - Why are there garbage digits in MOD(??)&"*"?
- How to write c language modulo 2 with use mpfr function?
- Python how to convert total teaspoons to tablespoons, ounces, cups, and pints using modulus and floor division
- How to evaluate an expression in SageMath over Zmod?
- Alternate show of every 3 then every 1 item
- swap group of characters every words in list
- JS Last value in array is never checked when looped
- Save data every t time units in R
- Julia modulo of vector (or remainer of vector)
Related Questions in MODULUS
- Write a function that takes in an array of integers, and a string that will be either 'even' or 'odd'
- C program for computing greatest common divisor gives wrong answer
- PHP modulus function not give me expected results
- Pricing discount logic, 2 for $4, 6 for the price of 5
- c# modulus operator on floats
- Why is 4 % -8 equal to 4?
- Calculate modulo in LC3
- CSS Formula for Precisely Offsetting Text
- Range queries on a binary string?
- Probable complete loss of accuracy in modulus warning and incorrect results when using certain numbers with the modulus function
- Solving modulo in c#
- Script ignores set to false
- Modulus and float numbers
- Divsion with no remainder
- Please help make Modulo Simple To Understand
Related Questions in LC3
- Installing the C compiler for LC3
- LC-3 Assembly OR operation
- I am unsure about LC-3 NOP
- LC-3 Assemby Counters
- Assembly - Prime/Not Prime - LC3
- How to return from HALT in LC3?
- How can I take multiple digit positive integers as input in LC3?
- How can I print a multiple-digit decimal number stored in a register in LC-3 assembly?
- LC-3 Program: Tracing the Execution
- Is there a reason this LC-3 subroutine keeps looping?
- LC-3 Assembly Calculator
- How do I modify my code to compare the user input against "QUIT" and have it exit the loop if they don't match?
- LC-3 program with 3 bugs (2 syntax and 1 logic)
- LC-3 Assembly Code isn't processing user's input correctly
- What is the equivalent of .WORD in LC3?
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Popular Tags
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
One way to do modulo is to do division by repetitive subtraction; this will yield a quotient and a remainder (the modulo). In the following N is the dividend and K is the divisor.
Start a tally at 0; this tally will count how many times we can subtract the divisor from the dividend.
Then loop, as long as the dividend is greater or equal to the divisor, subtract the latter from the former putting the result back into the dividend, and since we were able to do the subtraction, add one to the quotient. Note that the dividend is updated each iteration of the loop (it gets smaller each iteration).
When this loop finishes, the tally is the quotient, and the (updated) dividend is the remainder leftover that could not be subtracted. (The remainder will be less than the divisor. If it is zero the division was "even"/exact.)
This algorithm handles unsigned numbers (dividend and divisor). It can be adapted for signed, usually by negating negative numbers and then doing the unsigned division algorithm (and negating the answers as appropriate).
This is probably the simplest way to do division/modulo on a processor that doesn't have multiply or divide. Let's note that in the pathological case (65535/1) it will iterate 65535 times, which is a lot of iteration.
The study of integer division on processors that don't have good built-in divide operations is rather large. I believe that using the divide step operation, we can complete any division in 16 iterations (for 16 bit words), more complicated, of course, considering the LC-3 does not have right shift. (The idea is to subtract large chunks of the divisor multiplied by ever smaller powers of 2, i.e. long division in binary.) Further, when the divisor is known to be constant, there are lots of trick as well (e.g. dividing by, say 10, or by 3).