News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

What if I mess up?

Started by Evan, December 07, 2013, 04:09:51 PM

Previous topic - Next topic

Evan

Do not do this code it's is a MASM that kinda went wrong ...

byte1 BYTE '0111h'

dedndave

 :biggrin:

BYTE's contain 8 bits
111h is 9 bits - you need at least a WORD

Evan

A word is bigger than a byte.

dedndave

BYTE, 8 bits
WORD, 16 bits
DWORD, 32 bits  (same size as REAL4)
QWORD, 64 bits  (same size as REAL8)
OWORD, 128 bits

TBYTE, 80 bits  (same size as REAL10)

Evan


dedndave

9 bits
0001 0000 0000

for 8 bits, the max is 0FFh
1111 1111

dedndave

you could use 2 bytes
    db 0,1
very similar to
    dw 100h

Evan

Quote from: Evan on December 09, 2013, 06:50:32 PM
Would
byte1 BYTE '0100h'
work?
Is it this?
byte1 BYTE '0FFh'


or


byte1 BYTE 'FFh'

What does a full byte in hex look like?

Is 0xFF a full byte?

Evan

Quote from: dedndave on December 09, 2013, 06:51:26 PM
9 bits
0001 0000 0000

for 8 bits, the max is 0FFh
1111 1111



Quote from: dedndave on December 07, 2013, 05:38:32 PM
:biggrin:


BYTE's contain 8 bits
111h is 9 bits - you need at least a WORD
Yes. If 8 bits is a byte.

:D


So 0xFF is like 99(base ten)


and my calculator says 256 or 255 base ten must be a full byte.

dedndave

a byte holds 8 bits, in common parlance

in binary
11111111
or
1111  1111

in hexadecimal
FF
or
0FFh

in decimal
255

the range for a signed byte is -128 to +127
the range for an unsigned byte is 0 to 255

Evan

Quote from: dedndave on December 09, 2013, 07:34:34 PM
a byte holds 8 bits, in common parlance

in binary
11111111
or
1111  1111

in hexadecimal
FF
or
0FFh

in decimal
255

the range for a signed byte is -128 to +127
the range for an unsigned byte is 0 to 255
How do I figure out the explanation of making negative numbers on the computer?


Is that how signing works somehow?

Evan

#11
Is this it?
http://en.wikipedia.org/wiki/Signedness


Is this MASM friendly?
[quote source='wikipedia']For example, 0xFFFFFFFF gives −1, but 0xFFFFFFFFU gives 4,294,967,295 for 32-bit code.[/quote]


Would 0xFF be -1(base ten) and 0xFFU be 256(base ten) or 255(base ten)?


I would like to believe 0xFFU is 256(base ten) with all numbers being natural numbers including zero.

sinsi

Evan, you and dave seem to be talking about two different things.
This code works because it is a string due to using quotes
byte1 BYTE '0111h'
Without the quotes it is a number which is too big for a byte
byte1 BYTE 0111h

dedndave

hi sinsi - i saw the quotes - my assumption was that was how he got it to assemble without error
but, the intent was to define a value as hexadecimal - not a string

Evan - you may want to do some reading on basic data concepts
signed values normally use "two's compliment" form
you can google that term and find many descriptive texts

https://courses.engr.illinois.edu/ece390/books/artofasm/artofasm.html

start with chapter 1 - then, ask questions when something isn't clear   :t

you can put that url into translate.google.com and it will translate the entire site for you
by the way - what is your native language ???

Evan

Quote
Quote from: dedndave on December 10, 2013, 03:20:28 AM
hi sinsi - i saw the quotes - my assumption was that was how he got it to assemble without error
but, the intent was to define a value as hexadecimal - not a string

Evan - you may want to do some reading on basic data concepts
signed values normally use "two's compliment" form
you can google that term and find many descriptive texts

https://courses.engr.illinois.edu/ece390/books/artofasm/artofasm.html

start with chapter 1 - then, ask questions when something isn't clear   :t

you can put that url into translate.google.com and it will translate the entire site for you
by the way - what is your native language ???
Yeah well don't we always need a 0 in computers?
Does 0xFFU meaning 256(baseten) make sense?
Where I know that register is a positive one?
Including zero?


Or can I not use zero in this register and did my machine break?


Would my machine be okay if I don't use 0 in the register?


Do I then get to count up 1 to 256


Or can I count 0 to 256 in 0xFFU this whole time?
0 to 255
1 to 256
0 to 256


In 0xFFU
I am not sure.


Should I go with 0xFF meaning 255(baseten) and 0xFFU meaning ((-255 to 255))(base ten)?