Skip to content

Commit e28748a

Browse files
author
OnStarPrograms
committed
added some more material for BASE and Registers, and made the UI for the challenges into a little nicer format than originally
1 parent 4735b27 commit e28748a

File tree

2 files changed

+77
-0
lines changed

2 files changed

+77
-0
lines changed

src/part1/bin_and_hex.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,38 @@ If you’re having trouble converting between decimal and binary/hexadecimal, ch
114114
- Hexadecimal can be used as a "compact binary" notation.
115115
- Using binary or hexadecimal is useful when individual bits matter; otherwise, decimal works just as well.
116116
- For when numbers get a bit too long, RGBASM allows underscores between digits (`123_465`, `%10_1010`, `$DE_AD_BE_EF`, etc.)
117+
118+
:::challenge Challenge!
119+
120+
Answer the below questions on Binary and Conversions by hand!
121+
122+
1. Convert the __BASE 10__ number `96` to __Base 6__
123+
2. Convert the __BASE 16__ number `$FF` to __BASE 8__
124+
3. Add the __BASE 16__ number `$37` and the __BASE 2__ number `%1011 0110` together.
125+
126+
[Reference for converting bases (Libre Text)](https://math.libretexts.org/Courses/Florida_SouthWestern_State_College/MGF_1131%3A_Mathematics_in_Context__(FSW)/01%3A__Number_Representation_in_Different_Bases_and_Cryptography/1.03%3A_Converting_to_Different_Base_Systems)
127+
128+
129+
130+
<details>
131+
<summary>Answer (Click me!)</summary>
132+
133+
Reaching these answers can change drastically, this is just one way to solve such problems.
134+
### Answer 1
135+
---
136+
- The __BASE 10__ number `96` converts to `%0110 0000` in __BASE 2__, This can be found using the _"Short Division by 2 with Remainder"_ method.
137+
- From there you can convert __BASE 2__ `%0110 0000` to __BASE 6__ by using the _"Powers Method"_ resulting in `54432` as our final answer!
138+
### Answer 2
139+
---
140+
- The __BASE 16__ number `$FF` converts to `%1111 1111` in __BASE 2__, You can use the base conversion chart. `$F` = `%1111`
141+
- From there you can split __BASE 2__ `%1111 1111` to look like `%111 111 111` and using the conversion `&7` = `%111` you can convert this __BASE 2__ to __BASE 8__ `&777`
142+
### Answer 3
143+
---
144+
- I would suggest converting the __BASE 16__ number `$37` to __BASE 2__ which results in `%0011 0111`.
145+
- From there you can add `%0011 0111` with `%1011 0110` resulting in `1110 1101` or `ED` in __BASE 16__.
146+
147+
</details>
148+
<br />
149+
150+
151+
:::

src/part1/registers.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,45 @@ The other pairs work similarly.
6565
Modifying `de` actually modifies both `d` and `e` at the same time, and modifying either individually also affects the pair.
6666
How do we modify registers?
6767
Let's see how, with our first assembly instructions!
68+
69+
:::challenge Challenge!
70+
71+
1. You store the number `16` into the register `bc`, then store the number `14` into the register `c`. What is the current value of the register `bc`?
72+
(HINT: you might need to do some conversions :>)
73+
2. Can you store numbers larger than 255 into a single register? Why or why not?
74+
75+
76+
77+
<details>
78+
<summary>Answer (Click me!)</summary>
79+
80+
### Answer 1
81+
---
82+
By converting `256` and `14` to their __BASE 2__ format
83+
84+
> (`%0000 0001 0000 0000` & `%0000 0000 0000 1110` respectively)
85+
86+
The computer will update the register `bc` with the format
87+
88+
> `0000 0001 XXXX XXXX`
89+
where you replace the _X_ 's with `%0000 1110`.
90+
91+
This is possible only because you are updating the 4 bits in register `c`. Not the full 16.
92+
93+
This results in the answer `0001 1110` or `30`.
94+
95+
### Answer 2
96+
---
97+
Yes and No.
98+
99+
You can store numbers larger than `255` using a method we will go over later in this tutorial.
100+
101+
At this point however, numbers larger than `255` is not possible.
102+
103+
`256`, when converted to __BASE 2__ results in `%1 0000 0000` which is 1 bit larger than what the register can hold. This will result in what is called an _overflow_
104+
105+
</details>
106+
<br />
107+
108+
109+
:::

0 commit comments

Comments
 (0)